jackson
jackson

Reputation: 486

Pyvmomi: Permission denied on vcenter

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 :(.

Upvotes: 2

Views: 1962

Answers (1)

Surajano
Surajano

Reputation: 2688

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)

Upvotes: 1

Related Questions