]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Successful installation
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 30 Oct 2018 12:56:32 +0000 (13:56 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 30 Oct 2018 12:56:32 +0000 (13:56 +0100)
lib/cr_vmware_tpl/handler.py
python_fb_tools

index 18a43b099e1efb2f0cdc7027c26ee7e0288ee98c..b78f2332bbc4bf7ab140065883536721f3196665 100644 (file)
@@ -43,7 +43,7 @@ from fb_tools.vsphere.iface import VsphereVmInterface
 
 from .config import CrTplConfiguration
 
-__version__ = '0.10.8'
+__version__ = '0.10.9'
 
 LOG = logging.getLogger(__name__)
 TZ = pytz.timezone('Europe/Berlin')
@@ -178,6 +178,23 @@ class CrTplHandler(BaseHandler):
                 else:
                     raise HandlerError("Could not find VM after creating.")
 
+            self.vsphere.poweron_vm(self.tpl_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.purge_template_vm()
+                    return 10
+                else:
+                    self.poweroff_vm()
+                    #self.change_mac_address()
+
         return 0
 
 
@@ -211,8 +228,8 @@ class CrTplHandler(BaseHandler):
 #                if not self.tpl_vm:
 #                    raise HandlerError(
 #                        "Could not find VM after creating.")
-                self.poweron_vm()
-                self.wait_for_finish_install()
+#                self.poweron_vm()
+#                self.wait_for_finish_install()
                 self.get_postinstall_error()
                 if self.abort:
                     LOG.warn("Aborting after creation of template VM.")
@@ -347,34 +364,7 @@ class CrTplHandler(BaseHandler):
     # -------------------------------------------------------------------------
     def get_temp_tpl_vm(self):
 
-        content = self.service_instance.RetrieveContent()
-        dc = self.get_obj(content, [vim.Datacenter], self.config.dc)
-
-        for child in dc.vmFolder.childEntity:
-            vm = self._get_temp_tpl_vm(child)
-            if vm:
-                return vm
-
-        return None
-
-    # -------------------------------------------------------------------------
-    def _get_temp_tpl_vm(self, child, depth=1):
-
-        if hasattr(child, 'childEntity'):
-            if depth > self.max_depth:
-                return None
-            for sub_child in child.childEntity:
-                vm = self._get_temp_tpl_vm(sub_child, depth + 1)
-                if vm:
-                    return vm
-            return None
-
-        if hasattr(child, 'summary'):
-            summary = child.summary
-            if summary.config.name == self.config.template_vm:
-                return child
-
-        return None
+        return self.vsphere.get_vm(self.config.template_vm, as_vmw_obj=True)
 
     # -------------------------------------------------------------------------
     def get_templates(self):
@@ -496,15 +486,15 @@ class CrTplHandler(BaseHandler):
             name=self.config.template_vm, vm_folder=tpl_vm_folder, vm_config_spec=vm_spec,
             pool=self.cluster.resource_pool, max_wait=15)
 
-    # -------------------------------------------------------------------------
-    def poweron_vm(self):
-
-        LOG.info("Powering on VM {!r} ...".format(self.config.template_vm))
-
-        task = self.tpl_vm.PowerOnVM_Task()
-        self.wait_for_tasks([task])
-        self.ts_start_install = time.time()
-        LOG.debug("VM {!r} successful powered on.".format(self.config.template_vm))
+#    # -------------------------------------------------------------------------
+#    def poweron_vm(self):
+#
+#        LOG.info("Powering on VM {!r} ...".format(self.config.template_vm))
+#
+#        task = self.tpl_vm.PowerOnVM_Task()
+#        self.wait_for_tasks([task])
+#        self.ts_start_install = time.time()
+#        LOG.debug("VM {!r} successful powered on.".format(self.config.template_vm))
 
     # -------------------------------------------------------------------------
     def wait_for_finish_install(self):
index d4c4790f6abbcd7339d5ce4734c0a4d3129e1441..2b6f3b0911761160a386a005d092cd71da7aaf71 160000 (submodule)
@@ -1 +1 @@
-Subproject commit d4c4790f6abbcd7339d5ce4734c0a4d3129e1441
+Subproject commit 2b6f3b0911761160a386a005d092cd71da7aaf71