June 2018
Intermediate to advanced
398 pages
9h
English
This time we will use the pyvmomi bindings to change the virtual machine state. This will be done by checking the virtual machine name as we did before; then, we will navigate to another tree in MoB and get the runtime status. Finally, we will apply either the PowerOn() or PowerOff() function on the machine depending on its current status. This will switch the machine state from On to Off and vice versa.
The script is as follows:
#!/usr/bin/python__author__ = "Bassim Aly"__EMAIL__ = "basim.alyy@gmail.com"from pyVim.connect import SmartConnect, Disconnect,SmartConnectNoSSLESXi_connection = SmartConnectNoSSL(host="10.10.10.115", user="root", pwd='access123')datacenter = ESXi_connection.content.rootFolder
Read now
Unlock full access