0

I am creating a script that asks the user for the FQDN of a host, then the script sets that host to maintenance mode. I am running the script on the Windows Management Computer that is obviously connected to the esxi-vcsa that has these hosts on it. 11.11.11.5 is the IP of the vcsa.

from pyvim import connect
from pyVmomi import vim

fqdnInput = input("Enter FQDN of host: ")


host = connect.ConnectNoSSL("11.11.11.5", 443, root, lassword)
searcher = host.content.searchIndex
host = searcher.FindByDnsName(dnsName=fqdnInput, vmSearch=False)
host.EnterMaintenanceMode(0)

When I run that script, I am getting the following error after I input the FQDN name. (I tried both just the host name and host.domain full name).

Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\task4.py", line 14, in <module>
    host = connect.ConnectNoSSL("11.11.11.5", 443, "root", "Pa$$w0rd")
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\pyvim\connect.py", line 308, in ConnectNoSSL
    mechanism=mechanism)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\pyvim\connect.py", line 266, in Connect
    keyFile, certFile, thumbprint, sslContext, connectionPoolTimeout)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\pyvim\connect.py", line 390, in __Login
    x = content.sessionManager.Login(user, pwd, None)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\pyVmomi\VmomiSupport.py", line 706, in <lambda>
    self.f(*(self.args + (obj,) + args), **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\pyVmomi\VmomiSupport.py", line 512, in _InvokeMethod
    return self._stub.InvokeMethod(self, info, args)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\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.Folder:group-d1',
   privilegeId = 'System.View'
}

Help would be appreciated.

vmVisor
  • 1
  • 2

1 Answers1

0

It looks like you're dealing with a permissions issue and not a Python issue. I'm going to guess that the searcher is failing, meaning that the account you're using does not have access to the vCenter inventory at all.

Have you tried switching to a different account? Perhaps the "Administrator@vsphere.local" account?

Kyle Ruddy
  • 1,886
  • 1
  • 7
  • 5