summaryrefslogtreecommitdiffstats
path: root/vio
diff options
context:
space:
mode:
authorEthan Lynn <ethanlynnl@vmware.com>2018-09-14 14:55:58 +0800
committerEthan Lynn <ethanlynnl@vmware.com>2018-09-18 07:33:11 +0000
commit27b37133f342e70eca204aed42c9a969ea03aa27 (patch)
tree8020daac8ac6c2b9ff43d839fbdf725f6bc98c53 /vio
parentd289ff9bc1f738eabcce24cb087ca451f94bb004 (diff)
Handle oof_directives in infra_workload API
Update infra_workload API to handle oof_directives. Change-Id: I9d51276fdbaf90d0a81379c487c849fd74971831 Issue-ID: MULTICLOUD-357 Signed-off-by: Ethan Lynn <ethanlynnl@vmware.com>
Diffstat (limited to 'vio')
-rw-r--r--vio/vio/swagger/views/workload/views.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/vio/vio/swagger/views/workload/views.py b/vio/vio/swagger/views/workload/views.py
index ec53408..84b4057 100644
--- a/vio/vio/swagger/views/workload/views.py
+++ b/vio/vio/swagger/views/workload/views.py
@@ -25,6 +25,27 @@ from vio.pub.exceptions import VimDriverVioException
logger = logging.getLogger(__name__)
+def handle_directives(body):
+ params = {}
+ try:
+ stack_params = body['template_data']['parameters']
+ stack_params_keys = list(stack_params.keys())
+ for oofd in body["oof_directives"]:
+ if oofd["type"] == "vnfc":
+ for dd in oofd["directives"]:
+ if dd["type"] == "flavor_directives":
+ for attr in dd["attributes"]:
+ params[attr[
+ "attribute_name"]] = attr["attribute_value"]
+ except KeyError as ex:
+ logger.debug("Error handle directives: %s" % str(ex))
+ return {}
+ for k, v in params.items():
+ if k in stack_params_keys:
+ stack_params[k] = v
+ return body
+
+
class CreateStackViewV1(APIView):
def post(self, request, cloud_owner, cloud_region):
@@ -34,6 +55,7 @@ class CreateStackViewV1(APIView):
return Response(data={'error': str(e)}, status=e.status_code)
try:
body = json.loads(request.body)
+ logger.debug("infra_workload post body: %s" % body)
template_type = body['template_type']
if template_type != "heat":
return Response(
@@ -41,12 +63,14 @@ class CreateStackViewV1(APIView):
"error": "invalid template type %s" % template_type
},
status=status.HTTP_400_BAD_REQUEST)
+ body = handle_directives(body)
stack_body = body['template_data']
except Exception as e:
return Response(data={'error': 'Fail to decode request body.'},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
try:
+ logger.debug("create stack input: %s" % stack_body)
stack_op = OperateStack.OperateStack(vim_info)
stack = stack_op.create_vim_stack(**stack_body)
rsp = {