Creating datastore using pyvmomi on ESX

时间:2016-07-11 19:27:22

标签: python esx pyvmomi

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"

1 个答案:

答案 0 :(得分:-1)

您可以找到示例here

简短版本:

使用ManagedObjectReference创建数据存储区时,需要提供HostDatastoreSystemvim.host.DatastoreSystem.QueryVmfsDatastoreCreateOptions()