From 92d57dd388e5ad292d476298ad79d8a566780e2a Mon Sep 17 00:00:00 2001 From: spisarski Date: Thu, 12 Oct 2017 14:17:59 -0600 Subject: Improved creator/state machine classes class hierarchy. Created abstract superclasses for all classes responsible for deploying and maintaining the state of objects deployed to OpenStack which should help developers better understand the library. JIRA: SNAPS-183 Change-Id: I7651bd338f0d4e4086abbc11755e6be4f19058bd Signed-off-by: spisarski --- examples/launch.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'examples/launch.py') diff --git a/examples/launch.py b/examples/launch.py index f5d3bea..76353a2 100644 --- a/examples/launch.py +++ b/examples/launch.py @@ -164,7 +164,11 @@ def __create_instances(os_creds_dict, creator_class, config_class, config, creator = creator_class( __get_creds(os_creds_dict, os_users_dict, inst_config), config_class(**inst_config)) - creator.create(cleanup=cleanup) + + if cleanup: + creator.initialize() + else: + creator.create() out[inst_config['name']] = creator logger.info('Created configured %s', config_key) except Exception as e: @@ -211,7 +215,7 @@ def __create_vm_instances(os_creds_dict, os_users_dict, instances_config, instance_settings, image_creator.image_settings, keypair_creator=keypairs_dict[kp_name], - cleanup=cleanup) + init_only=cleanup) else: raise Exception('Image creator instance not found.' ' Cannot instantiate') @@ -669,7 +673,6 @@ def main(arguments): logger.error( 'Unexpected error deploying environment. Rolling back due' ' to - ' + str(e)) - # __cleanup(creators) raise # Must enter either block @@ -701,8 +704,8 @@ def main(arguments): def __cleanup(creators, clean_image=False): for creator_dict in reversed(creators): for key, creator in creator_dict.items(): - if (isinstance(creator, OpenStackImage) and clean_image) or \ - not isinstance(creator, OpenStackImage): + if ((isinstance(creator, OpenStackImage) and clean_image) + or not isinstance(creator, OpenStackImage)): try: creator.clean() except Exception as e: -- cgit 1.2.3-korg