def updateElement(request, descriptor_type=None, descriptor_id=None, element_type=None):
user = osmutils.get_user(request)
client = Client()
+ payload = request.POST.dict()
+ util = OsmUtil()
+
if descriptor_type == 'nsd':
descriptor_result = client.nsd_get(user.get_token(), descriptor_id)
- util = OsmUtil()
- payload = request.POST.dict()
- if element_type == 'graph_params':
- descriptor_updated = util.update_graph_params('nsd', descriptor_result, json.loads(payload['update']))
- else:
- descriptor_updated = util.update_node('nsd', descriptor_result, element_type, json.loads(payload['old']), json.loads(payload['update']))
- result = client.nsd_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 == 'nsd':
- result_graph = parser.nsd_to_graph(descriptor_updated)
- if descriptor_type == 'vnfd':
+ elif 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']))
+
+ if element_type == 'graph_params':
+ descriptor_updated = util.update_graph_params(descriptor_type, descriptor_result, json.loads(payload['update']))
+ else:
+ descriptor_updated = util.update_node(descriptor_type, descriptor_result, element_type, json.loads(payload['old']), json.loads(payload['update']))
+
+ if descriptor_type == 'nsd':
+ result = client.nsd_update(user.get_token(), descriptor_id, descriptor_updated)
+ elif descriptor_type == 'vnfd':
result = client.vnfd_update(user.get_token(), descriptor_id, descriptor_updated)
- if result['error'] == True:
+ 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)
-
+ else:
+ parser = OsmParser()
+ if descriptor_type == 'vnfd':
+ result_graph = parser.vnfd_to_graph(descriptor_updated)
+ elif descriptor_type == 'nsd':
+ result_graph = parser.nsd_to_graph(descriptor_updated)
return __response_handler(request, result_graph, url=None, status=200)
+
@login_required
def edit_descriptor(request, descriptor_id=None, descriptor_type=None):
user = osmutils.get_user(request)
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
"addable": {"callback": "addNode"},
"removable": {"callback": "removeNode"}
},
- "cp": {},
+ "ns_cp": {
+ "removable": {"callback": "removeNode"}
+ },
"ns_vl": {
"addable": {
"callback": "addNode"
}
},
"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",
}
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
str(item['member-vnf-index-ref']) != str(
args['member-vnf-index']) or str(
item['vnfd-id-ref']) != str(args['vnfd-id-ref'])]
- elif node_type == 'cp':
+ elif node_type == 'ns_cp':
for vld in nsd['vld']:
if vld['id'] == args['vld_id']:
vld['vnfd-connection-point-ref'] = [item for item in vld['vnfd-connection-point-ref'] if
var source_type = s.info.type;
var destination_type = d.info.type;
var current_layer = self.getCurrentView();
+ console.log(self.model.layer[current_layer])
if (self.model.layer[current_layer].allowed_edges && self.model.layer[current_layer].allowed_edges[source_type] && self.model.layer[current_layer].allowed_edges[source_type].destination[destination_type] &&
self.model.layer[current_layer].allowed_edges[source_type].destination[destination_type].removable
) {
var callback = self.model.layer[current_layer].allowed_edges[source_type].destination[destination_type].removable.callback;
var c = self.model.callback[callback].class;
var controller = new TCD3.OsmController();
- controller[callback](self, link, function () {
+ controller[callback](self, link, function (result) {
self._deselectAllNodes();
self._deselectAllLinks();
- self.parent.removeLink.call(self, link.index);
+
+ self.updateData(result);
+ // success && success();
success && success();
}, error);
} else {
var graph_editor = new TCD3.ModelGraphEditor();
var type_view = {
- "nsd": ["vnf", "ns_vl"],
+ "nsd": ["vnf", "ns_vl", "ns_cp"],
"vnfd": ["vdu", "cp", "vnf_vl", "int_cp"]
};
case 'int_cp':
intcpDetails(element.info.osm);
break;
+ case 'ns_cp':
+ nscpDetails(element.info.osm);
+ break;
case 'cp':
cpDetails(element.info.osm);
break;
side.append(cp_template);
}
+function nscpDetails(cp) {
+ var side = $('#side_form');
+ var cp_template = getMainSection('Connection Point');
+
+ cp_template += getChildrenTable(cp, true);
+ side.empty();
+ side.append(cp_template);
+}
+
function vlDetails(vl) {
var side = $('#side_form');
var vl_template = getMainSectionWithSubmitButton('Virtual Link');
var desc_type = getUrlParameter('type');
if (desc_type === 'nsd') {
- var element_type = 'cp';
+ var element_type = 'ns_cp';
var data_form = new FormData();
-
- var vnfd_node = (link.source.info.type === 'vnf') ? link.source : link.target;
- var vld_node = (link.source.info.type === 'ns_vl') ? link.source : link.target;
-
+ var ns_cp = (link.source.info.type === 'ns_cp') ? link.source : link.target;
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('member-vnf-index-ref', ns_cp.info.osm['member-vnf-index-ref']);
+ data_form.append('vnfd-id-ref', ns_cp.info.osm['vnfd-id-ref']);
+ data_form.append('vld_id', ns_cp.info.osm['vld_id']);
$.ajax({
url: '/projects/descriptors/' + desc_type + '/' + desc_id + '/removeElement/' + element_type,
};
var type_view = {
- "nsr": ["vnfr", "ns_vl"],
+ "nsr": ["vnfr", "ns_vl", "ns_cp"],
"vnfr": ["vdur", "cp", "vnf_vl"]
};
"height": 20,
"name": "VDU"
},
+ "ns_cp": {
+ //"image": "cp-80.png",
+ "shape": "square",
+ "color": "#3c8dbc",
+ "size": 20,
+ "name": "CP"
+ },
"cp": {
//"image": "cp-80.png",
"shape": "square",