]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Stepping forward until creation of VM
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 9 Jun 2020 09:29:03 +0000 (11:29 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 9 Jun 2020 09:29:03 +0000 (11:29 +0200)
lib/cr_vmware_tpl/handler.py

index 074d3ee224c7d727331ae9747339e4b2f838f10a..cd9672a95bf8bd0839246512ae4794c4a5feb46a 100644 (file)
@@ -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)
 
     # -------------------------------------------------------------------------