vmware/pyvmomi-community-samples

change_disk_mode.py: pyVmomi.VmomiSupport.NoPermission

Offen

#619 geöffnet am 03.12.2019

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Python (914 Forks)batch import
help wanted

Repository-Metriken

Stars
 (972 Sterne)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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!

Contributor Guide