From: Frank Brehm Date: Thu, 28 May 2020 10:23:43 +0000 (+0200) Subject: Splitting exec_cobble into two different methods X-Git-Tag: 2.1.2^2~9^2~31^2~100 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=42a7e6e6ea401dec7b0b19eb58b13e38bdbc0646;p=pixelpark%2Fcreate-vmware-tpl.git Splitting exec_cobble into two different methods --- 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()