]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Making path to cobbler executable configurable
authorFrank Brehm <frank@brehm-online.com>
Sat, 18 Jun 2022 15:37:27 +0000 (17:37 +0200)
committerFrank Brehm <frank@brehm-online.com>
Sat, 18 Jun 2022 15:37:27 +0000 (17:37 +0200)
etc/create-vmware-template.ini.default
lib/cr_vmware_tpl/cobbler.py
lib/cr_vmware_tpl/config.py

index a5e3e7dd170c5b73a10abdc031ae0ead44ba4ed5..7d1df367666eed0034ef7addf5e019fa82aa4deb 100644 (file)
 
 # host = cobbler.pixelpark.com
 
+# bin = /bin/cobbler
+
 # ssh_port = 22
 
-# ssh_user = root
+# ssh_user = cobbler
 
 # ssh_timeout = 30
 
index a3b86017c513aa3ceee92c2dc812201cc601f476..8ed38c95a5c5ef1d3bcf49f98fd6c8e1e9a239e9 100644 (file)
@@ -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
index 1df33fc35be991cd2b3cba505353213695ea3598..260157bc0d85b75b050576e892211d747936b350 100644 (file)
@@ -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