From 9f16b1a4d699ae3012e04017a8a04976ef8d5fce Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 16 Jun 2020 17:28:12 +0200 Subject: [PATCH] Ensuring repofiles on Cobbler webserver --- lib/cr_vmware_tpl/cobbler.py | 25 ++++++++++++++++++++++++- lib/cr_vmware_tpl/handler.py | 3 ++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/cr_vmware_tpl/cobbler.py b/lib/cr_vmware_tpl/cobbler.py index 6e41729..78b50d8 100644 --- a/lib/cr_vmware_tpl/cobbler.py +++ b/lib/cr_vmware_tpl/cobbler.py @@ -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): diff --git a/lib/cr_vmware_tpl/handler.py b/lib/cr_vmware_tpl/handler.py index ffe2f4e..cfa96f1 100644 --- a/lib/cr_vmware_tpl/handler.py +++ b/lib/cr_vmware_tpl/handler.py @@ -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() -- 2.39.5