return __response_handler(request, result_graph, url=None, status=200)
+ elif descriptor_type == 'vnfd':
+ descriptor_result = client.vnfd_get(user.get_token(), descriptor_id)
+ element_id = request.POST.get('id', '')
+ util = OsmUtil()
+ descriptor_updated = util.remove_node('vnfd', descriptor_result, element_type, element_id, request.POST.dict())
+ result = client.vnfd_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 == 'vnfd':
+ result_graph = parser.vnfd_to_graph(descriptor_updated)
+
+ return __response_handler(request, result_graph, url=None, status=200)
+
@login_required
def updateElement(request, descriptor_type=None, descriptor_id=None, element_type=None):
user = osmutils.get_user(request)
}
},
"int_cp": {
- "addable": {
- "callback": "addNode"
- },
"removable": {
"callback": "removeNode"
}
"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": {}
}
}
}
"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]
"layer": {
"nsd": {
"nodes": {
- "vnf": {"addable": {
- "callback": "addNode"
- },
- "removable": {
- "callback": "removeNode"
- }},
+ "vnf": {
+ "addable": {"callback": "addNode"},
+ "removable": {"callback": "removeNode"}
+ },
"cp": {},
"ns_vl": {
"addable": {
if node_type == 'cp':
for vld in nsd['vld']:
if vld['id'] == args['vld_id']:
- if'vnfd-connection-point-ref' not in vld:
+ if 'vnfd-connection-point-ref' not in vld:
vld['vnfd-connection-point-ref'] = []
vld['vnfd-connection-point-ref'].append(
{
"ip-profile-ref": "",
"id": element_id
})
-
+ if node_type == 'interface':
+ for vdu in vnfd['vdu']:
+ if vdu['id'] == args['vdu-id']:
+ vdu['interface'].append({
+ "virtual-interface": {
+ "type": "VIRTIO"
+ },
+ "name": element_id,
+ "mgmt-interface": True,
+ "type": "EXTERNAL",
+ "external-connection-point-ref": args["external-connection-point-ref"]
+ })
return descriptor
@staticmethod
nsd = descriptor['nsd:nsd-catalog']['nsd'][0]
nsd.update(updated)
- return descriptor
\ No newline at end of file
+ return descriptor
error: error
});
}
+ else if (desc_type === 'vnfd') {
+ if (['vdu', 'cp'].indexOf(link.source.info.type) > -1 && ['vdu', 'cp'].indexOf(link.target.info.type) > -1) {
+ var vdu_node = (link.source.info.type === 'vdu') ? link.source : link.target;
+ var cp_node = (link.source.info.type === 'cp') ? link.source : link.target;
+
+ var data_form = new FormData();
+ data_form.append('csrfmiddlewaretoken', getCookie('csrftoken'));
+ 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',
+ type: 'POST',
+ data: data_form,
+ cache: false,
+ contentType: false,
+ processData: false,
+ success: success,
+ error: error
+ });
+ }
+ 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;
+
+ 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']);
+
+ $.ajax({
+ url: '/projects/descriptors/' + desc_type + '/' + desc_id + '/addElement/' + element_type,
+ type: 'POST',
+ data: data_form,
+ cache: false,
+ contentType: false,
+ processData: false,
+ success: success,
+ error: error
+ });*/
+ }
+
+ }
+
};
console.log(args)
var data_form = new FormData();
data_form.append('csrfmiddlewaretoken', getCookie('csrftoken'));
- data_form.append('old', JSON.stringify( node.info.osm));
+ data_form.append('old', JSON.stringify(node.info.osm));
data_form.append('update', JSON.stringify(args));
/*for (var key in node.info.osm) {
data_form.append(key, node.info.osm[key]);
};
- OsmController.prototype.updateGraphParams = function(args, success, error){
+ OsmController.prototype.updateGraphParams = function (args, success, error) {
var desc_id = getUrlParameter('id');
var desc_type = getUrlParameter('type');
var data_form = new FormData();