[英]VMWare pyvmomi 6.0.0 : Operation not supported
I am using VMWare's pyvmomi to manage my ESXI's virtual machines我正在使用 VMWare 的 pyvmomi 来管理我的 ESXI 虚拟机
I'm using :我正在使用 :
pyvmomi-6.0.0 with python 2.7.5 to clone a VM on pyvmomi-6.0.0和python 2.7.5来克隆一个虚拟机
VMWare ESXi 6.0.0 Update 1 which is managed by VMWare ESXi 6.0.0 Update 1由
vCenter Server 6中心服务器 6
Using pyvmomi, i can successfully retrieve vm objects, iterate through datacenters, datastores, vm etc... But i can't clone them.使用 pyvmomi,我可以成功检索 vm 对象,遍历数据中心、数据存储、vm 等……但我无法克隆它们。
I am connecting to my ESXi as root我以 root 身份连接到我的 ESXi
I'm always getting the following error : (I've tried cloning vms and creating folders on ESXI)我总是收到以下错误:(我尝试在 ESXI 上克隆虚拟机并创建文件夹)
./test.py
Source VM : TEST_A
Pool cible : Pool_2
Traceback (most recent call last):
File "./vmomiTest.py", line 111, in <module>
sys.exit(main())
File "./vmomiTest.py", line 106, in main
tasks.wait_for_tasks(esxi, [task])
File "/home/user/dev/tools/tasks.py", line 53, in wait_for_tasks
raise task.info.error
pyVmomi.VmomiSupport.NotSupported: (vmodl.fault.NotSupported) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
msg = 'The operation is not supported on the object.',
faultCause = <unset>,
faultMessage = (vmodl.LocalizableMessage) []
}
When I read by /var/log/hostd.log file on esxi, i get the following :当我通过 esxi 上的 /var/log/hostd.log 文件读取时,我得到以下信息:
2016-09-13T10:15:17.775Z info hostd[51F85B70] [Originator@6876 sub=Vimsvc.TaskManager opID=467be296 user=root] Task Created : haTask-2-vim.VirtualMachine.clone-416315
2016-09-13T10:15:17.775Z info hostd[51F85B70] [Originator@6876 sub=Vimsvc.TaskManager opID=467be296 user=root] 任务创建:haTask-2-vim.VirtualMachine.clone-416315
2016-09-13T10:15:17.779Z info hostd[51F03B70] [Originator@6876 sub=Default opID=467be296 user=root] AdapterServer caught exception: vmodl.fault.NotSupported
2016-09-13T10:15:17.779Z info hostd[51F03B70] [Originator@6876 sub=Default opID=467be296 user=root] AdapterServer 捕获异常:vmodl.fault.NotSupported
2016-09-13T10:15:17.779Z info hostd[51F03B70] [Originator@6876 sub=Vimsvc.TaskManager opID=467be296 user=root] Task Completed : haTask-2-vim.VirtualMachine.clone-416315 Status error
2016-09-13T10:15:17.779Z info hostd[51F03B70] [Originator@6876 sub=Vimsvc.TaskManager opID=467be296 user=root] 任务完成:haTask-2-vim.VirtualMachine.clone-416315 状态错误
Is there any other pre-requisites that i don't match ?是否还有其他我不匹配的先决条件? Has anyone any clue ?
有没有人有任何线索?
Using the following test.py example code :使用以下 test.py 示例代码:
def get_obj_case_insensitive(content, vimtype, name, folder=None):
obj = None
if not folder:
folder = content.rootFolder
container = content.viewManager.CreateContainerView(folder, vimtype, True)
for item in container.view:
if item.name.lower() == name.lower():
obj = item
break
return obj
def get_obj(content, vimtype, name, folder=None):
obj = None
if not folder:
folder = content.rootFolder
container = content.viewManager.CreateContainerView(folder, vimtype, True)
for item in container.view:
if item.name == name:
obj = item
break
return obj
def main():
esxi = connect.SmartConnect(user=esxi_user,
pwd=esxi_password,
host=esxi_addr,
port=443)
atexit.register(connect.Disconnect, esxi)
content = esxi.RetrieveContent()
source_vm = get_obj(content, [vim.VirtualMachine], source_vm_name)
if source_vm == None:
print "Source VM %s doesn't exist, couldn't create VM" % source_vm_name
return None
print "Source VM Found : %s" % source_vm.config.name
wanted_pool = get_obj_case_insensitive(content, [vim.ResourcePool], wanted_pool_name)
if wanted_pool == None:
print "Resource Pool couldn't be found: Pool=%s" % wanted_pool_name
return None
else:
print "Pool Found : %s " % wanted_pool.name
new_location = vim.vm.RelocateSpec()
new_location.diskMoveType = 'createNewChildDiskBacking'
new_location.datastore = content.rootFolder.childEntity[0].datastore[0]
new_location.pool = wanted_pool
ESXI.ensure_snapshot_exists(source_vm)
clone_spec = vim.vm.CloneSpec(template=False, location=new_location, snapshot=source_vm.snapshot.rootSnapshotList[0].snapshot)
task = source_vm.Clone(name=dest_vm_name, folder=source_vm.parent, spec=clone_spec)
tasks.wait_for_tasks(esxi, [task])
print "Cloning %s into %s was successfull" % (source_vm.config.name, dest_vm_name)
if __name__ == '__main__':
sys.exit(main())
It appears this is because VMWARE has disabled many operations when directly connected to the ESXi.看来这是因为 VMWARE 在直接连接到 ESXi 时禁用了许多操作。
Apparently, i should have connected to my vCenterServer in order to properly clone my VM.显然,我应该连接到我的 vCenterServer 以便正确克隆我的虚拟机。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.