bug fix vnfd composer; minor ui fix 60/6960/1
authorlombardofr <lombardo@everyup.it>
Sun, 25 Nov 2018 20:46:36 +0000 (21:46 +0100)
committerlombardofr <lombardo@everyup.it>
Sun, 25 Nov 2018 20:46:36 +0000 (21:46 +0100)
Change-Id: I3f7cbc4949ddf9265bd1b1eb19aa3d51aefb8c42
Signed-off-by: lombardofr <lombardo@everyup.it>
descriptorhandler/template/modal/modal_keyboard_info_base.html
lib/osm/osm_util.py
static/TopologyComposer/css/composer.css
static/TopologyComposer/js/graph_editor.js

index 2be28a9..8f0fa42 100644 (file)
@@ -15,7 +15,7 @@
                         <p>Create edge: Select the first vertex by clicking on it. <span class="help-key">Shift</span> + <span class="help-key">left-click</span> on another vertex (different than the selected one).</p>
                     </li>
                     <li>
-                        <p> <span class="help-key">Delete</span> Delete selected nodes or link.</p>
+                        <p>Delete edge: Select the vertex by clicking on it. <span class="help-key">right-click</span> + <span class="help-key">Delete</span></p>
                     </li>
 
 
index 49be9df..8cf6a4e 100644 (file)
@@ -38,21 +38,24 @@ class OsmUtil():
             if node_type == 'vnf_vl':
                 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':
-
+                vnfd['connection-point'] = [item for item in vnfd['connection-point'] if item['name'] != args['name']]
                 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]
-
-
-
+                        vdu['interface'] = [item for item in vdu['interface'] if 'external-connection-point-ref' not in item
+                        or ('external-connection-point-ref'in item and item['external-connection-point-ref'] != args['name'])]
+            if node_type == 'vdu':
+                vdus = []
+                for vdu in vnfd['vdu']:
+                    if vdu['name'] != element_id:
+                        vdus.append(vdu)
+                    else:
+                        for intcp in vdu['internal-connection-point']:
+                            for intVld in vnfd['internal-vld']:
+                                intVld['internal-connection-point'] = [item for item in intVld['internal-connection-point']
+                                                                    if item['id-ref'] != intcp['id']]
+                vnfd['vdu'] = vdus
+            if node_type == 'int_cp':
+                OsmUtil.remove_int_cp(element_id, vnfd)
         return descriptor
 
     @staticmethod
@@ -137,6 +140,8 @@ class OsmUtil():
             elif 'vnfd:vnfd-catalog' in descriptor:
                 vnfd = descriptor['vnfd:vnfd-catalog']['vnfd'][0]
             if node_type == 'vdu':
+                if 'vdu' not in vnfd:
+                    vnfd['vdu'] = []
                 vnfd['vdu'].append({
                     "count": "1",
                     "description": "",
@@ -150,12 +155,16 @@ class OsmUtil():
                     "name": element_id
                 })
             if node_type == 'cp':
+                if 'connection-point' not in vnfd:
+                    vnfd['connection-point'] = []
                 vnfd['connection-point'].append({
                     "type": "VPORT",
                     "name": element_id
                 })
 
             if node_type == 'vnf_vl':
+                if 'internal-vld' not in vnfd:
+                    vnfd['internal-vld'] = []
                 vnfd['internal-vld'].append({
                     "short-name": element_id,
                     "name": element_id,
@@ -222,3 +231,19 @@ class OsmUtil():
             vnfd.update(updated)
 
         return descriptor
+
+    @staticmethod
+    def remove_int_cp(element_id, vnfd):
+        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]
+        for intVld in vnfd['internal-vld']:
+            intVld['internal-connection-point'] = [item for item in intVld['internal-connection-point'] if
+                                                   item['id-ref'] != element_id]
+
+        return vnfd
index 12be9e7..119d2ea 100644 (file)
@@ -1,3 +1,8 @@
+line {
+  stroke: rgb(212, 212, 212);
+  stroke-width: 1px;
+  shape-rendering: crispEdges;
+}
 
 .node_path {
     opacity: 1;
     -moz-user-select: none;
     -ms-user-select: none;
     user-select: none;
+    background-color: whitesmoke;
 }
 
 #palette > .node:first-child {
index d8abcc8..2d9218b 100755 (executable)
@@ -137,11 +137,11 @@ TCD3.GraphEditor = (function () {
                 //d3.event.preventDefault();
                 if (self.lastKeyDown !== -1) return;
                 self.lastKeyDown = d3.event.keyCode;
-                if (self.lastKeyDown === CANC_BUTTON && self._selected_node !== undefined) {
-                    self.removeNode(self._selected_node, null, showAlert);
-                } else if (self.lastKeyDown === CANC_BUTTON && self._selected_link !== undefined) {
-                    self.removeLink(self._selected_link, null, showAlert);
-                }
+                // if (self.lastKeyDown === CANC_BUTTON && self._selected_node !== undefined) {
+                //     self.removeNode(self._selected_node, null, showAlert);
+                // } else if (self.lastKeyDown === CANC_BUTTON && self._selected_link !== undefined) {
+                //     self.removeLink(self._selected_link, null, showAlert);
+                // }
 
             })
             .on('keyup', function () {