diff options
Diffstat (limited to 'sdnvpn/lib/openstack_utils.py')
-rw-r--r-- | sdnvpn/lib/openstack_utils.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sdnvpn/lib/openstack_utils.py b/sdnvpn/lib/openstack_utils.py index 9126eeb..bc9a86b 100644 --- a/sdnvpn/lib/openstack_utils.py +++ b/sdnvpn/lib/openstack_utils.py @@ -1438,3 +1438,43 @@ def get_resource(heat_client, stack_id, resource): except Exception as e: logger.error("Error [get_resource]: %s" % e) return None + + +def create_stack(heat_client, **kwargs): + try: + stack = heat_client.stacks.create(**kwargs) + stack_id = stack['stack']['id'] + if stack_id is None: + logger.error("Stack create start failed") + raise SystemError("Stack create start failed") + return stack_id + except Exception as e: + logger.error("Error [create_stack]: %s" % e) + return None + + +def delete_stack(heat_client, stack_id): + try: + heat_client.stacks.delete(stack_id) + return True + except Exception as e: + logger.error("Error [delete_stack]: %s" % e) + return False + + +def list_stack(heat_client, **kwargs): + try: + result = heat_client.stacks.list(**kwargs) + return result + except Exception as e: + logger.error("Error [list_stack]: %s" % e) + return None + + +def get_output(heat_client, stack_id, output_key): + try: + output = heat_client.stacks.output_show(stack_id, output_key) + return output + except Exception as e: + logger.error("Error [get_output]: %s" % e) + return None |