]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Ensuring repofiles on Cobbler webserver
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 16 Jun 2020 15:28:12 +0000 (17:28 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 16 Jun 2020 15:28:12 +0000 (17:28 +0200)
lib/cr_vmware_tpl/cobbler.py
lib/cr_vmware_tpl/handler.py

index 6e417295fdc0a2a2d9ce3f55d4450f673d5f3e6e..78b50d84533275c5d21e8dea8279aae795d4ccde 100644 (file)
@@ -40,7 +40,7 @@ from .config import CrTplConfiguration
 
 from .xlate import XLATOR
 
-__version__ = '0.5.5'
+__version__ = '0.5.6'
 
 LOG = logging.getLogger(__name__)
 
@@ -725,6 +725,29 @@ class Cobbler(BaseHandler):
         self.ensure_remote_directory(remote_dir)
         self.ensure_remote_file(auth_keys_file, remote_file, check_parent=False)
 
+    # -------------------------------------------------------------------------
+    def ensure_repo_files(self):
+
+        files_dir = self.base_dir / 'files'
+        docroot = self.config.cobbler_ws_docroot / self.config.cobbler_ws_rel_filesdir
+        remote_dir = docroot / self.config.system_status / 'repos'
+
+        LOG.info(_("Ensuring currentness of snippets below {!r}.").format(
+            str(self.config.snippets_dir)))
+
+        for local_repo_dir in local_snippets_dir.glob('repos-*'):
+            if not local_repo_dir.is_dir():
+                LOG.warn(_("Local path {!r} is not a directory.").format(str(local_repo_dir)))
+                continue
+            dirname = str(local_repo_dir.name)
+            os_id = dirname.replace('repos-', '', 1)
+            LOG.debug(_("Ensuring repo files for {}.").format(os_id))
+            remote_dir_os = remote_dir / os_id
+            self.ensure_remote_directory(remote_dir_os)
+            for local_repo_file in local_repo_dir.glob('*.repo'):
+                remote_file = remote_dir_os / local_repo_file.name
+                self.ensure_remote_file(local_repo_file, remote_file)
+
     # -------------------------------------------------------------------------
     def get_dhcp_ip(self, mac_address):
 
index ffe2f4e33cc83dcb7aa6d6b75717b1115566e4eb..cfa96f1dad2010a8da5b4927366a0c98752a74be 100644 (file)
@@ -42,7 +42,7 @@ from .cobbler import CobblerError, Cobbler
 
 from .xlate import XLATOR
 
-__version__ = '1.6.1'
+__version__ = '1.6.2'
 
 LOG = logging.getLogger(__name__)
 TZ = pytz.timezone('Europe/Berlin')
@@ -232,6 +232,7 @@ class CrTplHandler(BaseHandler):
         self.cobbler.ensure_system_ks()
         self.cobbler.ensure_snippets()
         self.cobbler.ensure_keys()
+        self.cobbler.ensure_repo_files()
 
         self.vsphere.get_about()
         self.vsphere.get_clusters()