]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Adding possibility of aborting template creation after creating VM for inspection...
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 2 May 2018 09:39:30 +0000 (11:39 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 2 May 2018 09:39:30 +0000 (11:39 +0200)
lib/cr_vmware_tpl/app.py
lib/cr_vmware_tpl/handler.py

index 6a23f14e62f56a2c3a23092caf028a2d0eb9bde5..e21c85b261c80b054900de213afff9f5046e9fcf 100644 (file)
@@ -34,7 +34,7 @@ from .config import CrTplConfiguration
 
 from .handler import ExpectedHandlerError, CrTplHandler
 
-__version__ = '0.4.3'
+__version__ = '0.5.1'
 LOG = logging.getLogger(__name__)
 
 
@@ -415,6 +415,9 @@ class CrTplApplication(PpBaseObject):
         self.handler.config = self.config
         if self.args.rotate:
             self.handler.rotate_only = True
+        if self.args.abort:
+            self.handler.abort = True
+
         self.handler.initialized = True
         self.initialized = True
 
@@ -593,6 +596,11 @@ class CrTplApplication(PpBaseObject):
 
         """
 
+        self.arg_parser.add_argument(
+            '-A', '--abort', dest='abort', action='store_true',
+            help="Abort creation of VMWare template after successsful creation of template VM.",
+        )
+
         vmware_group = self.arg_parser.add_argument_group('VMWare options')
 
         vmware_group.add_argument(
index 0830eafb0f4a1b055872b9c5b859b54041b7f84b..bd774bd1c314990940fc39cabd97b939fb41ab09 100644 (file)
@@ -36,7 +36,7 @@ from .obj import PpBaseObject
 
 from .config import CrTplConfiguration
 
-__version__ = '0.7.7'
+__version__ = '0.8.1'
 LOG = logging.getLogger(__name__)
 TZ = pytz.timezone('Europe/Berlin')
 
@@ -169,6 +169,7 @@ class CrTplHandler(PpBaseObject):
         self.ssh_timeout = 30
         self.max_wait_for_shutdown = 600
         self.rotate_only = False
+        self.abort = False
 
         if initialized:
             self.initialized = True
@@ -219,12 +220,14 @@ class CrTplHandler(PpBaseObject):
                         "Could not find VM after creating.")
                 self.poweron_vm()
                 self.wait_for_finish_install()
-                self.post_install_tasks_ssh()
-                self.poweroff_vm()
-                self.change_mac_address()
-            self.rotate_templates()
-            if not self.rotate_only:
-                self.rename_and_change_vm()
+                if not self.abort:
+                    self.post_install_tasks_ssh()
+                    self.poweroff_vm()
+                    self.change_mac_address()
+            if not self.abort:
+                self.rotate_templates()
+                if not self.rotate_only:
+                    self.rename_and_change_vm()
         finally:
             LOG.debug("Disconnecting from vSphere host {h}:{p} ...".format(
                 h=self.config.vsphere_host, p=self.config.vsphere_port))