from .config import CrTplConfiguration
-__version__ = '0.10.8'
+__version__ = '0.10.9'
LOG = logging.getLogger(__name__)
TZ = pytz.timezone('Europe/Berlin')
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
# 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.")
# -------------------------------------------------------------------------
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):
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):