From 54cdb92978758488821d74d5b43737429ee47891 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Thu, 9 Jun 2011 20:59:43 +0000 Subject: [PATCH] -Add chhypervisor to manage vCenter enter/exit maintenance mode git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9777 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-client/bin/chhypervisor | 1 + xCAT-server/lib/xcat/plugins/esx.pm | 48 ++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 120000 xCAT-client/bin/chhypervisor diff --git a/xCAT-client/bin/chhypervisor b/xCAT-client/bin/chhypervisor new file mode 120000 index 000000000..b1c9eea11 --- /dev/null +++ b/xCAT-client/bin/chhypervisor @@ -0,0 +1 @@ +xcatclient \ No newline at end of file diff --git a/xCAT-server/lib/xcat/plugins/esx.pm b/xCAT-server/lib/xcat/plugins/esx.pm index bcd98fbf4..556b23880 100644 --- a/xCAT-server/lib/xcat/plugins/esx.pm +++ b/xCAT-server/lib/xcat/plugins/esx.pm @@ -87,6 +87,7 @@ sub handled_commands{ rshutdown => "nodetype:os=(esxi.*)", lsvm => ['hypervisor:type','nodetype:os=(esx.*)'], rmhypervisor => ['hypervisor:type','nodetype:os=(esx.*)'], + chhypervisor => ['hypervisor:type','nodetype:os=(esx.*)'], #lsvm => 'nodehm:mgt', not really supported yet }; } @@ -149,7 +150,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') { + if ($command eq "rmhypervisor" or $command eq 'lsvm' or $command eq 'rshutdown' or $command eq "chhypervisor") { $hyp_hash{$node}{nodes} = [$node]; } else { my $ent = $vmtabhash->{$node}->[0]; @@ -547,6 +548,8 @@ sub do_cmd { generic_hyp_operation(\&rmhypervisor,@exargs); } elsif ($command eq 'rshutdown') { generic_hyp_operation(\&rshutdown,@exargs); + } elsif ($command eq 'chhypervisor') { + generic_hyp_operation(\&chhypervisor,@exargs); } elsif ($command eq 'lsvm') { generic_hyp_operation(\&lsvm,@exargs); } elsif ($command eq 'clonevm') { @@ -1935,6 +1938,49 @@ sub lsvm { return; } +sub chhypervisor { + my %args = @_; + @ARGV = @{$args{exargs}}; #for getoptions; + my $maintenance; + my $online; + my $stat; + require Getopt::Long; + GetOptions( + 'maintenance|m' => \$maintenance, + 'online|o' => \$online, + 'show|s' => \$stat, + ); + my $hyp = $args{hyp}; + $hyphash{$hyp}->{hostview} = get_hostview(hypname=>$hyp,conn=>$hyphash{$hyp}->{conn}); #,properties=>['config','configManager']); + if ($maintenance) { + if (defined $hyphash{$hyp}->{hostview}) { + my $task = $hyphash{$hyp}->{hostview}->EnterMaintenanceMode_Task(timeout=>0); + $running_tasks{$task}->{task} = $task; + $running_tasks{$task}->{callback} = \&generic_task_callback; + $running_tasks{$task}->{hyp} = $args{hyp}; + $running_tasks{$task}->{data} = { node => $hyp , successtext => "hypervisor in maintenance mode"}; + } + } elsif ($online) { + if (defined $hyphash{$hyp}->{hostview}) { + my $task = $hyphash{$hyp}->{hostview}->ExitMaintenanceMode_Task(timeout=>0); + $running_tasks{$task}->{task} = $task; + $running_tasks{$task}->{callback} = \&generic_task_callback; + $running_tasks{$task}->{hyp} = $args{hyp}; + $running_tasks{$task}->{data} = { node => $hyp , successtext => "hypervisor online"}; + } + } elsif ($stat) { + if (defined $hyphash{$hyp}->{hostview}) { + if ($hyphash{$hyp}->{hostview}->runtime->inMaintenanceMode) { + xCAT::SvrUtils::sendmsg("hypervisor in maintenance mode", $output_handler,$hyp); + } else { + xCAT::SvrUtils::sendmsg("hypervisor online", $output_handler,$hyp); + } + } + } + + return; +} + sub rshutdown { #TODO: refactor with next function too my %args = @_; my $hyp = $args{hyp};