vmware/pyvmomi-community-samples

change_disk_mode.py: pyVmomi.VmomiSupport.NoPermission

开放

#619 创建于 2019年12月3日

 (0 条评论) (0 个反应) (0 位负责人)Python (914 个派生)batch import
help wanted

仓库指标

星标
 (972 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Hi, and first of all thank you guys for this nice samples 👍 they already helped me a lot! But now I'm stuck. I try to change a VMs disk mode with your example change_disk_mode.py.

I run it like this from the command-line:

python change_disk_mode.py -s myhost -u "EUR\myuser" -p mypassword -v myvm -d 1 -m independent_persistent

I instantly get the following traceback:

File "change_disk_mode.py", line 108, in <module>
    main()
  File "change_disk_mode.py", line 101, in main
    change_disk_mode(si, vm_obj, args.disk_number, args.mode)
  File "change_disk_mode.py", line 54, in change_disk_mode
    task = vm_obj.ReconfigVM_Task(spec=spec)
  File "/vSphere-env/lib64/python3.6/site-packages/pyVmomi/VmomiSupport.py", line 706, in <lambda>
    self.f(*(self.args + (obj,) + args), **kwargs)
  File "/vSphere-env/lib64/python3.6/site-packages/pyVmomi/VmomiSupport.py", line 512, in _InvokeMethod
    return self._stub.InvokeMethod(self, info, args)
  File "/vSphere-env/lib64/python3.6/site-packages/pyVmomi/SoapAdapter.py", line 1397, in InvokeMethod
    raise obj # pylint: disable-msg=E0702
pyVmomi.VmomiSupport.NoPermission: (vim.fault.NoPermission) {
   dynamicType = <unset>,
   dynamicProperty = (vmodl.DynamicProperty) [],
   msg = 'Permission to perform this operation was denied.',
   faultCause = <unset>,
   faultMessage = (vmodl.LocalizableMessage) [],
   object = 'vim.Datastore:datastore-24829',
   privilegeId = 'System.Read'

}

So it looks like it is a permission problem. Because of this it try to set the disk mode with this user via [VmWare vSphere Client > VM > Virtual Machine Properties] . Here it is possible to set the disk mode.

Can somebody help me to archive changing the disk mode with this user?

Best regards and thank you guys!

贡献者指南