]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Implementing syncing of snippets
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 11 Jun 2020 09:22:46 +0000 (11:22 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 11 Jun 2020 09:22:46 +0000 (11:22 +0200)
lib/cr_vmware_tpl/cobbler.py
lib/cr_vmware_tpl/config.py
lib/cr_vmware_tpl/handler.py

index 34d077fd1c56c161a81bd3df3a5d30f8304f01dc..7d0d1d653be13d3f9615eeb5ee4e85d9d5576f91 100644 (file)
@@ -37,7 +37,7 @@ from .config import CrTplConfiguration
 
 from .xlate import XLATOR
 
-__version__ = '0.4.5'
+__version__ = '0.4.6'
 
 LOG = logging.getLogger(__name__)
 
@@ -612,6 +612,11 @@ class Cobbler(BaseHandler):
     def ensure_snippets(self):
 
         local_snippets_dir = self.base_dir / 'snippets'
+        self.ensure_remote_directory(self.config.snippets_dir)
+
+        for local_snippet in local_snippets_dir.glob('*'):
+            remote_snippet = self.config.snippets_dir / local_snippet.name
+            self.ensure_remote_file(local_snippet, remote_snippet, check_parent=False)
 
     # -------------------------------------------------------------------------
     def add_system(self, name, fqdn, mac_address, comment=None):
@@ -629,6 +634,7 @@ class Cobbler(BaseHandler):
         ks_meta_list = []
         ks_meta_list.append("ROOT_PWD_HASH={}".format(self.config.get_root_pwd_hash()))
         ks_meta_list.append("SWAP_SIZE_MB={}".format(self.config.swap_size_mb))
+        ks_meta_list.append("SYSTEM_STATUS={}".format(status))
 
         ks_meta = None
         if ks_meta_list:
@@ -650,6 +656,8 @@ class Cobbler(BaseHandler):
             args.append('--ksmeta')
             args.append(ks_meta)
 
+        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))
 
index 58ed6fc898eba9f1fc3b79ab078c657a7edde9cd..683ae29aff899b376daea775f7fbdaf59aefc397 100644 (file)
@@ -22,7 +22,7 @@ from fb_tools.config import ConfigError, BaseConfiguration
 
 from .xlate import XLATOR
 
-__version__ = '1.5.5'
+__version__ = '1.5.6'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -219,6 +219,12 @@ class CrTplConfiguration(BaseConfiguration):
         ks_base = 'template-' + self.os_id + '-' + self.system_status + '.ks'
         return self.cobbler_ks_dir / ks_base
 
+    # -------------------------------------------------------------------------
+    @property
+    def snippets_dir(self):
+        """The path to the snippets dirctory, depending of the system status."""
+        return self.cobbler_rootdir / 'snippets' / 'per_status' / self.system_status
+
     # -------------------------------------------------------------------------
     def as_dict(self, short=True):
         """
@@ -237,6 +243,7 @@ class CrTplConfiguration(BaseConfiguration):
         res['data_size'] = self.data_size
         res['ram_gb'] = self.ram_gb
         res['system_ks'] = self.system_ks
+        res['snippets_dir'] = self.snippets_dir
 
         res['root_password'] = None
         if self.root_password:
index ea03527c19cc069bfe7c6b5bd177b52c524d155c..f44d629eeb53df2b28ce3cc0257dda3941e95abb 100644 (file)
@@ -42,7 +42,7 @@ from .cobbler import CobblerError, Cobbler
 
 from .xlate import XLATOR
 
-__version__ = '1.5.7'
+__version__ = '1.5.8'
 
 LOG = logging.getLogger(__name__)
 TZ = pytz.timezone('Europe/Berlin')
@@ -227,6 +227,8 @@ class CrTplHandler(BaseHandler):
         self.check_for_cobbler_distro()
         self.cobbler.ensure_profile()
         self.cobbler.ensure_root_authkeys()
+        self.cobbler.ensure_system_ks()
+        self.cobbler.ensure_snippets()
 
         self.vsphere.get_about()
         self.vsphere.get_clusters()