]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Bugfixing
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 27 May 2020 14:38:57 +0000 (16:38 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 27 May 2020 14:38:57 +0000 (16:38 +0200)
lib/cr_vmware_tpl/cobbler.py

index f32d7b02f6d7e93ca1f21ec2495a141f26bd4940..0af1df2c8dc790cb30090776fbcedda95b598fec 100644 (file)
@@ -31,7 +31,7 @@ from .config import CrTplConfiguration
 
 from .xlate import XLATOR
 
-__version__ = '0.2.1'
+__version__ = '0.2.2'
 
 LOG = logging.getLogger(__name__)
 
@@ -107,6 +107,7 @@ class Cobbler(BaseHandler):
                 cmds.append(c)
 
         ssh = None
+        proc = None
 
         try:
 
@@ -142,9 +143,15 @@ class Cobbler(BaseHandler):
 
             proc = CompletedProcess(cmds, retcode, output, err, start_dt=start_dt, end_dt=end_dt)
 
-            if self.verbose > 2:
-                LOG.debug(_("Completed SSH process:") + "\n{}".format(proc))
-            return proc
+        finally:
+            if ssh:
+                if self.verbose > 2:
+                    LOG.debug(_("Closing SSH connection."))
+                ssh.close()
+
+        if self.verbose > 2:
+            LOG.debug(_("Completed SSH process:") + "\n{}".format(proc))
+        return proc
 
     # -------------------------------------------------------------------------
     def get_cobbler_version(self):