summaryrefslogtreecommitdiffstats
path: root/sdnvpn/lib
diff options
context:
space:
mode:
Diffstat (limited to 'sdnvpn/lib')
-rw-r--r--sdnvpn/lib/openstack_utils.py18
-rw-r--r--sdnvpn/lib/utils.py18
2 files changed, 27 insertions, 9 deletions
diff --git a/sdnvpn/lib/openstack_utils.py b/sdnvpn/lib/openstack_utils.py
index d377c33..5fc1e49 100644
--- a/sdnvpn/lib/openstack_utils.py
+++ b/sdnvpn/lib/openstack_utils.py
@@ -1404,15 +1404,6 @@ def delete_user(keystone_client, user_id):
# *********************************************
# HEAT
# *********************************************
-def get_resource(conn, stack_id, resource):
- try:
- resource = conn.orchestration.resources(stack_id, id=resource).next()
- return resource
- except Exception as e:
- logger.error("Error [get_resource(orchestration)]: %s" % e)
- return None
-
-
def create_stack(conn, **kwargs):
try:
stack = conn.orchestration.create_stack(**kwargs)
@@ -1426,6 +1417,15 @@ def create_stack(conn, **kwargs):
return None
+def update_stack(conn, stack_id, **kwargs):
+ try:
+ conn.orchestration.update_stack(stack_id, **kwargs)
+ return True
+ except Exception as e:
+ logger.error("Error [update_stack(orchestration)]: %s" % e)
+ return False
+
+
def delete_stack(conn, stack_id):
try:
conn.orchestration.delete_stack(stack_id)
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py
index eb245c5..4c35edc 100644
--- a/sdnvpn/lib/utils.py
+++ b/sdnvpn/lib/utils.py
@@ -14,6 +14,7 @@ import time
import requests
import re
import subprocess
+import yaml
from concurrent.futures import ThreadPoolExecutor
from openstack.exceptions import ResourceNotFound, NotFoundException
from requests.auth import HTTPBasicAuth
@@ -1150,3 +1151,20 @@ def get_vms_from_stack_outputs(conn, stack_id, vm_stack_output_keys):
if vm is not None:
vms.append(vm)
return vms
+
+
+def merge_yaml(y1, y2):
+ """ Merge two yaml HOT into one
+
+ The parameters, resources and outputs sections are merged.
+
+ :param y1: the first yaml
+ :param y2: the second yaml
+ :return y: merged yaml
+ """
+ d1 = yaml.load(y1)
+ d2 = yaml.load(y2)
+ for key in ('parameters', 'resources', 'outputs'):
+ if key in d2:
+ d1[key].update(d2[key])
+ return yaml.dump(d1, default_flow_style=False)