I am using python 3.7 and pyvmomi 6.7 I am connecting to exsi host (version 6.7 free license) and trying to deploy a vm with my python script. In one of the step I'm trying to create a directory (to store iso and vmdk) in the datastore. This is the code snippet to create a directory,
fmgr = host['content'].fileManager
dco = vm['storage']['root']['dc']
dirname = '[' + dso.info.name + '] ' + vm['name']
logger.info('Creating Directory {} on {}'.format(
dirname, dso.info.name))
try:
fmgr.MakeDirectory(name=dirname, datacenter=dco,
createParentDirectories=False)
except vim.fault.FileAlreadyExists as e:
logger.info('Directory {} already exists on {} - {}'.format(
dirname, dso.info.name, str(e)))
return True
except vim.fault.InvalidDatastore as e:
logger.error('Invalid datastore: {} - {}'.format(
dso.info.name, str(e)))
return False
except vim.fault.RuntimeFault as e:
logger.error('Runtime error while creating directory {} on {} - {}'.format(
dirname, dso.info.name, str(e)))
return False
except Exception as e:
logger.error('Failed to create top directory {}. - {}'.format(
dirname, str(e)))
I am getting this error while it is trying to create the directory,
pyVmomi.VmomiSupport.RestrictedVersion: (vim.fault.RestrictedVersion) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
msg = 'Current license or ESXi version prohibits execution of the requested operation.',
faultCause = <unset>,
faultMessage = (vmodl.LocalizableMessage) []
}
The same code is able to create directory for exsi version 6.5 (free license) According to compatibility policy section from https://github.com/vmware/pyvmomi, exsi 6.7 should be supported.
Are there any functionality restrictions on versions?
Do we have any other way of creating top level directory in the datastore?
Are there any other python library for managing VMs in VMware (which supports from exsi 6.0)?
The key thing is the type of license the ESXi host has. If it has a free license then the API will allow read-only operations and all the other operations will be blocked with 'Current license or ESXi version prohibits execution of the requested operation' message. Quoting from one of the vmware blogs,
Access to the vSphere API is governed by the variousvSphere Editions which provides both read and write access to the API. If you are using vSphere Hypervisor (free edition of ESXi), the vSphere API will only be available as read-only.
I have tried my same code on another licensed version of ESXi and guess what, the code executed successfully and created VMs. Found one of the answer in ServerFault stating the same.
The problem was the original documents for SDK, Python API or the community samples doesn't say anything on this limitation.