VMware {code} Community
gdan2000
Contributor
Contributor
Jump to solution

add VMFS5 disk to VM using Perl SDK

Hi

Each of my VM's has one hard disk on nfs datastore

   9  VirtualLsiLogicController=HASH(0x46f5bc0)

      'busNumber' => 0

      'controllerKey' => 100

      'device' => ARRAY(0x520e190)

         0  2000

      'deviceInfo' => Description=HASH(0x520e148)

         'label' => 'SCSI controller 0'

         'summary' => 'LSI Logic'

      'hotAddRemove' => 1

      'key' => 1000

      'scsiCtlrUnitNumber' => 7

      'sharedBus' => VirtualSCSISharing=HASH(0x520de78)

         'val' => 'noSharing'

I have to find an option to add a new disk which is located on another datastore (Serial attached SCSI disk to each ESXi )


dsbrowse.pl --name vp-dscs1-sb1

     Summary

      Name             : vp-dscs1-sb1

      Location         : ds:///vmfs/volumes/5309af02-0ba1ac70-e723-10604bb454c8/

      File system      : VMFS

      Maximum Capacity : 931.25 GB

      Available space  : 930.2978515625 GB

I tried to use a vdiskcreate.pl , but it does not have an option to use different datastore for a new disk and always creates a new disk on a nfs datastore.

It's pretty easy to do with a wizard but I have to run it ~50 times

Thanks

0 Kudos
1 Solution

Accepted Solutions
MadhavParab
Contributor
Contributor
Jump to solution



$devspec = VMUtils::get_vdisk_spec(vm => $entity_view,
                                      backingtype => 'regular',
                                      diskMode => $diskMode,
                                      fileName => $vm_disk_filename,
                                      controllerKey => $controllerKey,
                                      unitNumber => $unitnumber,
                                      size => $disksize);


you need to specify the new datastore name in the filename variable.


e.g $vm_disk_filename = "[ new_datastore ] tstvm/tstvm.vmdk"

View solution in original post

0 Kudos
3 Replies
MadhavParab
Contributor
Contributor
Jump to solution



$devspec = VMUtils::get_vdisk_spec(vm => $entity_view,
                                      backingtype => 'regular',
                                      diskMode => $diskMode,
                                      fileName => $vm_disk_filename,
                                      controllerKey => $controllerKey,
                                      unitNumber => $unitnumber,
                                      size => $disksize);


you need to specify the new datastore name in the filename variable.


e.g $vm_disk_filename = "[ new_datastore ] tstvm/tstvm.vmdk"

0 Kudos
gdan2000
Contributor
Contributor
Jump to solution

It does not work,

I used the following command:

   

vdiskcreate.pl --filename '[vp-dscs1-sb1] test7/test7.vmdk' --host testserver --datacenter Site-1 --vmname test7

Adding Virtual Disk on Virtual machine test7 in the host testserver

Virtual Disk created.

And as a result I get one more disk on existing nfs datastore ( [vms_nfs] )  instead of [vp-dscs1-sb1] , but this time a new disk was created in a nested folder ...

          [vms_nfs] test7/[vp-dscs1-sb1] test7/test7.vmdk

Thanks

0 Kudos
gdan2000
Contributor
Contributor
Jump to solution

I found the problem,

generate_filename in VMUtils.pm generates wrong filename string

So I overwrited the function and it works fine now.

Next challenge is to add "thin" option...

Thanks a lot

0 Kudos