X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=descriptorhandler%2Fviews.py;h=064b5a51a2a244cd005114bd2faff686d9aeae3a;hb=refs%2Fchanges%2F48%2F6948%2F1;hp=1bdb9b4def007d88246bc4d6fa98c07518f420ce;hpb=e428af7f429a3e42379c42c633ded0651ea2f0cf;p=osm%2FLW-UI.git diff --git a/descriptorhandler/views.py b/descriptorhandler/views.py index 1bdb9b4..064b5a5 100644 --- a/descriptorhandler/views.py +++ b/descriptorhandler/views.py @@ -137,6 +137,24 @@ def addElement(request, descriptor_type=None, descriptor_id=None, element_type=N return __response_handler(request, result_graph, url=None, status=200) + elif descriptor_type == 'vnfd': + descriptor_result = client.vnfd_get(user.get_token(), descriptor_id) + element_id = request.POST.get('id', '') + util = OsmUtil() + descriptor_updated = util.add_base_node('vnfd', descriptor_result, element_type, element_id, request.POST.dict()) + result = client.vnfd_update(user.get_token(), descriptor_id, descriptor_updated) + if result['error'] == True: + return __response_handler(request, result['data'], url=None, + status=result['data']['status'] if 'status' in result['data'] else 500) + else: + parser = OsmParser() + # print nsr_object + if descriptor_type == 'vnfd': + result_graph = parser.vnfd_to_graph(descriptor_updated) + + return __response_handler(request, result_graph, url=None, status=200) + + @login_required def removeElement(request, descriptor_type=None, descriptor_id=None, element_type=None): user = osmutils.get_user(request) @@ -159,6 +177,23 @@ def removeElement(request, descriptor_type=None, descriptor_id=None, element_typ return __response_handler(request, result_graph, url=None, status=200) + elif descriptor_type == 'vnfd': + descriptor_result = client.vnfd_get(user.get_token(), descriptor_id) + element_id = request.POST.get('id', '') + util = OsmUtil() + descriptor_updated = util.remove_node('vnfd', descriptor_result, element_type, element_id, request.POST.dict()) + result = client.vnfd_update(user.get_token(), descriptor_id, descriptor_updated) + if result['error'] == True: + return __response_handler(request, result['data'], url=None, + status=result['data']['status'] if 'status' in result['data'] else 500) + else: + parser = OsmParser() + # print nsr_object + if descriptor_type == 'vnfd': + result_graph = parser.vnfd_to_graph(descriptor_updated) + + return __response_handler(request, result_graph, url=None, status=200) + @login_required def updateElement(request, descriptor_type=None, descriptor_id=None, element_type=None): user = osmutils.get_user(request) @@ -181,6 +216,22 @@ def updateElement(request, descriptor_type=None, descriptor_id=None, element_typ # print nsr_object if descriptor_type == 'nsd': result_graph = parser.nsd_to_graph(descriptor_updated) + if descriptor_type == 'vnfd': + descriptor_result = client.vnfd_get(user.get_token(), descriptor_id) + util = OsmUtil() + payload = request.POST.dict() + if element_type == 'graph_params': + descriptor_updated = util.update_graph_params('vnfd', descriptor_result, json.loads(payload['update'])) + else: + descriptor_updated = util.update_node('vnfd', descriptor_result, element_type, json.loads(payload['old']), json.loads(payload['update'])) + result = client.vnfd_update(user.get_token(), descriptor_id, descriptor_updated) + if result['error'] == True: + return __response_handler(request, result['data'], url=None, + status=result['data']['status'] if 'status' in result['data'] else 500) + else: + parser = OsmParser() + if descriptor_type == 'vnfd': + result_graph = parser.vnfd_to_graph(descriptor_updated) return __response_handler(request, result_graph, url=None, status=200)