vnfd composer fix missing node update 48/6948/1
authorlombardofr <lombardo@everyup.it>
Thu, 22 Nov 2018 09:50:33 +0000 (10:50 +0100)
committerlombardofr <lombardo@everyup.it>
Thu, 22 Nov 2018 09:50:33 +0000 (10:50 +0100)
Change-Id: Ia5c84c19739fd8d611169bffefbc6e667e3eb35f
Signed-off-by: lombardofr <lombardo@everyup.it>
descriptorhandler/views.py
lib/osm/osm_util.py
projecthandler/template/project/osm/osm_project_descriptors.html
static/TopologyComposer/js/graph_editor.js
static/src/descriptorhandler/composer.js

index b6c2b2a..064b5a5 100644 (file)
@@ -216,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)
 
index f61e201..49be9df 100644 (file)
@@ -72,6 +72,24 @@ class OsmUtil():
                     if str(v['member-vnf-index']) == str(old['member-vnf-index']) and str(v['vnfd-id-ref']) == str(
                             old['vnfd-id-ref']):
                         print 'update here'
+        elif descriptor_type == 'vnfd':
+            if 'vnfd-catalog' in descriptor:
+                vnfd = descriptor['vnfd-catalog']['vnfd'][0]
+            elif 'vnfd:vnfd-catalog' in descriptor:
+                vnfd = descriptor['vnfd:vnfd-catalog']['vnfd'][0]
+
+            if node_type == 'vnf_vl':
+                for k, v in enumerate(vnfd['internal-vld']):
+                    if v['id'] == old['id']:
+                        vnfd['internal-vld'][k].update(updated)
+            if node_type == 'cp':
+                for k, v in enumerate(vnfd['connection-point']):
+                    if v['name'] == old['name']:
+                        vnfd['connection-point'][k].update(updated)
+            if node_type == 'vdu':
+                for k, v in enumerate(vnfd['vdu']):
+                    if v['name'] == old['name']:
+                        vnfd['vdu'][k].update(updated)
 
         return descriptor
 
@@ -196,5 +214,11 @@ class OsmUtil():
             elif 'nsd:nsd-catalog' in descriptor:
                 nsd = descriptor['nsd:nsd-catalog']['nsd'][0]
             nsd.update(updated)
+        elif descriptor_type == 'vnfd':
+            if 'vnfd-catalog' in descriptor:
+                vnfd = descriptor['vnfd-catalog']['vnfd'][0]
+            elif 'vnfd:vnfd-catalog' in descriptor:
+                vnfd = descriptor['vnfd:vnfd-catalog']['vnfd'][0]
+            vnfd.update(updated)
 
         return descriptor
index 0957ba2..2491bf0 100644 (file)
                            '        data-toggle="tooltip" data-placement="top" title="Clone"\n' +
                            '        onclick="javascript:clonePackage(\''+ descriptor_type +'\', \''+row["_id"]+'\')">\n' +
                            '    <i class="fa fa-clone"></i></button>\n';
-                        if(descriptor_type == "nsd")
+                        //if(descriptor_type == "nsd")
                            result += '<button type="button" class="btn btn-default" data-container="body"\n' +
                            '        data-toggle="tooltip" data-placement="top" title="Show Graph"\n' +
                            '  onclick="location.href=\'/projects/descriptors/composer?type='+descriptor_type+'&id='+row["_id"] +'\'"\n' +
index 50e4f44..d8abcc8 100755 (executable)
@@ -347,7 +347,7 @@ TCD3.GraphEditor = (function () {
      * @returns {boolean}
      */
     GraphEditor.prototype.addLink = function (link) {
-        console.log("addLink" + JSON.stringify(link));
+
         if (link.source && link.target) {
             this.force.stop();
             this.cleanAll();
index 4b8bfd5..18072a8 100644 (file)
@@ -193,6 +193,8 @@ function refreshElementInfo(event, element) {
                 vduDetails(element.info.osm);
                 break;
             case 'int_cp':
+                intcpDetails(element.info.osm);
+                break;
             case 'cp':
                 cpDetails(element.info.osm);
                 break;
@@ -311,6 +313,15 @@ function vduDetails(vdur) {
     side.append(vdur_template)
 }
 
+function intcpDetails(cp) {
+    var side = $('#side_form');
+    var cp_template = getMainSection('Int. Connection Point');
+
+    cp_template += getChildrenTable(cp, true);
+    side.empty();
+    side.append(cp_template);
+}
+
 function cpDetails(cp) {
     var side = $('#side_form');
     var cp_template = getMainSectionWithSubmitButton('Connection Point');