-Implement rshutdown command
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7496 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		@@ -77,6 +77,7 @@ sub handled_commands{
 | 
			
		||||
        clonevm => 'nodehm:mgt',
 | 
			
		||||
		rinv => 'nodehm:mgt',
 | 
			
		||||
                chvm => 'nodehm:mgt',
 | 
			
		||||
        rshutdown => "nodetype:os=(esxi.*)",
 | 
			
		||||
        lsvm => ['hypervisor:type','nodetype:os=(esx.*)'],
 | 
			
		||||
		rmhypervisor => ['hypervisor:type','nodetype:os=(esx.*)'],
 | 
			
		||||
		#lsvm => 'nodehm:mgt', not really supported yet
 | 
			
		||||
@@ -140,7 +141,7 @@ sub preprocess_request {
 | 
			
		||||
 | 
			
		||||
	my $vmtabhash = $vmtab->getNodesAttribs($noderange,['host']);
 | 
			
		||||
	foreach my $node (@$noderange){
 | 
			
		||||
        if ($command eq "rmhypervisor" or $command eq 'lsvm') {
 | 
			
		||||
        if ($command eq "rmhypervisor" or $command eq 'lsvm' or $command eq 'rshutdown') {
 | 
			
		||||
            $hyp_hash{$node}{nodes} = [$node];
 | 
			
		||||
        } else {
 | 
			
		||||
        my $ent = $vmtabhash->{$node}->[0];
 | 
			
		||||
@@ -458,6 +459,8 @@ sub do_cmd {
 | 
			
		||||
        generic_vm_operation(['config.name','config','runtime.host'],\&inv,@exargs);
 | 
			
		||||
    } elsif ($command eq 'rmhypervisor') {
 | 
			
		||||
        generic_hyp_operation(\&rmhypervisor,@exargs);
 | 
			
		||||
    } elsif ($command eq 'rshutdown') {
 | 
			
		||||
        generic_hyp_operation(\&rshutdown,@exargs);
 | 
			
		||||
    } elsif ($command eq 'lsvm') {
 | 
			
		||||
        generic_hyp_operation(\&lsvm,@exargs);
 | 
			
		||||
    } elsif ($command eq 'clonevm') {
 | 
			
		||||
@@ -1603,6 +1606,41 @@ sub lsvm {
 | 
			
		||||
    return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub rshutdown { #TODO: refactor with next function too
 | 
			
		||||
    my %args = @_;
 | 
			
		||||
    my $hyp = $args{hyp};
 | 
			
		||||
    $hyphash{$hyp}->{hostview} = get_hostview(hypname=>$hyp,conn=>$hyphash{$hyp}->{conn}); #,properties=>['config','configManager']); 
 | 
			
		||||
    if (defined $hyphash{$hyp}->{hostview}) {
 | 
			
		||||
        my $task = $hyphash{$hyp}->{hostview}->EnterMaintenanceMode_Task(timeout=>0);
 | 
			
		||||
        $running_tasks{$task}->{task} = $task;
 | 
			
		||||
        $running_tasks{$task}->{callback} = \&rshutdown_inmaintenance;
 | 
			
		||||
        $running_tasks{$task}->{hyp} = $args{hyp}; 
 | 
			
		||||
        $running_tasks{$task}->{data} = { node => $hyp }; 
 | 
			
		||||
    }
 | 
			
		||||
    return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub rshutdown_inmaintenance {
 | 
			
		||||
    my $task = shift;
 | 
			
		||||
    my $parms = shift;
 | 
			
		||||
    my $state = $task->info->state->val;
 | 
			
		||||
    my $node = $parms->{node};
 | 
			
		||||
    my $intent = $parms->{successtext};
 | 
			
		||||
    if ($state eq 'success') {
 | 
			
		||||
        my $hyp = $parms->{node};
 | 
			
		||||
        if (defined $hyphash{$hyp}->{hostview}) {
 | 
			
		||||
            my $task = $hyphash{$hyp}->{hostview}->ShutdownHost_Task(force=>0);
 | 
			
		||||
            $running_tasks{$task}->{task} = $task;
 | 
			
		||||
            $running_tasks{$task}->{callback} = \&generic_task_callback;
 | 
			
		||||
            $running_tasks{$task}->{hyp} = $hyp;
 | 
			
		||||
            $running_tasks{$task}->{data} = { node => $hyp, successtext => "shutdown initiated" };
 | 
			
		||||
        }
 | 
			
		||||
    } elsif ($state eq 'error') {
 | 
			
		||||
        relay_vmware_err($task,"",$node);
 | 
			
		||||
    }
 | 
			
		||||
    return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub rmhypervisor {
 | 
			
		||||
    my %args = @_;
 | 
			
		||||
    my $hyp = $args{hyp};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user