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.add_base_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 removeElement(request, descriptor_type=None, descriptor_id=None, element_type=None):
user = osmutils.get_user(request)
"layer": {
"vnfd": {
"nodes": {
- "vdu": {},
- "cp": {},
- "int_cp": {},
+ "vdu": {
+ "addable": {
+ "callback": "addNode"
+ },
+ "removable": {
+ "callback": "removeNode"
+ }
+ },
+ "cp": {
+ "addable": {
+ "callback": "addNode"
+ },
+ "removable": {
+ "callback": "removeNode"
+ }
+ },
+ "int_cp": {
+ "addable": {
+ "callback": "addNode"
+ },
+ "removable": {
+ "callback": "removeNode"
+ }
+ },
"vnf_vl": {
"addable": {
"callback": "addNode"
},
"int_cp": {
"direct_edge": False,
- },
- "vnf_vl": {
- "direct_edge": False,
}
}
},
},
"vnf_vl": {
"destination": {
- "vdu": {
+ "int_cp": {
"direct_edge": False
}
}
str(item['member-vnf-index-ref']) != str(
args['member-vnf-index-ref']) or str(
item['vnfd-id-ref']) != str(args['vnfd-id-ref'])]
+ elif descriptor_type == 'vnfd':
+ if 'vnfd-catalog' in descriptor:
+ vnfd = descriptor['vnfd-catalog']['vnfd'][0]
+ elif 'vnfd:vnfd-catalog' in descriptor:
+ vnfd = descriptor['vnfd:vnfd-catalog']['vnfd'][0]
+
+ 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]
return descriptor
"vnfd-id-ref": args['vnfd-id-ref']
},
)
+
+ elif descriptor_type == 'vnfd':
+ if 'vnfd-catalog' in descriptor:
+ vnfd = descriptor['vnfd-catalog']['vnfd'][0]
+ elif 'vnfd:vnfd-catalog' in descriptor:
+ vnfd = descriptor['vnfd:vnfd-catalog']['vnfd'][0]
+ if node_type == 'vdu':
+ vnfd['vdu'].append({
+ "count": "1",
+ "description": "",
+ "monitoring-param": [],
+ "internal-connection-point": [],
+ "image": "ubuntu",
+ "cloud-init-file": "",
+ "vm-flavor": {},
+ "interface": [],
+ "id": element_id,
+ "name": element_id
+ })
+ if node_type == 'cp':
+ vnfd['connection-point'].append({
+ "type": "VPORT",
+ "name": element_id
+ })
+
+ if node_type == 'vnf_vl':
+ vnfd['internal-vld'].append({
+ "short-name": element_id,
+ "name": element_id,
+ "internal-connection-point": [],
+ "type": "ELAN",
+ "ip-profile-ref": "",
+ "id": element_id
+ })
+
return descriptor
@staticmethod
var nodetype = $('#' + elemet_id).attr('type-name');
var random_name = nodetype + "_" + generateUID();
-
+ console.log(nodetype)
var node_information = {
'id': random_name,
'info': {
'x': e.layerX,
'y': e.layerY
};
- if (nodetype === 'ns_vl') {
- graph_editor.addNode(node_information, function () {
- console.log("OK")
- }, function (error) {
- showAlert(error)
- })
- } else if (nodetype === 'vnf') {
+ if (nodetype === 'vnf') {
node_information['id'] = $('#' + elemet_id).attr('desc_id');
- graph_editor.addNode(node_information, function () {
- console.log("OK")
- }, function (error) {
- showAlert(error)
- })
}
+
+ graph_editor.addNode(node_information, function () {
+ console.log("OK")
+ }, function (error) {
+ showAlert(error)
+ })
+
};
dropZone.ondragover = function (ev) {
var node = nodes[n];
if (nodes_properties[node]) {
palette_template += '<div id="drag_' + n + '" class="node ui-draggable"' +
- 'type-name="' + n + '" draggable="true" ondragstart="nodeDragStart(event)">' +
+ 'type-name="' + node + '" draggable="true" ondragstart="nodeDragStart(event)">' +
'<div class="icon" style="background-color:' + nodes_properties[node].color + '"></div>' +
'<div class="name">' + nodes_properties[node].name + '</div></div>';
}