From: Frank Brehm Date: Thu, 23 Jun 2022 11:33:07 +0000 (+0200) Subject: Verifying existence of repos of the given distro X-Git-Tag: 2.6.2~1^2~8^2~46 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=425d9287a7cfc57da83fe0e9012d3f337525d395;p=pixelpark%2Fcreate-vmware-tpl.git Verifying existence of repos of the given distro --- diff --git a/lib/cr_vmware_tpl/cobbler.py b/lib/cr_vmware_tpl/cobbler.py index d3d7a16..8e63cae 100644 --- a/lib/cr_vmware_tpl/cobbler.py +++ b/lib/cr_vmware_tpl/cobbler.py @@ -42,7 +42,7 @@ from .config import CrTplConfiguration from .xlate import XLATOR -__version__ = '0.8.1' +__version__ = '0.8.2' LOG = logging.getLogger(__name__) @@ -348,6 +348,42 @@ class Cobbler(BaseHandler): LOG.debug(_("Sorted list of found distros:") + "\n{}".format(pp(distro_list))) return distro_list + # ------------------------------------------------------------------------- + def get_repo_list(self): + """Trying to get a list of all configured repositories.""" + + repo_list = [] + + proc = self.exec_cobbler(('repo', 'list'), no_simulate=True) + for line in proc.stdout.splitlines(): + repo = line.strip() + if repo: + repo_list.append(repo) + repo_list.sort(key=str.lower) + if self.verbose > 1: + LOG.debug(_("Sorted list of found repositories:") + "\n{}".format(pp(repo_list))) + return repo_list + + # ------------------------------------------------------------------------- + def verify_distro_repos(self, distro): + + repo_list = self.get_repo_list() + + LOG.debug(_("Checking existence of repos for distro {!r}.").format(distro.name)) + + all_ok = True + for repo in distro.repos: + if repo not in repo_list: + msg = _("Repo {r!r} for distro {d!r} not found on cobbler server.").format( + r=repo, d=distro.name) + LOG.warn(msg) + all_ok = False + elif self.verbose > 1: + msg = _("Found repo {r!r} for distro {d!r}.").format(r=repo, d=distro.name) + LOG.debug(msg) + + return all_ok + # ------------------------------------------------------------------------- def get_profile_list(self): """Trying to get a list of all configured cobbler profiles.""" diff --git a/lib/cr_vmware_tpl/handler.py b/lib/cr_vmware_tpl/handler.py index 13e272c..7948442 100644 --- a/lib/cr_vmware_tpl/handler.py +++ b/lib/cr_vmware_tpl/handler.py @@ -49,7 +49,7 @@ from .cobbler import Cobbler from .xlate import XLATOR -__version__ = '2.1.0' +__version__ = '2.1.1' LOG = logging.getLogger(__name__) TZ = pytz.timezone('Europe/Berlin') @@ -382,6 +382,11 @@ class CrTplHandler(BaseHandler): self.cfg.cobbler_distro) LOG.debug(msg) + if not self.cobbler.verify_distro_repos(self.cfg.current_distro): + msg = _("Not all rpos for distro {!r} were found on Cobbler server.").format( + self.cfg.current_distro.name) + raise ExpectedHandlerError(msg) + # ------------------------------------------------------------------------- def check_for_temp_tpl_vm(self, no_error=False):