vmware/pyvmomi-community-samples

Not able to reboot VM

Ouverte

#464 ouverte le 14 févr. 2018

 (3 commentaires) (0 réaction) (0 personne assignée)Python (914 forks)batch import
help wanted

Métriques du dépôt

Stars
 (972 étoiles)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

Hi All,

I am beginner and recently started using pyvmomi module.

I tried to follow scripts available in sample folder and wrote simple script which will reboot the Virtual Machine. The code is mentioned below:-

import atexit

from pyVim import connect

si = connect.SmartConnect( host="ESX-HOSTNAME", user="USERNAME", pwd="PASSWORD", port=443)

atexit.register(connect.Disconnect, si) content = si.RetrieveContent() vm = si.content.searchIndex.FindByDnsName(None, "VM-NAME",True) if vm is None: print "Unable to locate VirtualMachine." else: print "VM Name : {}".format(vm.name) print "VM instanceUuid : {}".format(vm.config.instanceUuid) print "VM ipAddress : {}".format(vm.guest.ipAddress) print "VM hostName : {}".format(vm.guest.hostName) print "VM powerState : {}".format(vm.runtime.powerState) vm.RebootGuest()

But when tried to execute it, I am getting following error at list line of above script

Traceback (most recent call last): File "powercyle-vm.py", line 24, in vm.RebootGuest() File "/apps/python/2.7.3/lib/python2.7/site-packages/pyvmomi-6.5.0.2017.5_1-py2.7.egg/pyVmomi/VmomiSupport.py", line 580, in self.f(*(self.args + (obj,) + args), **kwargs) File "/apps/python/2.7.3/lib/python2.7/site-packages/pyvmomi-6.5.0.2017.5_1-py2.7.egg/pyVmomi/VmomiSupport.py", line 386, in _InvokeMethod return self._stub.InvokeMethod(self, info, args) File "/apps/python/2.7.3/lib/python2.7/site-packages/pyvmomi-6.5.0.2017.5_1-py2.7.egg/pyVmomi/SoapAdapter.py", line 1366, in InvokeMethod raise obj # pylint: disable-msg=E0702 pyVmomi.VmomiSupport.HostNotConnected: (vmodl.fault.HostNotConnected) { dynamicType = , dynamicProperty = (vmodl.DynamicProperty) [], msg = 'Unable to communicate with the remote host, since it is disconnected.', faultCause = , faultMessage = (vmodl.LocalizableMessage) [] }

Please let me know any suggestion/help to resolve this issue.

Guide contributeur