2

I'm trying to run some sample scripts from the Pyvmomi Community Samples on a vcenter server appliance: https://github.com/vmware/pyvmomi-community-samples

Caught vmodl fault : Permission to perform this operation was denied.

With another simple script:

from pyVim.connect import SmartConnect, Disconnect
import ssl

s = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
s.verify_mode = ssl.CERT_NONE

c = SmartConnect(host="IP", user="USER", pwd='PWD', sslContext=s)

datacenter = c.content.rootFolder.childEntity[0]
vms = datacenter.vmFolder.childEntity

for i in vms:
    print(i.name)

Disconnect(c)

If I use my domain user account, with which I can login to the vcenter:

Cannot complete login due to an incorrect user name or password.

I used DOMAIN\USERNAME as user.

or as root:

Permission to perform this operation was denied.

I added some permissions in vcenter server, but apparently it is not enough :(.

jackson
  • 386
  • 1
  • 4
  • 21

1 Answers1

1

I was also facing the same issue, I added port it worked. Need to add port as the parameter, Change this

SmartConnect(host="IP", user="USER", pwd='PWD', sslContext=s)

to

import ssl
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_NONE
SmartConnect(host="IP", user="USER", pwd='PWD', port=443, sslContext=context)
Surajano
  • 2,688
  • 13
  • 25
  • This doesn't help me. Here's [my](https://stackoverflow.com/questions/75506100/unable-to-query-vms-on-vcenter-server-appliance-using-pyvmomi) question. Could you please take a look at it and see if I am missing something obvious? – AjB Feb 20 '23 at 07:06