From b1410412ebcf74c79fccc7ffa7d53eb1c120df12 Mon Sep 17 00:00:00 2001 From: cjhardee Date: Thu, 29 Jul 2010 20:03:05 +0000 Subject: [PATCH] Added a couple of checks to make sure the vm exists and moved others so they'll be checked less often. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6913 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/esx.pm | 30 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/esx.pm b/xCAT-server/lib/xcat/plugins/esx.pm index 25a364fcf..b654e5c0f 100644 --- a/xCAT-server/lib/xcat/plugins/esx.pm +++ b/xCAT-server/lib/xcat/plugins/esx.pm @@ -462,10 +462,10 @@ sub inv { my $hyp = $args{hyp}; if (not defined $args{vmview}) { #attempt one refresh $args{vmview} = $hyphash{$hyp}->{conn}->find_entity_view(view_type => 'VirtualMachine',properties=>['config.name','runtime.powerState'],filter=>{name=>$node}); - } - if (not defined $args{vmview}) { - sendmsg([1,"VM does not appear to exist"],$node); - return; + if (not defined $args{vmview}) { + sendmsg([1,"VM does not appear to exist"],$node); + return; + } } my $vmview = $args{vmview}; my $uuid = $vmview->config->uuid; @@ -504,11 +504,11 @@ sub chvm { $args{vmview} = $hyphash{$hyp}->{conn}->find_entity_view(view_type => 'VirtualMachine', properties=>['config.name','runtime.powerState'], filter=>{name=>$node}); - } - if (not defined $args{vmview}) { + if (not defined $args{vmview}) { sendmsg([1,"VM does not appear to exist"],$node); return; - } + } + } @ARGV= @{$args{exargs}}; my @deregister; my @purge; @@ -1203,10 +1203,10 @@ sub rmvm { my $hyp = $args{hyp}; if (not defined $args{vmview}) { #attempt one refresh $args{vmview} = $hyphash{$hyp}->{conn}->find_entity_view(view_type => 'VirtualMachine',properties=>['config.name','runtime.powerState'],filter=>{name=>$node}); - } - if (not defined $args{vmview}) { - sendmsg([1,"VM does not appear to exist"],$node); - return; + if (not defined $args{vmview}) { + sendmsg([1,"VM does not appear to exist"],$node); + return; + } } @ARGV= @{$args{exargs}}; require Getopt::Long; @@ -1286,6 +1286,10 @@ sub power { my $pretendop = $args{pretendop}; #to pretend a system was on for reset or boot when we have to turn it off internally for reconfig if (not defined $args{vmview}) { #attempt one refresh $args{vmview} = $hyphash{$hyp}->{conn}->find_entity_view(view_type => 'VirtualMachine',properties=>['config.name','config','runtime.powerState'],filter=>{name=>$node}); + if (not defined $args{vmview}) { + sendmsg([1,"VM does not appear to exist"],$node); + return; + } } @ARGV = @{$args{exargs}}; #for getoptions; my $forceon; @@ -1627,6 +1631,10 @@ sub setboot { my $hyp = $args{hyp}; if (not defined $args{vmview}) { #attempt one refresh $args{vmview} = $hyphash{$hyp}->{conn}->find_entity_view(view_type => 'VirtualMachine',properties=>['config.name'],filter=>{name=>$node}); + if (not defined $args{vmview}) { + sendmsg([1,"VM does not appear to exist"],$node); + return; + } } my $bootorder = ${$args{exargs}}[0]; #NOTE: VMware simply does not currently seem to allow programatically changing the boot