summaryrefslogtreecommitdiffstats
path: root/examples/launch.py
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2017-10-12 14:17:59 -0600
committerspisarski <s.pisarski@cablelabs.com>2017-10-12 14:17:59 -0600
commit92d57dd388e5ad292d476298ad79d8a566780e2a (patch)
treedeaa2c6854aa53a6e71cc15c06c9d5d1e57beab2 /examples/launch.py
parentcef5b452099579a3f69a5c233b7ba25bd0d80f5c (diff)
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 <s.pisarski@cablelabs.com>
Diffstat (limited to 'examples/launch.py')
-rw-r--r--examples/launch.py13
1 files changed, 8 insertions, 5 deletions
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: