From: Frank Brehm Date: Tue, 10 Oct 2023 09:10:12 +0000 (+0200) Subject: Moving Cobbler related methods from lib/cr_vmware_tpl/handler/__init__.py into lib... X-Git-Tag: 3.0.0^2~11 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=e9925cd4386b9cd2432773cc30aedab3791216e5;p=pixelpark%2Fcreate-vmware-tpl.git Moving Cobbler related methods from lib/cr_vmware_tpl/handler/__init__.py into lib/cr_vmware_tpl/handler/cobbler.py --- diff --git a/lib/cr_vmware_tpl/handler/__init__.py b/lib/cr_vmware_tpl/handler/__init__.py index 8446291..cdc0841 100644 --- a/lib/cr_vmware_tpl/handler/__init__.py +++ b/lib/cr_vmware_tpl/handler/__init__.py @@ -58,7 +58,7 @@ from ..errors import MSG_NO_CLUSTER, TempVmExistsError, NoDatastoreFoundError from ..xlate import XLATOR -__version__ = '2.4.2' +__version__ = '2.4.3' LOG = logging.getLogger(__name__) TZ = pytz.timezone('Europe/Berlin') @@ -365,27 +365,6 @@ class CrTplHandler(BaseHandler, HandlerLdapMixin, HandlerCobblerMixin): return 0 - # ------------------------------------------------------------------------- - def check_for_cobbler_distro(self): - LOG.debug(_( - "Checking, whether distro {!r} is available " - "on the cobbler host.").format(self.cfg.cobbler_distro)) - - distro_list = self.cobbler.get_distro_list() - if self.cfg.cobbler_distro not in distro_list: - msg = _("Did not found distro {!r} on the cobbler host.").format( - self.cfg.cobbler_distro) - raise ExpectedHandlerError(msg) - if self.verbose > 1: - msg = _("Distro {!r} is available on the cobbler host.").format( - self.cfg.cobbler_distro) - LOG.debug(msg) - - if not self.cobbler.verify_distro_repos(self.cfg.current_distro): - msg = _("Not all repos 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): diff --git a/lib/cr_vmware_tpl/handler/cobbler.py b/lib/cr_vmware_tpl/handler/cobbler.py index a3c2218..117983b 100644 --- a/lib/cr_vmware_tpl/handler/cobbler.py +++ b/lib/cr_vmware_tpl/handler/cobbler.py @@ -13,16 +13,12 @@ import logging # Third party modules -from fb_tools.common import pp, is_sequence -from fb_tools.errors import HandlerError +from fb_tools.errors import ExpectedHandlerError # Own modules - -from .. import print_section_start, print_section_end - from ..xlate import XLATOR -__version__ = '0.1.0' +__version__ = '0.2.0' LOG = logging.getLogger(__name__) @@ -35,7 +31,26 @@ class HandlerCobblerMixin(): A mixin class for extending the CrTplHandler class for Cobbler dependend methods. """ - pass + # ------------------------------------------------------------------------- + def check_for_cobbler_distro(self): + LOG.debug(_( + "Checking, whether distro {!r} is available " + "on the cobbler host.").format(self.cfg.cobbler_distro)) + + distro_list = self.cobbler.get_distro_list() + if self.cfg.cobbler_distro not in distro_list: + msg = _("Did not found distro {!r} on the cobbler host.").format( + self.cfg.cobbler_distro) + raise ExpectedHandlerError(msg) + if self.verbose > 1: + msg = _("Distro {!r} is available on the cobbler host.").format( + self.cfg.cobbler_distro) + LOG.debug(msg) + + if not self.cobbler.verify_distro_repos(self.cfg.current_distro): + msg = _("Not all repos for distro {!r} were found on Cobbler server.").format( + self.cfg.current_distro.name) + raise ExpectedHandlerError(msg) # =============================================================================