From cf2f50626f1fb9cc60d9dbdc3b7931d4c6e423b2 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 27 May 2020 16:38:57 +0200 Subject: [PATCH] Bugfixing --- lib/cr_vmware_tpl/cobbler.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/cr_vmware_tpl/cobbler.py b/lib/cr_vmware_tpl/cobbler.py index f32d7b0..0af1df2 100644 --- a/lib/cr_vmware_tpl/cobbler.py +++ b/lib/cr_vmware_tpl/cobbler.py @@ -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): -- 2.39.5