From f7add0bcc8b5b3cbc876fad1d6b0f962c6aab151 Mon Sep 17 00:00:00 2001 From: Rottler Tamas Date: Sun, 17 Mar 2024 14:13:10 +0100 Subject: [PATCH] new: vmw_list_tasks --- vmw_list_tasks | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 vmw_list_tasks diff --git a/vmw_list_tasks b/vmw_list_tasks new file mode 100755 index 0000000..49c25b3 --- /dev/null +++ b/vmw_list_tasks @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +from pyVmomi import vim +import pyVim.connect +import atexit +import argparse +import time +import siteconf + +site_conf = siteconf.read() + + +def get_args(): + parser = argparse.ArgumentParser( + description='Set VM network') + + parser.add_argument('-s', '--site', + required=True, + action='store', + help='name of the site to connect to') + + args = parser.parse_args() + return args + +def main(): + args = get_args() + + if not args.site in site_conf: + print(f"site not found: {args.site}") + exit(1) + host = site_conf[args.site]['vcenter'] + user = site_conf[args.site]['vcenter_user'] + passwd = site_conf[args.site]['vcenter_passwd'] + + si = pyVim.connect.SmartConnectNoSSL( + host = host, + user = user, + pwd = passwd + ) + atexit.register(pyVim.connect.Disconnect, si) + content = si.RetrieveContent() + + for task in content.taskManager.recentTask: + i = task.info + print(f"{i.startTime.astimezone().strftime('%F %T')} {i.progress}% {i.state} {i.descriptionId} {i.entityName}") + + + +if __name__ == "__main__": + main() + +# vim: set tabstop=4 shiftwidth=4 expandtab smarttab: