from .xlate import XLATOR
-__version__ = '0.2.3'
+__version__ = '0.2.4'
LOG = logging.getLogger(__name__)
return cobbler_version
+ # -------------------------------------------------------------------------
+ def get_distro_list(self):
+ """Trying to get a list of all configured distros."""
+
+ distro_list = []
+ proc = self.exec_cobbler(('distro', 'list'), no_simulate=True)
+ lines = proc.stdout.splitlines()
+ for line in proc.stdout.splitlines():
+ distro = line.strip()
+ if distro:
+ distro_list.append(distro)
+ distro_list.sort(key=str.lower)
+ return distro_list
+
# =============================================================================
if __name__ == "__main__":
from .xlate import XLATOR
-__version__ = '1.4.0'
+__version__ = '1.4.1'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
default_cobbler_ssh_port = 22
default_cobbler_ssh_user = 'root'
default_cobbler_ssh_timeout = 30
+ default_cobbler_distro = 'CentOS-8.1-x86_64'
ssh_privkey = 'id_rsa_cr_vmw_tpl'
self.private_ssh_key = None
+ self.cobbler_distro = self.default_cobbler_distro
self.cobbler_host = self.default_cobbler_host
self.cobbler_ssh_port = self.default_cobbler_ssh_port
self.cobbler_ssh_user = self.default_cobbler_ssh_user
re_timeout_key = re.compile(r'^\s*ssh-_]?timeout\s*$', re.IGNORECASE)
for (key, value) in config.items(section_name):
+ if key.lower() == 'distro' and value.strip() != '':
+ self.cobbler_distro = value.strip()
+ continue
if key.lower() == 'host' and value.strip() != '':
self.cobbler_host = value.strip().lower()
continue
from .xlate import XLATOR
-__version__ = '1.4.3'
+__version__ = '1.4.4'
LOG = logging.getLogger(__name__)
TZ = pytz.timezone('Europe/Berlin')
LOG.debug(_("Starting handling ..."))
self.cobbler.get_cobbler_version()
+ self.check_for_cobbler_distro()
return 0
return 0
+ # -------------------------------------------------------------------------
+ def check_for_cobbler_distro(self):
+ LOG.debug(_(
+ "Checking, whether distro {!r} is available "
+ "on the cobbler host.").format(self.config.cobbler_distro))
+
+ distro_list = self.cobbler.get_distro_list()
+ if self.config.cobbler_distro not in distro_list:
+ msg = _("Did not found distro {!r} on the cobbler host.").format(
+ self.config.cobbler_distro)
+ raise ExpectedHandlerError(msg)
+ if self.verbose > 1:
+ msg = _("Distro {!r} is available on the cobbler host.").format(
+ self.config.cobbler_distro)
+
# -------------------------------------------------------------------------
def check_for_temp_tpl_vm(self, no_error=False):