]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Executing 'cobbler sync' after adding a new system
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 11 Jun 2020 13:27:50 +0000 (15:27 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 11 Jun 2020 13:27:50 +0000 (15:27 +0200)
lib/cr_vmware_tpl/cobbler.py

index 3e749b513e81da107fc5017b57f65700403db295..880c088d96eaacbfc2fa010d5de9336a0ec732c5 100644 (file)
@@ -37,7 +37,7 @@ from .config import CrTplConfiguration
 
 from .xlate import XLATOR
 
-__version__ = '0.4.8'
+__version__ = '0.4.9'
 
 LOG = logging.getLogger(__name__)
 
@@ -677,11 +677,6 @@ class Cobbler(BaseHandler):
         args.append('--management')
         args.append('true')
 
-        cmd_str = 'cobbler ' + ' '.join(map(lambda x: pipes.quote(x), args))
-        LOG.debug("Should execute: {}".format(cmd_str))
-        if self.verbose > 1:
-            LOG.debug(_("Cobbler arguments for creating a new system:") + "\n" + pp(args))
-
         proc = self.exec_cobbler(args)
 
         if proc.returncode:
@@ -694,6 +689,31 @@ class Cobbler(BaseHandler):
                 rc=proc.returncode, err=err)
             raise ExpectedCobblerError(msg)
 
+        self.sync()
+
+    # -------------------------------------------------------------------------
+    def sync(self):
+        """Executing 'cobbler sync' to apply environment, especially DHCPD configuration."""
+
+        proc = self.exec_cobbler('sync')
+
+        if proc.returncode != 0:
+            err = _('No error message')
+            if proc.stderr:
+                err = proc.stderr
+            elif proc.stdout:
+                err = proc.stdout
+            msg = _("Could syncing cobbler: {}").format(err)
+            raise ExpectedCobblerError(msg)
+
+        if self.verbose > 1:
+            if proc.stdout:
+                LOG.debug(_("Output on {}:").format('STDOUT') + '\n' + proc.stdout)
+        if self.verbose:
+            if proc.stderr:
+                LOG.debug(_("Output on {}:").format('STDERR') + '\n' + proc.stderr)
+
+
 # =============================================================================
 if __name__ == "__main__":