diff --git a/xCAT-server/lib/xcat/plugins/esx.pm b/xCAT-server/lib/xcat/plugins/esx.pm index 168fa6515..655556ee5 100644 --- a/xCAT-server/lib/xcat/plugins/esx.pm +++ b/xCAT-server/lib/xcat/plugins/esx.pm @@ -123,6 +123,7 @@ sub handled_commands{ mknetboot => "nodetype:os=(esxi.*)", mkinstall => "nodetype:os=(esxi5.*)", rpower => 'nodehm:power,mgt', + esxiready => "esx", rsetboot => 'nodehm:power,mgt', rmigrate => 'nodehm:power,mgt', formatdisk => "nodetype:os=(esxi.*)", @@ -180,8 +181,17 @@ sub preprocess_request { # exit if preprocesses my @requests; - my $noderange = $request->{node}; # array ref + my $noderange; my $command = $request->{command}->[0]; + if ($request->{node}) { + $noderange = $request->{node}; # array ref + } elsif ($command eq "esxiready") { + my $node; + ($node) = noderange($request->{'_xcat_clienthost'}->[0]); + $noderange = [$node]; + $request->{node} = $noderange; + } + my $extraargs = $request->{arg}; my @exargs=($request->{arg}); my %hyp_hash = (); @@ -212,7 +222,7 @@ sub preprocess_request { my $vmtabhash = $vmtab->getNodesAttribs($noderange,['host','migrationdest']); foreach my $node (@$noderange){ - if ($command eq "rmhypervisor" or $command eq 'lsvm' or $command eq 'rshutdown' or $command eq "chhypervisor" or $command eq "formatdisk" or $command eq 'rescansan') { + if ($command eq "rmhypervisor" or $command eq 'lsvm' or $command eq 'esxiready' or $command eq 'rshutdown' or $command eq "chhypervisor" or $command eq "formatdisk" or $command eq 'rescansan') { $hyp_hash{$node}{nodes} = [$node]; } else { my $ent = $vmtabhash->{$node}->[0]; @@ -363,7 +373,14 @@ sub process_request { } my $moreinfo; - my $noderange = $request->{node}; + my $noderange; + if ($request->{node}) { + $noderange = $request->{node}; # array ref + } elsif ($command eq "esxiready") { + my $node; + ($node) = noderange($request->{'_xcat_clienthost'}->[0]); + $noderange = [$node]; + } xCAT::VMCommon::grab_table_data($noderange,\%tablecfg,$output_handler); my @exargs; unless($command){ @@ -631,6 +648,9 @@ sub validate_licenses { sub do_cmd { my $command = shift; my @exargs = @_; + if ($command eq 'esxiready') { + return; + } if ($command eq 'rpower') { generic_vm_operation(['config.name','config.guestId','config.hardware.memoryMB','config.hardware.numCPU','runtime.powerState','runtime.host'],\&power,@exargs); } elsif ($command eq 'rmvm') { @@ -4621,6 +4641,11 @@ sub makecustomizedmod { copy( "$::XCATROOT/share/xcat/netboot/esxi/48.esxifixup",$tempdir."/etc/init.d/48.esxifixup"); chmod(0755,"$tempdir/etc/init.d/48.esxifixup"); } + if ($osver =~ /esxi5/ and -e "$::XCATROOT/share/xcat/netboot/esxi/99.esxiready") { + mkpath($tempdir."/etc/init.d"); + copy( "$::XCATROOT/share/xcat/netboot/esxi/99.esxiready",$tempdir."/etc/init.d/99.esxiready"); + chmod(0755,"$tempdir/etc/init.d/99.esxiready"); + } if (-e "$::XCATROOT/share/xcat/netboot/esxi/xcatsplash") { mkpath($tempdir."/etc/vmware/"); copy( "$::XCATROOT/share/xcat/netboot/esxi/xcatsplash",$tempdir."/etc/vmware/welcome"); @@ -4911,6 +4936,7 @@ sub mkcommonboot { } else { $append = "-c $tp/boot.cfg.$bootmode"; } + $append .= " xcatd=$ksserver:3001"; if ($bootmode eq "install") { $append .= " ks=http://$ksserver/install/autoinst/$node"; esxi_kickstart_from_template(node=>$node,os=>$osver,arch=>$arch,profile=>$profile); diff --git a/xCAT-server/share/xcat/install/esxi/hypervisor.tmpl b/xCAT-server/share/xcat/install/esxi/hypervisor.tmpl index 6a200daa6..467c92ded 100644 --- a/xCAT-server/share/xcat/install/esxi/hypervisor.tmpl +++ b/xCAT-server/share/xcat/install/esxi/hypervisor.tmpl @@ -57,4 +57,11 @@ esxcli network ip set -e y esxcli network firewall ruleset set -r DHCPv6 -e y esxcli network firewall ruleset set -r sshServer -e y esxcli network ip interface ipv6 set -i vmk0 -d y +cat > /etc/init.d/xcatesxiready << EOF +echo -e "\nesxiready\n" | /bin/openssl s_client -quiet -connect $xcatd:3001 2>&1 | tee /tmp/foo.log +chkconfig --del xcatesxiready +rm -rf /etc/init.d/xcatesxiready +EOF +chmod +x xcatesxiready +chkconfig --add xcatesxiready reboot diff --git a/xCAT-server/share/xcat/netboot/esxi/99.esxiready b/xCAT-server/share/xcat/netboot/esxi/99.esxiready new file mode 100644 index 000000000..d0865a743 --- /dev/null +++ b/xCAT-server/share/xcat/netboot/esxi/99.esxiready @@ -0,0 +1,10 @@ +#!/bin/sh +for param in `vsish -e get /system/bootCmdLine|head -n 2 |tail -n 1`; do + if [ "xcatd" = ${param%=*} ]; then + xcatd=${param#*=} + fi +done +localcli network firewall unload +echo -e '\nesxiready' | openssl s_client -connect $xcatd +localcli network firewall load +return ${SUCCESS}