-Reinstate vm reparenting when vCenter changed without xCAT being involved, without the previous
performance penalty it incurred. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8928 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
de779f7f2d
commit
1e48cdd307
@ -39,6 +39,7 @@ my $output_handler; #Pointer to the function to drive results to client
|
||||
my $executerequest;
|
||||
my $usehostnamesforvcenter;
|
||||
my %tablecfg; #to hold the tables
|
||||
my %hostrefbynode;
|
||||
my $currkey;
|
||||
my $requester;
|
||||
my $viavcenter;
|
||||
@ -1640,24 +1641,19 @@ 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; }
|
||||
confess "I didn't expect this at all...\n"; #remove if hit, but want to see if this actually goes further..
|
||||
#$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}) {
|
||||
$node =~ s/\..*//; #try the short name;
|
||||
}
|
||||
if (defined $tablecfg{vm}->{$node}) { #see if the host pointer requires a refresh
|
||||
my $hostref = $hostrefbynode{$node};
|
||||
if ($hostref eq $_->{'runtime.host'}->value) { next; } #the actual host reference matches the one that we got when populating hostviews based on what the table had to say #TODO: does this mean it is buggy if we want to mkvm/rmigrate/etc if the current vm.host is wrong and the noderange doesn't have something on the right hostview making us not get it in the
|
||||
#mass request? Or is it just slower because it hand gets host views?
|
||||
my $host = $hyphash{$hyp}->{conn}->get_view(mo_ref=>$_->{'runtime.host'},properties=>['summary.config.name']);
|
||||
$host = $host->{'summary.config.name'};
|
||||
if ( $tablecfg{vm}->{$node}->[0]->{host} eq "$host" ) { next; }
|
||||
my $newnhost = inet_aton($host);
|
||||
my $oldnhost = inet_aton($tablecfg{vm}->{$node}->[0]->{host});
|
||||
if ($newnhost eq $oldnhost) { next; } #it resolved fine
|
||||
$host = $host->{'summary.config.name'};
|
||||
my $shost = $host;
|
||||
$shost =~ s/\..*//;
|
||||
if ( $tablecfg{vm}->{$node}->[0]->{host} eq "$shost" ) { next; }
|
||||
#time to figure out which of these is a node
|
||||
my @nodes = noderange("$host,$shost");
|
||||
my $vmtab = xCAT::Table->new("vm",-create=>1);
|
||||
@ -1665,7 +1661,6 @@ sub generic_vm_operation { #The general form of firing per-vm requests to ESX hy
|
||||
die "Error opening vm table";
|
||||
}
|
||||
if ($nodes[0]) {
|
||||
print $node. " and ".$nodes[0];
|
||||
$vmtab->setNodeAttribs($node,{host=>$nodes[0]});
|
||||
} #else {
|
||||
# $vmtab->setNodeAttribs($node,{host=>$host});
|
||||
@ -2779,21 +2774,30 @@ sub populate_vcenter_hostviews {
|
||||
my $hosts = join(")|(",@hypervisors);
|
||||
$hosts = '^(('.$hosts.'))(\z|\.)';
|
||||
my $search = qr/$hosts/;
|
||||
my @hypviews = @{$vcenterhash{$vcenter}->{conn}->find_entity_views(view_type=>'HostSystem',properties=>['summary.config.name','summary.runtime.connectionState','runtime.inMaintenanceMode','parent','configManager'],filter=>{'summary.config.name'=>$search})};
|
||||
my @hypviews = @{$vcenterhash{$vcenter}->{conn}->find_entity_views(view_type=>'HostSystem',properties=>['summary.config.name','summary.runtime.connectionState','runtime.inMaintenanceMode','parent','configManager','summary.host'],filter=>{'summary.config.name'=>$search})};
|
||||
foreach (@hypviews) {
|
||||
my $hypname = $_->{'summary.config.name'};
|
||||
my $hypv=$_;
|
||||
my $hyp;
|
||||
if ($vcenterhash{$vcenter}->{allhyps}->{$hypname}) { #simplest case, config.name is exactly the same as node name
|
||||
$vcenterhash{$vcenter}->{hostviews}->{$hypname} = $_;
|
||||
$hyp=$hypname;
|
||||
} elsif ($nametohypmap{$hypname}) { #second case, there is a name mapping this to a real name
|
||||
$vcenterhash{$vcenter}->{hostviews}->{$nametohypmap{$hypname}} = $_;
|
||||
$hyp=$nametohypmap{$hypname};
|
||||
} else { #name as-is doesn't work, start stripping domain and hope for the best
|
||||
$hypname =~ s/\..*//;
|
||||
if ($vcenterhash{$vcenter}->{allhyps}->{$hypname}) { #shortname is a node
|
||||
$vcenterhash{$vcenter}->{hostviews}->{$hypname} = $_;
|
||||
$hyp=$hypname;
|
||||
} elsif ($nametohypmap{$hypname}) { #alias for node
|
||||
$vcenterhash{$vcenter}->{hostviews}->{$nametohypmap{$hypname}} = $_;
|
||||
$hyp=$nametohypmap{$hypname};
|
||||
}
|
||||
}
|
||||
foreach my $nodename (keys %{$hyphash{$hyp}->{nodes}}) {
|
||||
$hostrefbynode{$nodename}=$hypv->{'summary.host'}->value;
|
||||
}
|
||||
}
|
||||
$iterations--;
|
||||
@hypervisors=();
|
||||
|
Loading…
x
Reference in New Issue
Block a user