mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 11:22:27 +00:00 
			
		
		
		
	-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
This commit is contained in:
		
							
								
								
									
										1
									
								
								xCAT-client/bin/chhypervisor
									
									
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								xCAT-client/bin/chhypervisor
									
									
									
									
									
										Symbolic link
									
								
							| @@ -0,0 +1 @@ | ||||
| xcatclient | ||||
| @@ -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}; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user