From: Frank Brehm Date: Tue, 23 Jun 2020 10:34:45 +0000 (+0200) Subject: Cleaning up config, version bump to 1.9.9 X-Git-Tag: 2.1.2^2~9^2~31^2~3 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=a554781f2c621fe23ecea09e5830b4298f6549e6;p=pixelpark%2Fcreate-vmware-tpl.git Cleaning up config, version bump to 1.9.9 --- diff --git a/lib/cr_vmware_tpl/__init__.py b/lib/cr_vmware_tpl/__init__.py index 1184a56..83b21d2 100644 --- a/lib/cr_vmware_tpl/__init__.py +++ b/lib/cr_vmware_tpl/__init__.py @@ -1,6 +1,6 @@ #!/bin/env python3 # -*- coding: utf-8 -*- -__version__ = '1.1.1' +__version__ = '1.9.9' # vim: ts=4 et list diff --git a/lib/cr_vmware_tpl/app.py b/lib/cr_vmware_tpl/app.py index 41e4e6b..8fee7c8 100644 --- a/lib/cr_vmware_tpl/app.py +++ b/lib/cr_vmware_tpl/app.py @@ -35,7 +35,7 @@ from .xlate import __base_dir__ as __xlate_base_dir__ from .xlate import __mo_file__ as __xlate_mo_file__ from .xlate import XLATOR, LOCALE_DIR, DOMAIN -__version__ = '1.1.2' +__version__ = '1.2.1' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -291,17 +291,10 @@ class CrTplApplication(BaseApplication): ) vmware_group.add_argument( - '-M', '--vm', dest='vm', + '-I', '--os-id', dest='os_id', help=_( - "The temporary VM, which will be created and converted into a " - "template (Default: {!r}).").format(CrTplConfiguration.default_template_vm) - ) - - vmware_group.add_argument( - '-T', '--template', metavar=_("TEMPLATE"), - help=_( - "The name of the created template as result of this script " - "(Default: {!r}).").format(CrTplConfiguration.default_template_name) + "The abbreviation for the operating system (e.g. 'oel7' or 'centos8', " + "Default: {!r}).").format(CrTplConfiguration.default_os_id) ) vmware_group.add_argument( @@ -344,11 +337,14 @@ class CrTplApplication(BaseApplication): self.config.vsphere_cluster = self.args.cluster if self.args.folder: self.config.folder = self.args.folder - if self.args.vm: - self.config.template_vm = self.args.vm if self.args.template: self.config.template_name = self.args.template - + if self.args.os_id: + self.config.os_id = self.args.os_id + if not self.config.template_name_given: + self.config.template_name = self.args.os_id + '-template' + if not self.config.cobbler_profile_given: + self.config.cobbler_profile = 'vmware-template-' + self.args.os_id if self.args.number is not None: self.config.max_nr_templates_stay = self.args.number diff --git a/lib/cr_vmware_tpl/config.py b/lib/cr_vmware_tpl/config.py index e7a9d94..3c6a696 100644 --- a/lib/cr_vmware_tpl/config.py +++ b/lib/cr_vmware_tpl/config.py @@ -52,13 +52,11 @@ class CrTplConfiguration(BaseConfiguration): default_vsphere_cluster = 'vmcc-l105-01' default_dc = 'vmcc' default_folder = 'templates' - default_template_vm = 'template.pixelpark.com' default_template_name = default_os_id + '-template' default_data_size_gb = 32.0 default_num_cpus = 2 default_ram_mb = 4 * 1024 default_network = '192.168.88.0_23' - default_mac_address = '00:16:3e:54:ab:2b' default_max_wait_for_general = 15 default_max_wait_for_shutdown = 600 default_max_wait_for_finish_install = 60 * 60 @@ -126,14 +124,12 @@ class CrTplConfiguration(BaseConfiguration): self.dc = self.default_dc self.password = None self.folder = self.default_folder - self.template_vm = self.default_template_vm self.template_name = self.default_template_name self.data_size_gb = self.default_data_size_gb self.num_cpus = self.default_num_cpus self.ram_mb = self.default_ram_mb self.swap_size_mb = self.default_swap_size_mb self.network = self.default_network - self.mac_address = self.default_mac_address self.max_wait_for_general = self.default_max_wait_for_general self.max_wait_for_create_vm = None self.max_wait_for_poweron_vm = None @@ -146,8 +142,8 @@ class CrTplConfiguration(BaseConfiguration): self.tpl_vm_domain = self.default_tpl_vm_domain - self._cobbler_profile_given = False - self._template_name_given = False + self.cobbler_profile_given = False + self.template_name_given = False self._root_password = self.default_root_password @@ -279,10 +275,10 @@ class CrTplConfiguration(BaseConfiguration): if self.max_wait_for_shutdown_vm is None: self.max_wait_for_shutdown_vm = self.max_wait_for_general - if not self._template_name_given: + if not self.template_name_given: self.template_name = self.os_id + '-template' - if not self._cobbler_profile_given: + if not self.cobbler_profile_given: self.cobbler_profile = 'vmware-template-' + self.os_id self.cobbler_ks_dir = self.cobbler_rootdir / 'kickstarts' @@ -374,61 +370,53 @@ class CrTplConfiguration(BaseConfiguration): re_swap_space = re.compile(r'^\s*swap[-_]?space(?:[-_]?mb)?\s*$', re.IGNORECASE) for (key, value) in config.items(section_name): - if key.lower() == 'vm': - self.template_vm = value - continue - elif re_os_id.match(key): + if re_os_id.match(key): v = value.strip().lower() v = re_os_id_subst.sub('', v) if v: self.os_id = v continue - elif key.lower() == 'name': + if key.lower() == 'name': self.template_name = value - self._template_name_given = True + self.template_name_given = True continue - elif re_vm_domain.match(key) and value.strip(): + if re_vm_domain.match(key) and value.strip(): self.tpl_vm_domain = value.strip().lower() continue - elif key.lower() == 'data_size_gb': + if key.lower() == 'data_size_gb': self.data_size_gb = float(value) continue - elif key.lower() == 'data_size_mb': + if key.lower() == 'data_size_mb': self.data_size_gb = float(value) / 1024.0 continue - elif key.lower() == 'data_size_kb': + if key.lower() == 'data_size_kb': self.data_size_gb = float(value) / 1024.0 / 1024.0 continue - elif key.lower() == 'data_size': + if key.lower() == 'data_size': self.data_size_gb = float(value) / 1024.0 / 1024.0 / 1024.0 continue - elif key.lower() == 'num_cpus': + if key.lower() == 'num_cpus': self.num_cpus = int(value) continue - elif key.lower() == 'ram_gb': + if key.lower() == 'ram_gb': self.ram_mb = int(float(value) * 1024.0) continue - elif key.lower() == 'ram_mb': + if key.lower() == 'ram_mb': self.ram_mb = int(value) continue - elif key.lower() == 'network': + if key.lower() == 'network': self.network = value.strip() continue - elif key.lower() == 'mac_address': - v = value.strip().lower() - if v: - self.mac_address = v - continue - elif key.lower() == 'vmware_cfg_version': + if key.lower() == 'vmware_cfg_version': self.vmware_cfg_version = value.strip() continue - elif key.lower() == 'os_version': + if key.lower() == 'os_version': self.os_version = value.strip() continue - elif re_root_pwd.match(key) and value.strip(): + if re_root_pwd.match(key) and value.strip(): self._root_password = value.strip() continue - elif re_swap_space.match(key) and value.strip(): + if re_swap_space.match(key) and value.strip(): self.swap_size_mb = int(value) continue @@ -567,7 +555,7 @@ class CrTplConfiguration(BaseConfiguration): continue if key.lower() == 'profile' and value.strip() != '': self.cobbler_profile = value.strip().lower() - self._cobbler_profile_given = True + self.cobbler_profile_given = True continue if re_pr_repos_key.match(key) and value.strip() != '': self.cobbler_profile_repos = re_split_values.split(value.strip())