From: Frank Brehm Date: Thu, 12 Oct 2023 16:43:17 +0000 (+0200) Subject: Extending lib/cr_tf/config.py X-Git-Tag: 1.8.0^2~55 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=7603d5779204f9486eafa5b7c5e5859b30f567d6;p=pixelpark%2Fcreate-terraform.git Extending lib/cr_tf/config.py --- diff --git a/lib/cr_tf/config.py b/lib/cr_tf/config.py index 2a8702a..7efe0bd 100644 --- a/lib/cr_tf/config.py +++ b/lib/cr_tf/config.py @@ -32,7 +32,7 @@ from .errors import CrTfConfigError from .xlate import XLATOR -__version__ = '1.6.1' +__version__ = '1.8.0' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -47,17 +47,17 @@ class VsphereConfig(FbBaseObject): default_port = 443 default_dc = 'vmcc' default_cluster = 'vmcc-l105-01' - default_min_root_size_gb = 32.0 - default_guest_id = "oracleLinux7_64Guest" + default_min_root_size_gb = 20.0 + default_guest_id = 'centos8_64Guest' - default_template_name = 'oel7-template' + default_template_name = 'rhel9-template' # ------------------------------------------------------------------------- def __init__( self, appname=None, verbose=0, version=__version__, base_dir=None, name=None, host=None, port=None, user=None, password=None, dc=None, cluster=None, template_name=None, min_root_size_gb=None, excluded_ds=None, guest_id=None, - initialized=False): + rhsm_user=None, rhsm_password=None, initialized=False): self._name = None self._host = self.default_host @@ -286,7 +286,7 @@ class VsphereConfig(FbBaseObject): # ----------------------------------------------------------- @property def guest_id(self): - """The user name to connect to the VSphere server.""" + """The Id of the Guest OS in VSphere.""" return self._guest_id @guest_id.setter @@ -342,7 +342,8 @@ class VsphereConfig(FbBaseObject): initialized=self.initialized, host=self.host, port=self.port, user=self.user, password=self.password, dc=self.dc, cluster=self.cluster, template_name=self.template_name, excluded_ds=self.excluded_ds, - min_root_size_gb=self.min_root_size_gb, guest_id=self.guest_id) + min_root_size_gb=self.min_root_size_gb, guest_id=self.guest_id, + ) return vsphere # ------------------------------------------------------------------------- @@ -438,6 +439,8 @@ class CrTfConfiguration(BaseConfiguration): default_pdns_api_timeout = DEFAULT_PDNS_API_PORT default_pdns_comment_account = 'provisioning' + default_rhsm_user = 'dpx-subscriber' + default_vsphere_defs = { 'live': { 'host': 'vcs01.ppbrln.internal', @@ -504,6 +507,8 @@ class CrTfConfiguration(BaseConfiguration): self.puppetmaster = self.default_puppetmaster self.puppetca = self.default_puppetca self.pdns_comment_account = self.default_pdns_comment_account + self._rhsm_user = self.default_rhsm_user + self._rhsm_password = None self._no_pdns = False @@ -706,6 +711,40 @@ class CrTfConfiguration(BaseConfiguration): raise ValueError(msg) self._root_max_size = val + # ----------------------------------------------------------- + @property + def rhsm_user(self): + """The user used for subscribing the VM at RedHat.""" + return self._rhsm_user + + @rhsm_user.setter + def rhsm_user(self, value): + if value is None: + self._rhsm_user = self.default_rhsm_user + return + val = str(value).strip() + if val == '': + self._rhsm_user = self.default_rhsm_user + else: + self._rhsm_user = val + + # ----------------------------------------------------------- + @property + def rhsm_password(self): + """The password of the user used for subscribing the VM at RedHat.""" + return self._rhsm_password + + @rhsm_password.setter + def rhsm_password(self, value): + if value is None: + msg = _("The password of the ser used for subscribing at RedHat may not be None.") + raise CrTfConfigError(msg) + val = str(value).strip() + if val == '': + msg = _("The password of the ser used for subscribing at RedHat may not be None.") + raise CrTfConfigError(msg) + self._rhsm_password = val + # ------------------------------------------------------------------------- def init_vsphere_defaults(self): @@ -759,6 +798,7 @@ class CrTfConfiguration(BaseConfiguration): res['disk_max_size'] = self.disk_max_size res['root_min_size'] = self.root_min_size res['root_max_size'] = self.root_max_size + res['rhsm_user'] = self.rhsm_user res['vsphere'] = {} for vsphere_name in self.vsphere.keys(): @@ -777,6 +817,14 @@ class CrTfConfiguration(BaseConfiguration): else: res['vm_root_password'] = '*******' + if self.rhsm_password: + if show_secrets or self.verbose > 4: + res['rhsm_password'] = self.rhsm_password + else: + res['rhsm_password'] = '*******' + else: + res['rhsm_password'] = None + return res # -------------------------------------------------------------------------