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
)
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(
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
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
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
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
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'
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
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())