From f4eac2fb34bb5be5395dab47690102295d48b3a2 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 30 May 2024 09:38:39 +0200 Subject: [PATCH] Setting URL of cobbler to https --- lib/cr_vmware_tpl/cobbler/__init__.py | 25 ++++++++++++++++++++++++- lib/cr_vmware_tpl/cobbler/profile.py | 9 ++++----- lib/cr_vmware_tpl/cobbler/system.py | 4 ++-- lib/cr_vmware_tpl/config/__init__.py | 4 ++-- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/lib/cr_vmware_tpl/cobbler/__init__.py b/lib/cr_vmware_tpl/cobbler/__init__.py index 274274b..64a769e 100644 --- a/lib/cr_vmware_tpl/cobbler/__init__.py +++ b/lib/cr_vmware_tpl/cobbler/__init__.py @@ -41,7 +41,7 @@ from ..errors import CobblerError, ExpectedCobblerError from ..xlate import XLATOR -__version__ = '0.11.4' +__version__ = '0.11.5' LOG = logging.getLogger(__name__) @@ -98,6 +98,29 @@ class Cobbler(BaseHandler, CobblerDistro, CobblerFiles, CobblerProfile, CobblerS if initialized: self.initialized = True + # ------------------------------------------------------ + @property + def url(self): + """The URL, which is used by new initiated VMs, to access resources on the cobbler host.""" + return self.cfg.cobbler_ws_base_url + + # ------------------------------------------------------------------------- + def as_dict(self, short=True): + """ + Transforms the elements of the object into a dict + + @param short: don't include local properties in resulting dict. + @type short: bool + + @return: structure as dict + @rtype: dict + """ + + res = super(Cobbler, self).as_dict(short=short) + res['url'] = self.url + + return res + # ------------------------------------------------------------------------- def __del__(self): diff --git a/lib/cr_vmware_tpl/cobbler/profile.py b/lib/cr_vmware_tpl/cobbler/profile.py index d8cfb60..492460b 100644 --- a/lib/cr_vmware_tpl/cobbler/profile.py +++ b/lib/cr_vmware_tpl/cobbler/profile.py @@ -27,7 +27,7 @@ from .. import print_section_start, print_section_end from ..errors import ExpectedCobblerError from ..xlate import XLATOR -__version__ = '0.2.3' +__version__ = '0.2.4' LOG = logging.getLogger(__name__) @@ -256,7 +256,7 @@ class CobblerProfile(): ks_meta_list.append("SWAP_SIZE_MB={}".format(self.cfg.swap_size_mb)) ks_meta_list.append("SYSTEM_STATUS={}".format(status)) ks_meta_list.append("WS_REL_FILESDIR={}".format(self.cfg.cobbler_ws_rel_filesdir)) - ks_meta_list.append("COBBLER_URL=http://{}".format(self.cfg.cobbler_host)) + ks_meta_list.append("COBBLER_URL={}".format(self.url)) if self.cfg.current_distro.is_rhel: ks_meta_list.append( "RHEL9_REPOSERVER_URL={}".format(self.cfg.rhel9_repo_server_url)) @@ -301,8 +301,7 @@ class CobblerProfile(): LOG.debug(_('Profile ks_meta {!r} is not ok.').format('WS_REL_FILESDIR')) ks_meta_ok = False - if 'COBBLER_URL' not in ks_meta_vars or \ - ks_meta_vars['COBBLER_URL'] != "http://{}".format(self.cfg.cobbler_host): + if 'COBBLER_URL' not in ks_meta_vars or ks_meta_vars['COBBLER_URL'] != self.url: LOG.debug(_('Profile ks_meta {!r} is not ok.').format('COBBLER_URL')) ks_meta_ok = False @@ -333,7 +332,7 @@ class CobblerProfile(): ks_meta_list.append("SWAP_SIZE_MB={}".format(self.cfg.swap_size_mb)) ks_meta_list.append("SYSTEM_STATUS={}".format(status)) ks_meta_list.append("WS_REL_FILESDIR={}".format(self.cfg.cobbler_ws_rel_filesdir)) - ks_meta_list.append("COBBLER_URL=http://{}".format(self.cfg.cobbler_host)) + ks_meta_list.append("COBBLER_URL={}".format(self.url)) if self.cfg.current_distro.is_rhel: ks_meta_list.append("RHEL9_REPOSERVER_URL={}".format(self.cfg.rhel9_repo_server_url)) diff --git a/lib/cr_vmware_tpl/cobbler/system.py b/lib/cr_vmware_tpl/cobbler/system.py index 35292a9..1ca9a1a 100644 --- a/lib/cr_vmware_tpl/cobbler/system.py +++ b/lib/cr_vmware_tpl/cobbler/system.py @@ -19,7 +19,7 @@ from .. import print_section_start, print_section_end from ..errors import ExpectedCobblerError from ..xlate import XLATOR -__version__ = '0.2.0' +__version__ = '0.2.1' LOG = logging.getLogger(__name__) @@ -75,7 +75,7 @@ class CobblerSystem(): ks_meta_list.append("SWAP_SIZE_MB={}".format(self.cfg.swap_size_mb)) ks_meta_list.append("SYSTEM_STATUS={}".format(status)) ks_meta_list.append("WS_REL_FILESDIR={}".format(self.cfg.cobbler_ws_rel_filesdir)) - ks_meta_list.append("COBBLER_URL=http://{}".format(self.cfg.cobbler_host)) + ks_meta_list.append("COBBLER_URL={}".format(self.url)) if self.cfg.rhsm_user: ks_meta_list.append("RHSM_USER={}".format(self.cfg.rhsm_user)) if self.cfg.rhsm_pwd: diff --git a/lib/cr_vmware_tpl/config/__init__.py b/lib/cr_vmware_tpl/config/__init__.py index cd79f3e..87fb968 100644 --- a/lib/cr_vmware_tpl/config/__init__.py +++ b/lib/cr_vmware_tpl/config/__init__.py @@ -38,7 +38,7 @@ from .eval import ConfigEval from .ldap import LdapConnectionInfo, LdapConnectionDict from .timeouts import ConfigTimeouts -__version__ = '3.3.1' +__version__ = '3.3.2' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -102,7 +102,7 @@ class CrTplConfiguration(BaseMultiConfig, ConfigCobbler, ConfigTimeouts, ConfigE resolv_conf = Path('/etc/resolv.conf') evaluated_resolv_conf = False - default_cobbler_ws_base_url = 'http://cobbler.pixelpark.com' + default_cobbler_ws_base_url = 'https://cobbler.pixelpark.com' default_cobbler_ws_docroot = Path('/var/www/html') default_cobbler_ws_rel_filesdir = Path('custom/vmware-template-files') -- 2.39.5