From a24fbd10e7cf41175cc38abb81b9f5c8eb077ca7 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Sat, 18 Jun 2022 17:37:27 +0200 Subject: [PATCH] Making path to cobbler executable configurable --- etc/create-vmware-template.ini.default | 4 +++- lib/cr_vmware_tpl/cobbler.py | 6 ++++-- lib/cr_vmware_tpl/config.py | 12 +++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/etc/create-vmware-template.ini.default b/etc/create-vmware-template.ini.default index a5e3e7d..7d1df36 100644 --- a/etc/create-vmware-template.ini.default +++ b/etc/create-vmware-template.ini.default @@ -68,9 +68,11 @@ # host = cobbler.pixelpark.com +# bin = /bin/cobbler + # ssh_port = 22 -# ssh_user = root +# ssh_user = cobbler # ssh_timeout = 30 diff --git a/lib/cr_vmware_tpl/cobbler.py b/lib/cr_vmware_tpl/cobbler.py index a3b8601..8ed38c9 100644 --- a/lib/cr_vmware_tpl/cobbler.py +++ b/lib/cr_vmware_tpl/cobbler.py @@ -42,7 +42,7 @@ from .config import CrTplConfiguration from .xlate import XLATOR -__version__ = '0.6.8' +__version__ = '0.7.0' LOG = logging.getLogger(__name__) @@ -79,6 +79,7 @@ class Cobbler(BaseHandler): raise HandlerError(msg) self.host = CrTplConfiguration.default_cobbler_host + self.cobbler_bin = CrTplConfiguration.default_cobbler_bin self.ssh_port = CrTplConfiguration.default_cobbler_ssh_port self.ssh_user = CrTplConfiguration.default_cobbler_ssh_user self.private_ssh_key = None @@ -95,6 +96,7 @@ class Cobbler(BaseHandler): self.private_ssh_key = str(self.base_dir.joinpath('keys', CrTplConfiguration.ssh_privkey)) + self.cobbler_bin = config.cobbler_bin self.private_ssh_key = config.private_ssh_key self.host = config.cobbler_host self.ssh_port = config.cobbler_ssh_port @@ -117,7 +119,7 @@ class Cobbler(BaseHandler): cmds.append('echo') if self.ssh_user != 'root': cmds.append('sudo') - cmds.append('cobbler') + cmds.append(self.cobbler_bin) if cmd is not None: if is_sequence(cmd): cmds += cmd diff --git a/lib/cr_vmware_tpl/config.py b/lib/cr_vmware_tpl/config.py index 1df33fc..260157b 100644 --- a/lib/cr_vmware_tpl/config.py +++ b/lib/cr_vmware_tpl/config.py @@ -24,7 +24,7 @@ from fb_vmware.config import VSPhereConfigInfo from .xlate import XLATOR -__version__ = '1.7.0' +__version__ = '1.7.1' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -75,6 +75,7 @@ class CrTplConfiguration(BaseConfiguration): default_tpl_vm_domain = 'pixelpark.com' + default_cobbler_bin = '/bin/cobbler' default_cobbler_host = 'cobbler.pixelpark.com' default_cobbler_ssh_port = 22 default_cobbler_ssh_user = 'root' @@ -149,6 +150,7 @@ class CrTplConfiguration(BaseConfiguration): self.private_ssh_key = None + self.cobbler_bin = self.default_cobbler_bin self.cobbler_distro = self.default_cobbler_distro self.cobbler_host = self.default_cobbler_host self.cobbler_ssh_port = self.default_cobbler_ssh_port @@ -533,7 +535,8 @@ class CrTplConfiguration(BaseConfiguration): r'^\s*(?:ws|webserver)[-_]?docroot\s*$', re.IGNORECASE) re_ws_rel_filesdir_key = re.compile( r'^\s*(?:ws|webserver)[-_]?rel(?:ative)?[-_]?filesdir\s*$', re.IGNORECASE) - rs_system_status = re.compile(r'^\s*system[-_]?status\s*$', re.IGNORECASE) + re_system_status = re.compile(r'^\s*system[-_]?status\s*$', re.IGNORECASE) + re_cobbler_bin_key = re.compile(r'^\s*(?:cobbler[_-]?)?bin\s*$', re.IGNORECASE) for (key, value) in config.items(section_name): if key.lower() == 'distro' and value.strip() != '': @@ -551,6 +554,9 @@ class CrTplConfiguration(BaseConfiguration): if re_timeout_key.match(key): self.cobbler_ssh_timeout = int(value) continue + if re_cobbler_bin_key.match(key) and value.strip() != '': + self.cobbler_bin = value.strip() + continue if re_rootdir_key.match(key): dpath = Path(value) if dpath.is_absolute(): @@ -588,7 +594,7 @@ class CrTplConfiguration(BaseConfiguration): if re_ws_rel_filesdir_key.match(key) and value.strip() != '': self.cobbler_ws_rel_filesdir = Path(value.strip()) continue - if rs_system_status.match(key) and value.strip() != '': + if re_system_status.match(key) and value.strip() != '': val = value.strip().lower() if val in self.valid_system_status: self.system_status = val -- 2.39.5