From 42a7e6e6ea401dec7b0b19eb58b13e38bdbc0646 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 28 May 2020 12:23:43 +0200 Subject: [PATCH] Splitting exec_cobble into two different methods --- lib/cr_vmware_tpl/cobbler.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/cr_vmware_tpl/cobbler.py b/lib/cr_vmware_tpl/cobbler.py index c554103..ea1984d 100644 --- a/lib/cr_vmware_tpl/cobbler.py +++ b/lib/cr_vmware_tpl/cobbler.py @@ -32,7 +32,7 @@ from .config import CrTplConfiguration from .xlate import XLATOR -__version__ = '0.3.1' +__version__ = '0.3.2' LOG = logging.getLogger(__name__) @@ -114,6 +114,12 @@ class Cobbler(BaseHandler): raise TypeError(msg) cmds.append(c) + cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmds)) + return self.exec_ssh(cmd_str) + + # ------------------------------------------------------------------------- + def exec_ssh(self, cmd): + ssh = None proc = None @@ -138,11 +144,10 @@ class Cobbler(BaseHandler): self.host, port=self.ssh_port, timeout=self.ssh_timeout, username=self.ssh_user, key_filename=self.private_ssh_key) - cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmds)) if self.verbose > 1: - LOG.debug(_("Executing: {}").format(cmd_str)) + LOG.debug(_("Executing: {!r}").format(cmd)) - stdin, stdout, stderr = ssh.exec_command(cmd_str, timeout=self.ssh_timeout) + stdin, stdout, stderr = ssh.exec_command(cmd, timeout=self.ssh_timeout) end_dt = datetime.datetime.now() retcode = stdout.channel.recv_exit_status() -- 2.39.5