From: Frank Brehm Date: Thu, 11 Jun 2020 13:27:50 +0000 (+0200) Subject: Executing 'cobbler sync' after adding a new system X-Git-Tag: 2.1.2^2~9^2~31^2~57 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=922eed1516c9f3504b86320625ecad158041b439;p=pixelpark%2Fcreate-vmware-tpl.git Executing 'cobbler sync' after adding a new system --- diff --git a/lib/cr_vmware_tpl/cobbler.py b/lib/cr_vmware_tpl/cobbler.py index 3e749b5..880c088 100644 --- a/lib/cr_vmware_tpl/cobbler.py +++ b/lib/cr_vmware_tpl/cobbler.py @@ -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__":