]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Preparations in VSPhere
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 9 Jun 2020 08:58:06 +0000 (10:58 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 9 Jun 2020 08:58:06 +0000 (10:58 +0200)
lib/cr_vmware_tpl/handler.py

index cffd9c43bc265e87c404154fcefcd492db517013..074d3ee224c7d727331ae9747339e4b2f838f10a 100644 (file)
@@ -40,7 +40,7 @@ from .cobbler import CobblerError, Cobbler
 
 from .xlate import XLATOR
 
-__version__ = '1.5.2'
+__version__ = '1.5.3'
 
 LOG = logging.getLogger(__name__)
 TZ = pytz.timezone('Europe/Berlin')
@@ -225,8 +225,6 @@ class CrTplHandler(BaseHandler):
         self.cobbler.ensure_profile()
         self.cobbler.ensure_root_authkeys()
 
-        return 0
-
         self.vsphere.get_about()
         self.vsphere.get_clusters()
         self.cluster = self.vsphere.get_cluster_by_name(self.config.vsphere_cluster)
@@ -243,11 +241,12 @@ class CrTplHandler(BaseHandler):
             return 6
 
         self.vsphere.get_networks()
-
         self.vsphere.ensure_vm_folder(self.config.folder)
         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:
@@ -302,21 +301,21 @@ class CrTplHandler(BaseHandler):
     # -------------------------------------------------------------------------
     def check_for_temp_tpl_vm(self, no_error=False):
 
-        LOG.debug(_("First checking, whether {!r} exists ...").format(self.config.template_vm))
-        vm = self.vsphere.get_vm(self.config.template_vm, no_error=no_error)
+        LOG.debug(_("First checking, whether {!r} exists ...").format(self.tpl_vm_fqdn))
+        vm = self.vsphere.get_vm(self.tpl_vm_fqdn, no_error=no_error)
 
         if vm:
             if self.verbose > 1:
                 LOG.debug(_("Temporary VM {n!r} exists, raising {e}.").format(
-                    n=self.config.template_vm, e='TempVmExistsError'))
+                    n=self.tpl_vm_fqdn, e='TempVmExistsError'))
             if self.verbose > 2:
-                msg = "Info about Temporary VM {!r}:".format(self.config.template_vm)
+                msg = "Info about Temporary VM {!r}:".format(self.tpl_vm_fqdn)
                 msg += '\n' + pp(vm.config)
                 LOG.debug(msg)
-            raise TempVmExistsError(self.config.template_vm)
+            raise TempVmExistsError(self.tpl_vm_fqdn)
 
         LOG.debug(_("Temporary VM {!r} does not exists, will be created.").format(
-            self.config.template_vm))
+            self.tpl_vm_fqdn))
 
     # -------------------------------------------------------------------------
     def get_temp_tpl_vm(self):