vnfd composer fix missing node update
Change-Id: Ia5c84c19739fd8d611169bffefbc6e667e3eb35f
Signed-off-by: lombardofr <lombardo@everyup.it>
diff --git a/descriptorhandler/views.py b/descriptorhandler/views.py
index b6c2b2a..064b5a5 100644
--- a/descriptorhandler/views.py
+++ b/descriptorhandler/views.py
@@ -216,6 +216,22 @@
# print nsr_object
if descriptor_type == 'nsd':
result_graph = parser.nsd_to_graph(descriptor_updated)
+ if 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']))
+ 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()
+ if descriptor_type == 'vnfd':
+ result_graph = parser.vnfd_to_graph(descriptor_updated)
return __response_handler(request, result_graph, url=None, status=200)
diff --git a/lib/osm/osm_util.py b/lib/osm/osm_util.py
index f61e201..49be9df 100644
--- a/lib/osm/osm_util.py
+++ b/lib/osm/osm_util.py
@@ -72,6 +72,24 @@
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'
+ 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':
+ for k, v in enumerate(vnfd['internal-vld']):
+ if v['id'] == old['id']:
+ vnfd['internal-vld'][k].update(updated)
+ if node_type == 'cp':
+ for k, v in enumerate(vnfd['connection-point']):
+ if v['name'] == old['name']:
+ vnfd['connection-point'][k].update(updated)
+ if node_type == 'vdu':
+ for k, v in enumerate(vnfd['vdu']):
+ if v['name'] == old['name']:
+ vnfd['vdu'][k].update(updated)
return descriptor
@@ -196,5 +214,11 @@
elif 'nsd:nsd-catalog' in descriptor:
nsd = descriptor['nsd:nsd-catalog']['nsd'][0]
nsd.update(updated)
+ 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]
+ vnfd.update(updated)
return descriptor
diff --git a/projecthandler/template/project/osm/osm_project_descriptors.html b/projecthandler/template/project/osm/osm_project_descriptors.html
index 0957ba2..2491bf0 100644
--- a/projecthandler/template/project/osm/osm_project_descriptors.html
+++ b/projecthandler/template/project/osm/osm_project_descriptors.html
@@ -133,7 +133,7 @@
' data-toggle="tooltip" data-placement="top" title="Clone"\n' +
' onclick="javascript:clonePackage(\''+ descriptor_type +'\', \''+row["_id"]+'\')">\n' +
' <i class="fa fa-clone"></i></button>\n';
- if(descriptor_type == "nsd")
+ //if(descriptor_type == "nsd")
result += '<button type="button" class="btn btn-default" data-container="body"\n' +
' data-toggle="tooltip" data-placement="top" title="Show Graph"\n' +
' onclick="location.href=\'/projects/descriptors/composer?type='+descriptor_type+'&id='+row["_id"] +'\'"\n' +
diff --git a/static/TopologyComposer/js/graph_editor.js b/static/TopologyComposer/js/graph_editor.js
index 50e4f44..d8abcc8 100755
--- a/static/TopologyComposer/js/graph_editor.js
+++ b/static/TopologyComposer/js/graph_editor.js
@@ -347,7 +347,7 @@
* @returns {boolean}
*/
GraphEditor.prototype.addLink = function (link) {
- console.log("addLink" + JSON.stringify(link));
+
if (link.source && link.target) {
this.force.stop();
this.cleanAll();
diff --git a/static/src/descriptorhandler/composer.js b/static/src/descriptorhandler/composer.js
index 4b8bfd5..18072a8 100644
--- a/static/src/descriptorhandler/composer.js
+++ b/static/src/descriptorhandler/composer.js
@@ -193,6 +193,8 @@
vduDetails(element.info.osm);
break;
case 'int_cp':
+ intcpDetails(element.info.osm);
+ break;
case 'cp':
cpDetails(element.info.osm);
break;
@@ -311,6 +313,15 @@
side.append(vdur_template)
}
+function intcpDetails(cp) {
+ var side = $('#side_form');
+ var cp_template = getMainSection('Int. Connection Point');
+
+ cp_template += getChildrenTable(cp, true);
+ side.empty();
+ side.append(cp_template);
+}
+
function cpDetails(cp) {
var side = $('#side_form');
var cp_template = getMainSectionWithSubmitButton('Connection Point');