From: Frank Brehm Date: Tue, 30 Oct 2018 12:56:32 +0000 (+0100) Subject: Successful installation X-Git-Tag: 0.3.2^2~17 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=4b8ee852a8f2713d1b8b62b7d2b9a38419202d4c;p=pixelpark%2Fcreate-vmware-tpl.git Successful installation --- diff --git a/lib/cr_vmware_tpl/handler.py b/lib/cr_vmware_tpl/handler.py index 18a43b0..b78f233 100644 --- a/lib/cr_vmware_tpl/handler.py +++ b/lib/cr_vmware_tpl/handler.py @@ -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): diff --git a/python_fb_tools b/python_fb_tools index d4c4790..2b6f3b0 160000 --- a/python_fb_tools +++ b/python_fb_tools @@ -1 +1 @@ -Subproject commit d4c4790f6abbcd7339d5ce4734c0a4d3129e1441 +Subproject commit 2b6f3b0911761160a386a005d092cd71da7aaf71