import atexit
from pyVim.connect import SmartConnectNoSSL, Disconnect
from pyVmomi import vim, vmodl
import time
import datetime
class VMware_operation():
def __init__(self):
self.host = 'vcenter.test.com'
self.user = 'example@domain.local'
self.password = 'password'
self.port = 443
self.server = None
def conn(self):
server = SmartConnectNoSSL(host=self.host, user=self.user, pwd=self.password, port=self.port)
self.server = server
atexit.register(Disconnect, self.server)
@property
def get_vmlist(self):
vmlist = []
content = self.server.RetrieveContent()
for child in content.rootFolder.childEntity:
if hasattr(child, 'vmFolder'):
datacenter = child
vmFolder = datacenter.vmFolder
vcenter自动清理快照
最新推荐文章于 2022-12-07 16:40:48 发布