]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Splitting exec_cobble into two different methods
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 28 May 2020 10:23:43 +0000 (12:23 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 28 May 2020 10:23:43 +0000 (12:23 +0200)
lib/cr_vmware_tpl/cobbler.py

index c5541033eb19196ee02468f8fe6cc6540463424b..ea1984d40b6ccfa8ddeb35f42c0777bdddba463f 100644 (file)
@@ -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()