1 Reply Latest reply on Sep 25, 2013 1:49 AM by Chiqos

    Add VMDK to VM using SDRS recommendation

    Chiqos Novice

      Hi guys,

       

      I am trying to add a disk to a VM following SDRS recommendation based on William Lam work.

       

      Here is my code:

       

      my $storagePod = Vim::find_entity_view(view_type => 'StoragePod', filter => {'name' => 'DCL_DC1_NOPROD_01'}, properties => ['name']);

      my $storageMgr = Vim::get_view(mo_ref => Vim::get_service_content()->storageResourceManager);

      my $podSpec = StorageDrsPodSelectionSpec->new(storagePod => $storagePod);

      my $vmSpec = VirtualMachineConfigSpec->new(files => $vm->config->files);

      my $storageSpec = StoragePlacementSpec->new(type => 'reconfigure', vm => $vm, podSelectionSpec => $podSpec, configSpec => $vmSpec);

      my $result = $storageMgr->RecommendDatastores(storageSpec => $storageSpec);

       

       

      Bit I get this error:

       

       

      SOAP Fault:

      -----------

      Fault string: A specified parameter was not correct.

      StoragePlacementSpec.podSelectionSpec.storagePod

       

       

      Any idea?

       

       

      Thanks in advance.

        • 1. Re: Add VMDK to VM using SDRS recommendation
          Chiqos Novice

          Hi,

           

          I think I was doing wrong with the VirtualmachineConfigSpec, I corrected that (I am not using the default method, as I cannot specify the SCSI controller). I have a doubt regarding the backing object, which requires a file name starting with [YOUR_DATASORE].


          my $vm_disk_filename = VMUtils::generate_filename(vm => $vm, filename => $file_name);

          my $disk_mode = VMUtils::get_diskmode(nopersist => $nopersist, independent => $independent);

          my $disk_backing_info = VirtualDiskFlatVer2BackingInfo->new(diskMode => $disk_mode, fileName => "", thinProvisioned => $o_thin);

          my $disk = VirtualDisk->new(controllerKey => $controller->key,

                                  unitNumber => $scsi_target,

                                  backing => $disk_backing_info,

                                  key => -1,

                                  capacityInKB => $o_size);

          my $diskSpec = VirtualDeviceConfigSpec->new(operation => VirtualDeviceConfigSpecOperation->new('add'),

                                  device => $disk,

                                  fileOperation => VirtualDeviceConfigSpecFileOperation->new('create'));

          my $vmspec = VirtualMachineConfigSpec->new(deviceChange => [$diskSpec] );

           

           

          But the error still come from my StoragePod object, which seems valid when I print it out.

           

          The --verbose option didn't help me so much:

           

          <soapenv:Fault><faultcode>ServerFaultCode</faultcode><faultstring>A specified parameter was not correct.

          StoragePlacementSpec.podSelectionSpec.storagePod</faultstring><detail><InvalidArgumentFault xmlns="urn:vim25" xsi:type="InvalidArgument"><invalidProperty>StoragePlacementSpec.podSelectionSpec.storagePod</invalidProperty></InvalidArgumentFault></detail></soapenv:Fault>

          </soapenv:Body>

          </soapenv:Envelope>';

           

          Any idea to help me troubleshooting?