From 2aee379b84c433c9e9d86af37d28ce1d395efc8c Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 28 Oct 2013 16:07:06 -0400 Subject: [PATCH] Add formatdisk to esx plugin, to be called by mkstorage --- xCAT-server/lib/xcat/plugins/esx.pm | 36 ++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/esx.pm b/xCAT-server/lib/xcat/plugins/esx.pm index 8ab62a3be..90384d9db 100644 --- a/xCAT-server/lib/xcat/plugins/esx.pm +++ b/xCAT-server/lib/xcat/plugins/esx.pm @@ -124,6 +124,7 @@ sub handled_commands{ rpower => 'nodehm:power,mgt', rsetboot => 'nodehm:power,mgt', rmigrate => 'nodehm:power,mgt', + formatdisk => "nodetype:os=(esxi.*)", mkvm => 'nodehm:mgt', rmvm => 'nodehm:mgt', clonevm => 'nodehm:mgt', @@ -203,7 +204,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' or $command eq "chhypervisor") { + if ($command eq "rmhypervisor" or $command eq 'lsvm' or $command eq 'rshutdown' or $command eq "chhypervisor" or $command eq "formatdisk") { $hyp_hash{$node}{nodes} = [$node]; } else { my $ent = $vmtabhash->{$node}->[0]; @@ -617,6 +618,8 @@ sub do_cmd { generic_vm_operation(['config.name','runtime.host'],\&setboot,@exargs); } elsif ($command eq 'rinv') { generic_vm_operation(['config.name','config','runtime.host','layoutEx'],\&inv,@exargs); + } elsif ($command eq 'formatdisk') { + generic_hyp_operation(\&formatdisk,@exargs); } elsif ($command eq 'rmhypervisor') { generic_hyp_operation(\&rmhypervisor,@exargs); } elsif ($command eq 'rshutdown') { @@ -2146,6 +2149,37 @@ sub rshutdown_inmaintenance { return; } +sub formatdisk { + my %args = @_; + my $hyp = $args{hyp}; + $hyphash{$hyp}->{hostview} = get_hostview(hypname=>$hyp,conn=>$hyphash{$hyp}->{conn},properties=>['config','configManager']); + @ARGV = @{$args{exargs}}; + my $nid; + my $name; + GetOptions( + 'id=s' => \$nid, + 'name=s' => \$name, + ); + my $hostview = $hyphash{$hyp}->{hostview}; + if (defined $hyphash{$hyp}->{hostview}) { + my $hdss = $hostview->{vim}->get_view(mo_ref=>$hostview->configManager->storageSystem); + $hdss->RescanAllHba(); + my $dss = $hostview->{vim}->get_view(mo_ref=>$hostview->configManager->datastoreSystem); + my $diskList = $dss->QueryAvailableDisksForVmfs(); + foreach my $disk (@$diskList) { + foreach my $id (@{$disk->{descriptor}}) { + if (lc($id->{id}) eq lc('naa.'.$nid)) { + my $options = $dss->QueryVmfsDatastoreCreateOptions(devicePath => $disk->devicePath); + @$options[0]->spec->vmfs->volumeName($name); + my $newDatastore = $dss->CreateVmfsDatastore(spec => @$options[0]->spec ); + } + } + } + + } + return; +} + sub rmhypervisor { my %args = @_; my $hyp = $args{hyp};