Add OSM_SERVER and OSMUI_SQL_DATABASE_URI to Dockerfile
[osm/LW-UI.git] / lib / osm / osm_rdcl_parser.py
index ab62688..48ffcbc 100644 (file)
@@ -257,8 +257,12 @@ class OsmParser(RdclGraph):
             self.add_node(ns_vld['id'], 'ns_vl', None, None, graph,
                           {'property': {'custom_label': ns_vld['name']}, 'osm': ns_vld})
             for cp_ref in ns_vld['vnfd-connection-point-ref']:
-                self.add_link(map_vnf_index_to_id[str(cp_ref['member-vnf-index-ref'])], ns_vld['id'], 'nsr', None,
-                              graph)
+                ns_vld['id']+ ':' + str(cp_ref['member-vnf-index-ref']) + ':' + cp_ref['vnfd-connection-point-ref']
+                cp_id = ns_vld['id']+ ':' + str(cp_ref['member-vnf-index-ref']) + ':' + cp_ref['vnfd-connection-point-ref']             
+                cp_label = str(cp_ref['vnfd-connection-point-ref'])
+                self.add_node(cp_id,'ns_cp','nsd',None,graph, {'property': {'custom_label': cp_label}, 'osm': cp_ref})
+                self.add_link(cp_id, ns_vld['id'], 'nsr', None, graph)
+                self.add_link(cp_id, map_vnf_index_to_id[str(cp_ref['member-vnf-index-ref'])], 'nsr', None, graph)
 
         return graph
 
@@ -284,9 +288,6 @@ class OsmParser(RdclGraph):
                             }
                         },
                         "int_cp": {
-                            "addable": {
-                                "callback": "addNode"
-                            },
                             "removable": {
                                 "callback": "removeNode"
                             }
@@ -304,34 +305,45 @@ class OsmParser(RdclGraph):
                         "vdu": {
                             "destination": {
                                 "cp": {
+                                    "callback": "addLink",
                                     "direct_edge": False,
+                                    "removable": {}
                                 },
-                                "int_cp": {
+                                "vnf_vl": {
+                                    "callback": "addLink",
                                     "direct_edge": False,
+                                    "removable": {}
                                 }
                             }
                         },
                         "cp": {
                             "destination": {
                                 "vdu": {
+                                    "callback": "addLink",
                                     "direct_edge": False,
+                                    "removable": {}
                                 }
                             }
                         },
-                        "int_cp": {
-                            "destination": {
-                                "vdu": {
-                                    "direct_edge": False,
-                                },
-                                "vnf_vl": {
-                                    "direct_edge": False,
-                                }
-                            }
-                        },
+                        "int_cp": {
+                            "destination": {
+                                "vdu": {
+                                    "direct_edge": False,
+                                },
+                                "vnf_vl": {
+                                    "direct_edge": False,
+                                }
+                            }
+                        },
                         "vnf_vl": {
                             "destination": {
                                 "int_cp": {
                                     "direct_edge": False
+                                },
+                                "vdu": {
+                                    "callback": "addLink",
+                                    "direct_edge": False,
+                                    "removable": {}
                                 }
                             }
                         }
@@ -340,7 +352,8 @@ class OsmParser(RdclGraph):
                 "name": "OSM",
                 "version": 1,
                 "description": "osm"
-            }, "callback": {"addNode": {"class": "OSMController"}, "removeNode": {"class": "OSMController"}}
+            }, "callback": {"addNode": {"class": "OSMController"}, "removeNode": {"class": "OSMController"},
+                            "removeLink": {"class": "OSMController"}, "addLink": {"class": "OSMController"}}
         }, 'graph_parameters': {'view': {'vnfd': {}}}}
         if 'vnfd-catalog' in vnfd_catalog:
             vnfd = vnfd_catalog['vnfd-catalog']['vnfd'][0]
@@ -387,13 +400,13 @@ class OsmParser(RdclGraph):
             "layer": {
                 "nsd": {
                     "nodes": {
-                        "vnf": {"addable": {
-                                "callback": "addNode"
-                            },
-                            "removable": {
-                                "callback": "removeNode"
-                            }},
-                        "cp": {},
+                        "vnf": {
+                            "addable": {"callback": "addNode"},
+                            "removable": {"callback": "removeNode"}
+                        },
+                        "ns_cp": {
+                            "removable": {"callback": "removeNode"}
+                        },
                         "ns_vl": {
                             "addable": {
                                 "callback": "addNode"
@@ -404,29 +417,44 @@ class OsmParser(RdclGraph):
                         }
                     },
                     "allowed_edges": {
-                        "cp": {
+                        "vnf":{
                             "destination": {
-                                "vnfd": {
+                                "ns_cp": {
+                                    "direct_edge": False,
+                                    "removable" : {
+                                        "callback": "removeLink",
+                                    }
+                                },
+                                "ns_vl": {
                                     "direct_edge": False,
+                                    "callback": "addLink",
                                 }
                             }
                         },
-                        "vnf":{
+                        "ns_vl": {
                             "destination": {
-                                "ns_vl": {
+                                "ns_cp": {
                                     "direct_edge": False,
-                                    "callback": "addLink",
-                                    "removable" : {
+                                    "removable": {
                                         "callback": "removeLink",
                                     }
+                                },
+                                "vnf": {
+                                    "direct_edge": False,
+                                    "callback": "addLink",
                                 }
                             }
                         },
-                        "ns_vl": {
+                        "ns_cp": {
                             "destination": {
+                                "ns_vl": {
+                                    "direct_edge": False,
+                                    "removable": {
+                                        "callback": "removeLink",
+                                    }
+                                },
                                 "vnf": {
                                     "direct_edge": False,
-                                    "callback": "addLink",
                                     "removable": {
                                         "callback": "removeLink",
                                     }
@@ -516,7 +544,15 @@ class OsmParser(RdclGraph):
                 if 'vnfd-connection-point-ref' in vld:
                     for cp_ref in vld['vnfd-connection-point-ref']:
                         vnfd_id = cp_ref['vnfd-id-ref'] + ':' + str(cp_ref['member-vnf-index-ref'])
-                        self.add_link(vld['id'], vnfd_id, 'nsd', None, graph)
+                        cp_id = vld['id']+ ':' + str(cp_ref['member-vnf-index-ref']) + ':' + cp_ref['vnfd-connection-point-ref']
+                        cp_label = vld['id']+ ':' + cp_ref['vnfd-connection-point-ref']
+                        node_payload = {'vld_id': vld['id']}
+                        node_payload.update(cp_ref)
+                        self.add_node(cp_id,'ns_cp',None,None,graph,
+                        {'property': {'custom_label': cp_label}, 'osm': node_payload})
+                        
+                        self.add_link(cp_id, vld['id'], 'nsd', None, graph)
+                        self.add_link(cp_id, vnfd_id, 'nsd', None, graph)
         return graph