From: Frank Brehm Date: Tue, 9 Jun 2020 09:29:03 +0000 (+0200) Subject: Stepping forward until creation of VM X-Git-Tag: 2.1.2^2~9^2~31^2~71 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=9d6f8aaec8692c155f2609979cabc31cb834e1a7;p=pixelpark%2Fcreate-vmware-tpl.git Stepping forward until creation of VM --- diff --git a/lib/cr_vmware_tpl/handler.py b/lib/cr_vmware_tpl/handler.py index 074d3ee..cd9672a 100644 --- a/lib/cr_vmware_tpl/handler.py +++ b/lib/cr_vmware_tpl/handler.py @@ -245,35 +245,35 @@ class CrTplHandler(BaseHandler): self.check_for_temp_tpl_vm(no_error=True) self.select_data_store() - return 0 - if self.rotate_only: LOG.warn(_("Only executing of template rotating.")) else: self.create_vm() - self.tpl_vm = self.vsphere.get_vm(self.config.template_vm, as_vmw_obj=True) + self.tpl_vm = self.vsphere.get_vm(self.tpl_vm_fqdn, as_vmw_obj=True) if not self.tpl_vm: if self.simulate: LOG.warn(_("Simulation mode - VM not created in real.")) else: raise HandlerError(_("Could not find VM after creating.")) - self.vsphere.poweron_vm(self.tpl_vm, max_wait=self.config.max_wait_for_poweron_vm) - self.ts_start_install = time.time() - self.wait_for_finish_install() +# self.vsphere.poweron_vm(self.tpl_vm, max_wait=self.config.max_wait_for_poweron_vm) +# self.ts_start_install = time.time() +# self.wait_for_finish_install() +# +# self.get_postinstall_error() +# if self.abort: +# LOG.warn(_("Aborting after creation of template VM.")) +# LOG.warn(_("You are responsible yourself to cleaning up the VM!!!")) +# else: +# self.post_install_tasks_ssh() +# if self.postinstall_errors: +# self.vsphere.purge_vm(self.tpl_vm, max_wait=self.config.max_wait_for_purge_vm) +# return 10 +# else: +# self.poweroff_vm() +# self.change_mac_address() - self.get_postinstall_error() - if self.abort: - LOG.warn(_("Aborting after creation of template VM.")) - LOG.warn(_("You are responsible yourself to cleaning up the VM!!!")) - else: - self.post_install_tasks_ssh() - if self.postinstall_errors: - self.vsphere.purge_vm(self.tpl_vm, max_wait=self.config.max_wait_for_purge_vm) - return 10 - else: - self.poweroff_vm() - self.change_mac_address() + return 0 if not self.abort and not self.postinstall_errors: self.rotate_templates() @@ -386,10 +386,14 @@ class CrTplHandler(BaseHandler): iface = VsphereVmInterface( appname=self.appname, verbose=self.verbose, base_dir=self.base_dir, name='eth', network=self.tpl_network, network_name=self.config.network, - mac_address=self.config.mac_address, summary='Primary network device') + summary='Primary network device') + + if self.verbose > 1: + msg = _("Defined interface to create:") + "\n{}".format(pp(iface.as_dict())) + LOG.debug(msg) vm_spec = self.vsphere.generate_vm_create_spec( - name=self.config.template_vm, datastore=self.tpl_data_store.name, + name=self.tpl_vm_fqdn, datastore=self.tpl_data_store.name, disks=[disk_size], nw_interfaces=[iface], graphic_ram_mb=256, videao_ram_mb=32, boot_delay_secs=5, ram_mb=self.config.ram_mb, num_cpus=self.config.num_cpus, ds_with_timestamp=True, @@ -403,7 +407,7 @@ class CrTplHandler(BaseHandler): LOG.debug(msg) self.vsphere.create_vm( - name=self.config.template_vm, vm_folder=tpl_vm_folder, vm_config_spec=vm_spec, + name=self.tpl_vm_fqdn, vm_folder=tpl_vm_folder, vm_config_spec=vm_spec, pool=self.cluster.resource_pool, max_wait=self.config.max_wait_for_create_vm) # -------------------------------------------------------------------------