2

I am trying to create a VMFS datastore using the devicepath on my ESX host. Based on suggestions from the internet, I tried to use the 'QueryVmfsDatastoreCreateOptions' with devicePath as a parameter and then use the output of the above call (spec) to create a datastore using CreateVmfsDatastore.

I get an error when I try to invoke QueryVmfsDatastoreCreateOptions API

[root@localhost bin]# python dd_esx_disk.py -s 10.25.190.100 -u root -p Abcd123! --uuid eui.3221784b198087db8ccb707400000001
Device path: /vmfs/devices/disks/eui.3221784b198087db8ccb707400000001
Unexpected error: _InvokeMethod() takes at least 2 arguments (1 given)

Code:

def createDatastore(si, uuid):
    devicepath="/vmfs/devices/disks/"+ uuid
    print "Device path: %s" %devicepath
    try:
        vmfs_ds_options = vim.host.DatastoreSystem.QueryVmfsDatastoreCreateOptions(devicePath=devicepath, vmfsMajorVersion=5)
    except vim.fault.NotFound:
        print "Not found"
    except vim.fault.HostConfigFault:
        print "host config fault"
    except vmodl.fault.NotSupported:
        print "Not supported"
    except Exception as e:
        print "Unexpected error: %s" %e

    else:
        print "Query success"
Abhijeet Kasurde
  • 3,937
  • 1
  • 24
  • 33

1 Answers1

-1

You can find an example here.

The short version:

A ManagedObjectReference to a HostDatastoreSystem needs to be supplied when you use vim.host.DatastoreSystem.QueryVmfsDatastoreCreateOptions() to create a datastore.

Henry An
  • 31
  • 4
  • does any one have working example code for creating vmfs datastores using pyvmomy? – Tez Aug 08 '21 at 02:18