From: Frank Brehm Date: Wed, 2 May 2018 09:39:30 +0000 (+0200) Subject: Adding possibility of aborting template creation after creating VM for inspection... X-Git-Tag: 0.1.1~7^2 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=d7bfe076e4db74de4c8cb88d2647d532c2d28cc6;p=pixelpark%2Fcreate-vmware-tpl.git Adding possibility of aborting template creation after creating VM for inspection purposes --- diff --git a/lib/cr_vmware_tpl/app.py b/lib/cr_vmware_tpl/app.py index 6a23f14..e21c85b 100644 --- a/lib/cr_vmware_tpl/app.py +++ b/lib/cr_vmware_tpl/app.py @@ -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( diff --git a/lib/cr_vmware_tpl/handler.py b/lib/cr_vmware_tpl/handler.py index 0830eaf..bd774bd 100644 --- a/lib/cr_vmware_tpl/handler.py +++ b/lib/cr_vmware_tpl/handler.py @@ -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))