composer vnfd fix on delete intCp node 47/6947/1
authorlombardofr <lombardo@everyup.it>
Thu, 22 Nov 2018 07:59:25 +0000 (08:59 +0100)
committerlombardofr <lombardo@everyup.it>
Thu, 22 Nov 2018 07:59:25 +0000 (08:59 +0100)
Change-Id: I0317be6e5c17ea4737b6e48bd77facc22c99f20d
Signed-off-by: lombardofr <lombardo@everyup.it>
lib/osm/osm_util.py
static/src/descriptorhandler/controller.js

index 05f73ff..f61e201 100644 (file)
@@ -39,6 +39,19 @@ class OsmUtil():
                 vnfd['internal-vld'] = [item for item in vnfd['internal-vld'] if item['id'] != element_id]
             if node_type == 'cp':
                 vnfd['connection-point'] = [item for item in vnfd['connection-point'] if item['name'] != element_id]
+            if node_type == 'vdu':
+                # check
+                vnfd['vdu'] = [item for item in vnfd['vdu'] if item['name'] != element_id]
+            if node_type == 'int_cp':
+
+                for vdu in vnfd['vdu']:
+                    if 'interface' in vdu:
+                        vdu['interface'] = [item for item in vdu['interface'] if 'internal-connection-point-ref' not in item
+                        or ('internal-connection-point-ref'in item and item['internal-connection-point-ref'] != element_id)]
+                    if 'internal-connection-point' in vdu:
+                        vdu['internal-connection-point'] = [item for item in vdu['internal-connection-point'] if item['id'] != element_id]
+
+
 
         return descriptor
 
@@ -54,14 +67,11 @@ class OsmUtil():
                 for k, v in enumerate(nsd['vld']):
                     if v['id'] == old['id']:
                         nsd['vld'][k].update(updated)
-                        print 'update here'
-                        print old
             elif node_type == 'vnf':
                 for k, v in enumerate(nsd['constituent-vnfd']):
                     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'
-                        print old
 
         return descriptor
 
@@ -138,7 +148,7 @@ class OsmUtil():
                 })
             if node_type == 'interface':
                 for vdu in vnfd['vdu']:
-                    if vdu['id'] == args['vdu-id']:
+                    if vdu['id'] == args['vdu_id']:
                         vdu['interface'].append({
                             "virtual-interface": {
                                 "type": "VIRTIO"
@@ -148,6 +158,34 @@ class OsmUtil():
                             "type": "EXTERNAL",
                             "external-connection-point-ref": args["external-connection-point-ref"]
                         })
+            if node_type == 'int_cp':
+                for vdu in vnfd['vdu']:
+                    if vdu['id'] == args['vdu_id']:
+                        if 'internal-connection-point' not in vdu:
+                            vdu['internal-connection-point'] = []
+                        vdu['internal-connection-point'].append({
+                            "short-name": element_id,
+                            "type": "VPORT",
+                            "id": element_id,
+                            "name": element_id
+                        })
+                        if 'interface' not in vdu:
+                            vdu['interface'] = []
+                        vdu['interface'].append({
+                            "virtual-interface": {
+                                "type": "VIRTIO"
+                            },
+                            "name": "int_"+element_id,
+                            "type": "INTERNAL",
+                            "internal-connection-point-ref": element_id
+                        })
+                for int_vld in vnfd['internal-vld']:
+                    if int_vld['id'] == args['vld_id']:
+                        if 'internal-connection-point' not in int_vld:
+                            int_vld['internal-connection-point'] = []
+                        int_vld['internal-connection-point'].append({
+                            'id-ref': element_id
+                        })
         return descriptor
 
     @staticmethod
index 90eb863..6285f82 100644 (file)
@@ -43,16 +43,6 @@ TCD3.OsmController = (function (global) {
     OsmController.prototype.addLink = function (graph_editor, link, success, error) {
         log('addLink');
 
-        var data_to_send = {
-            'desc_id': link.desc_id,
-            'source': link.source.id,
-            'source_type': link.source.info.type,
-            'target': link.target.id,
-            'target_type': link.target.info.type,
-            'view': link.view,
-            'group': link.group
-        };
-
         var desc_id = getUrlParameter('id');
         var desc_type = getUrlParameter('type');
         if (desc_type === 'nsd') {
@@ -86,7 +76,7 @@ TCD3.OsmController = (function (global) {
 
                 var data_form = new FormData();
                 data_form.append('csrfmiddlewaretoken', getCookie('csrftoken'));
-                data_form.append('vdu-id', vdu_node.info.osm.id);
+                data_form.append('vdu_id', vdu_node.info.osm.id);
                 data_form.append('external-connection-point-ref', cp_node.info.osm.name);
                 $.ajax({
                     url: '/projects/descriptors/' + desc_type + '/' + desc_id + '/addElement/interface',
@@ -101,21 +91,17 @@ TCD3.OsmController = (function (global) {
             }
             else if (['vdu', 'vnf_vl'].indexOf(link.source.info.type) > -1 && ['vdu', 'vnf_vl'].indexOf(link.target.info.type) > -1) {
 
-                console.log("link tra vdu e vl");
-                /*var element_type = 'cp';
-                var data_form = new FormData();
-
                 var vdu_node = (link.source.info.type === 'vdu') ? link.source : link.target;
                 var vld_node = (link.source.info.type === 'vnf_vl') ? link.source : link.target;
 
+                var data_form = new FormData();
                 data_form.append('csrfmiddlewaretoken', getCookie('csrftoken'));
-                data_form.append('vnfd-connection-point-ref', 'cp_temp');
-                data_form.append('member-vnf-index-ref', vnfd_node.info.osm['member-vnf-index']);
-                data_form.append('vnfd-id-ref', vnfd_node.info.osm['vnfd-id-ref']);
-                data_form.append('vld_id', vld_node.info.osm['id']);
+                data_form.append('vdu_id', vdu_node.info.osm.id);
+                data_form.append('vld_id', vld_node.info.osm.id);
+                data_form.append('id',  "intcp_" + generateUID());
 
                 $.ajax({
-                    url: '/projects/descriptors/' + desc_type + '/' + desc_id + '/addElement/' + element_type,
+                    url: '/projects/descriptors/' + desc_type + '/' + desc_id + '/addElement/int_cp',
                     type: 'POST',
                     data: data_form,
                     cache: false,
@@ -123,7 +109,7 @@ TCD3.OsmController = (function (global) {
                     processData: false,
                     success: success,
                     error: error
-                });*/
+                });
             }
 
         }