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
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
})
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"
"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
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') {
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',
}
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,
processData: false,
success: success,
error: error
- });*/
+ });
}
}