From 50b73a444e8b1291d7a37200547a8c5a06da416f Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Mon, 9 Aug 2010 15:12:05 +0000 Subject: [PATCH] -Fix potential issue where a hypervisor named 'conn' could make for a bad day. Slightly improve some performance by eliminating string equality checks. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7012 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/esx.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/esx.pm b/xCAT-server/lib/xcat/plugins/esx.pm index 9a2927603..6c6c508e5 100644 --- a/xCAT-server/lib/xcat/plugins/esx.pm +++ b/xCAT-server/lib/xcat/plugins/esx.pm @@ -789,7 +789,7 @@ sub connecthost_callback { if ($state eq "success") { $hypready{$args->{hypname}}=1; #declare readiness enable_vmotion(hypname=>$args->{hypname},hostview=>$args->{hostview},conn=>$args->{conn}); - $vcenterhash{$args->{vcenter}}->{$args->{hypname}} = 'good'; + $vcenterhash{$args->{vcenter}}->{goodhyps}->{$args->{hypname}} = 1; if (defined $args->{depfun}) { #If a function is waiting for the host connect to go valid, call it $args->{depfun}->($args->{depargs}); } @@ -822,7 +822,7 @@ sub connecthost_callback { } xCAT::SvrUtils::sendmsg([1,$error], $output_handler); #,$node); $hypready{$args->{hypname}} = -1; #Impossible for this hypervisor to ever be ready - $vcenterhash{$args->{vcenter}}->{$args->{hypname}} = 'bad'; + $vcenterhash{$args->{vcenter}}->{badhyps}->{$args->{hypname}} = 1; } } @@ -1079,11 +1079,11 @@ sub migrate { } return; } - if ((not $offline and $vcenterhash{$vcenter}->{$hyp} eq 'bad') or $vcenterhash{$vcenter}->{$target} eq 'bad') { + if ((not $offline and $vcenterhash{$vcenter}->{badhyps}->{$hyp}) or $vcenterhash{$vcenter}->{badhyps}->{$target}) { xCAT::SvrUtils::sendmsg([1,"Unable to migrate ".join(',',@nodes)." to $target due to inability to validate vCenter connectivity"], $output_handler); return; } - if (($offline or $vcenterhash{$vcenter}->{$hyp} eq 'good') and $vcenterhash{$vcenter}->{$target} eq 'good') { + if (($offline or $vcenterhash{$vcenter}->{goodhyps}->{$hyp}) and $vcenterhash{$vcenter}->{goodhyps}->{$target}) { unless (validate_datastore_prereqs(\@nodes,$target)) { xCAT::SvrUtils::sendmsg([1,"Unable to verify storage state on target system"], $output_handler); return; @@ -2063,7 +2063,7 @@ sub validate_vcenter_prereqs { #Communicate with vCenter and ensure this host is if ($hview->{'summary.config.name'} =~ /^$hyp(?:\.|\z)/ or $hview->{'summary.config.name'} =~ /^$name(?:\.|\z)/) { #Looks good, call the dependent function after declaring the state of vcenter to hypervisor as good if ($hview->{'summary.runtime.connectionState'}->val eq 'connected') { enable_vmotion(hypname=>$hyp,hostview=>$hview,conn=>$hyphash{$hyp}->{vcenter}->{conn}); - $vcenterhash{$vcenter}->{$hyp} = 'good'; + $vcenterhash{$vcenter}->{goodhyps}->{$hyp} = 1; $depfun->($depargs); if ($hview->parent->type eq 'ClusterComputeResource') { #if it is in a cluster, we can directly remove it $hyphash{$hyp}->{deletionref} = $hview->{mo_ref}; @@ -2138,7 +2138,7 @@ sub addhosttovcenter { if ($hyphash{$args->{hypname}}->{offline}) { #let it stay offline $hypready{$args->{hypname}}=1; #declare readiness #enable_vmotion(hypname=>$args->{hypname},hostview=>$args->{hostview},conn=>$args->{conn}); - $vcenterhash{$args->{vcenter}}->{$args->{hypname}} = 'good'; + $vcenterhash{$args->{vcenter}}->{goodhyps}->{$args->{hypname}} = 1; if (defined $args->{depfun}) { #If a function is waiting for the host connect to go valid, call it $args->{depfun}->($args->{depargs}); }