From: Frank Brehm Date: Fri, 24 Jun 2022 12:43:22 +0000 (+0200) Subject: Reading in cobbler repo definitions from config X-Git-Tag: 2.6.2~1^2~8^2~42 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=891986c6e41e94f8ae82a6335953045c2bd9df31;p=pixelpark%2Fcreate-vmware-tpl.git Reading in cobbler repo definitions from config --- diff --git a/lib/cr_vmware_tpl/config.py b/lib/cr_vmware_tpl/config.py index 68b54e3..e3f160c 100644 --- a/lib/cr_vmware_tpl/config.py +++ b/lib/cr_vmware_tpl/config.py @@ -18,7 +18,7 @@ import crypt from pathlib import Path # Own modules -from fb_tools.common import is_sequence +from fb_tools.common import is_sequence, pp from fb_tools.obj import FbGenericBaseObject from fb_tools.collections import CIStringSet from fb_tools.multi_config import MultiConfigError, BaseMultiConfig @@ -477,6 +477,7 @@ class CrTplConfiguration(BaseMultiConfig): self.cobbler_ws_docroot = self.default_cobbler_ws_docroot self.cobbler_ws_rel_filesdir = self.default_cobbler_ws_rel_filesdir self.cobbler_distros = {} + self.cobbler_repos = {} self.current_distro = None @@ -706,6 +707,7 @@ class CrTplConfiguration(BaseMultiConfig): def eval_section(self, section_name): re_cobbler_distros = re.compile(r'^\s*cobbler[_-]?distros\s*$', re.IGNORECASE) + re_cobbler_repos = re.compile(r'^\s*cobbler[_-]?repos\s*$', re.IGNORECASE) LOG.debug(_("Evaluating section {!r} ...").format(section_name)) @@ -729,6 +731,9 @@ class CrTplConfiguration(BaseMultiConfig): if re_cobbler_distros.match(section_name): self._eval_cobbler_distros(section_name, section) return + if re_cobbler_repos.match(section_name): + self._eval_cobbler_repos(section_name, section) + return if self.verbose > 1: LOG.debug(_("Unhandled configuration section {!r}.").format(section_name)) @@ -1075,6 +1080,30 @@ class CrTplConfiguration(BaseMultiConfig): return pwd_hash + # ------------------------------------------------------------------------- + def _eval_cobbler_repos(self, section_name, section): + + if self.verbose > 1: + LOG.debug(_("Checking config section {!r} ...").format(section_name)) + + for full_repo_name in section.keys(): + repo_data = section[full_repo_name] + if isinstance(repo_data, dict): + repo_info = {} + if self.verbose > 2: + LOG.debug(_("Found Cobbler repository {!r}.").format(full_repo_name)) + for key in repo_data.keys(): + value = repo_data[key] + if key.lower() == 'reponame' and value.strip() != '': + repo_info['reponame'] = value.strip() + continue + if key.lower() == 'filename' and value.strip() != '': + repo_info['filename'] = value.strip() + continue + self.cobbler_repos[full_repo_name] = repo_info + if self.verbose > 3: + LOG.debug(_("Evaluated Cobbler repositories:") + '\n' + pp(self.cobbler_repos)) + # ============================================================================= if __name__ == "__main__":