From c833ae295c0b49223d0353be0cf8bc595db47bdc Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Thu, 8 Jul 2010 14:22:33 +0000 Subject: [PATCH] -Remove most remaining calls to '_views' functions that become expensive on large configurations git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6677 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/esx.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/esx.pm b/xCAT-server/lib/xcat/plugins/esx.pm index abc2f6453..fda87ae44 100644 --- a/xCAT-server/lib/xcat/plugins/esx.pm +++ b/xCAT-server/lib/xcat/plugins/esx.pm @@ -1415,7 +1415,13 @@ sub generic_vm_operation { #The general form of firing per-vm requests to ESX hy foreach $hyp (keys %hyphash) { if ($viavcenterbyhyp->{$hyp}) { if ($vcviews{$hyphash{$hyp}->{vcenter}->{name}}) { next; } - $vcviews{$hyphash{$hyp}->{vcenter}->{name}} = $hyphash{$hyp}->{conn}->find_entity_views(view_type => 'VirtualMachine',properties=>$properties); + my @localvcviews=(); + my $node; + foreach $node (sort (keys %{$hyphash{$hyp}->{nodes}})){ + push @localvcviews,$hyphash{$hyp}->{conn}->find_entity_view(view_type => 'VirtualMachine',properties=>$properties,filter=>{'config.name'=>qr/^$node/}); + } + $vcviews{$hyphash{$hyp}->{vcenter}->{name}} = \@localvcviews; + #$vcviews{$hyphash{$hyp}->{vcenter}->{name}} = $hyphash{$hyp}->{conn}->find_entity_views(view_type => 'VirtualMachine',properties=>$properties); foreach (@{$vcviews{$hyphash{$hyp}->{vcenter}->{name}}}) { my $node = $_->{'config.name'}; unless (defined $tablecfg{vm}->{$node}) { @@ -1452,7 +1458,12 @@ sub generic_vm_operation { #The general form of firing per-vm requests to ESX hy if ($viavcenterbyhyp->{$hyp}) { $vmviews= $vcviews{$hyphash{$hyp}->{vcenter}->{name}} } else { - $vmviews = $hyphash{$hyp}->{conn}->find_entity_views(view_type => 'VirtualMachine',properties=>$properties); + $vmviews = []; + my $node; + foreach $node (sort (keys %{$hyphash{$hyp}->{nodes}})){ + push @{$vmviews},$hyphash{$hyp}->{conn}->find_entity_view(view_type => 'VirtualMachine',properties=>$properties,filter=>{'config.name'=>qr/^$node/}); + } + #$vmviews = $hyphash{$hyp}->{conn}->find_entity_views(view_type => 'VirtualMachine',properties=>$properties); } my %mgdvms; #sort into a hash for convenience foreach (@$vmviews) {