From 86a937cea6cd216120186d1cbe2a43be1ef75194 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 24 Oct 2018 11:34:52 +0200 Subject: [PATCH] First actions with VSphere --- bin/create-vmware-template | 2 +- lib/cr_vmware_tpl/app.py | 12 ++++++------ lib/cr_vmware_tpl/handler.py | 18 +++++++++++++++++- python_fb_tools | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/bin/create-vmware-template b/bin/create-vmware-template index 38e7507..63745de 100755 --- a/bin/create-vmware-template +++ b/bin/create-vmware-template @@ -52,7 +52,7 @@ app.initialized = True if app.verbose > 2: print("{c}-Object:\n{a}".format(c=app.__class__.__name__, a=app)) -# app() +app() sys.exit(0) diff --git a/lib/cr_vmware_tpl/app.py b/lib/cr_vmware_tpl/app.py index e40a050..9171d18 100644 --- a/lib/cr_vmware_tpl/app.py +++ b/lib/cr_vmware_tpl/app.py @@ -391,12 +391,12 @@ class CrTplApplication(BaseApplication): LOG.info("Starting {a!r}, version {v!r} ...".format( a=self.appname, v=self.version)) -# try: -# ret = self.handler() -# self.exit(ret) -# except ExpectedHandlerError as e: -# self.handle_error(str(e), "Temporary VM") -# self.exit(5) + try: + ret = self.handler() + self.exit(ret) + except ExpectedHandlerError as e: + self.handle_error(str(e), "Temporary VM") + self.exit(5) # ============================================================================= diff --git a/lib/cr_vmware_tpl/handler.py b/lib/cr_vmware_tpl/handler.py index 266fbda..1af3631 100644 --- a/lib/cr_vmware_tpl/handler.py +++ b/lib/cr_vmware_tpl/handler.py @@ -131,8 +131,24 @@ class CrTplHandler(BaseHandler): "self.config is not a CrTplConfiguration-instance, but a " "{}-instance instead.").format(self.config.__class__.__name__)) + retval = 0 + try: + retval = self.run() + finally: + LOG.debug("Closing ...") + self.vsphere.disconnect() + self.vsphere = None - return + return retval + + # ------------------------------------------------------------------------- + def run(self): + + LOG.debug("Starting handling ...") + + self.vsphere.get_about() + + return 0 LOG.debug("Connecting to vSphere host {h}:{p} as {u!r} ...".format( diff --git a/python_fb_tools b/python_fb_tools index d542794..ff5009c 160000 --- a/python_fb_tools +++ b/python_fb_tools @@ -1 +1 @@ -Subproject commit d542794caaf1b5336ad451901cbb0b9e6d58b6b2 +Subproject commit ff5009c6121ba6918b3f57f235bbd41091e6710d -- 2.39.5