{% block nav_buttons_list %}
{{ block.super }}
<li class="pull-right"><button id="save" type="button" class="btn btn-block btn-primary btn-sm" onclick="update(this.id)" ><i class="fa fa-save"></i> Update</button></li>
- <li class="pull-right"><button id="save_show_graph" type="button" class="btn btn-block btn-primary btn-sm" onclick="update(this.id)" disabled><i class="fa fa-save"></i> Update and Show Graph</button></li>
- <li class="pull-right"><button type="button" class="btn btn-block btn-primary btn-sm" onclick="goToGraph()" disabled><i class="fa fa-sitemap"></i> Show Graph</button></li>
+ <li class="pull-right"><button id="save_show_graph" type="button" class="btn btn-block btn-primary btn-sm" onclick="update(this.id, 'true')"><i class="fa fa-save"></i> Update and Show Graph</button></li>
+ <li class="pull-right"><button type="button" class="btn btn-block btn-primary btn-sm" onclick="goToGraph()"><i class="fa fa-sitemap"></i> Show Graph</button></li>
{% endblock %}
});
- function update(e) {
+ function update(e, show_graph) {
var dialog = bootbox.dialog({
message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Loading...</div>',
closeButton: false
'text': text
},
success: function (result) {
+ if(show_graph){
+ goToGraph();
+ }
dialog.modal('hide');
$("#success-alert").fadeTo(2000, 500).slideDown(500, function(){
setTimeout(function () {
});
},
error: function (result) {
- console.log(result);
dialog.modal('hide');
- bootbox.alert(result);
+ var data = result.responseJSON;
+ var title = "Error " + (data && data.code ? data.code : 'unknown');
+ var message = data && data.detail ? data.detail : 'No detail available.';
+ bootbox.alert({
+ title: title,
+ message: message
+ });
}
});
}
function goToGraph() {
- window.location.href = '/projects/graph?type={{descriptor_type}}&id={{descriptor_id}}'
+ window.location.href = '/projects/descriptors/composer?type={{descriptor_type}}&id={{descriptor_id}}'
}
</script>
{% endblock %}
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)
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'] != args['name']]
+ if vnfd['mgmt-interface']['cp'] == args['name']:
+ del vnfd['mgmt-interface']['cp']
for vdu in vnfd['vdu']:
if 'interface' in vdu:
vdu['interface'] = [item for item in vdu['interface'] if 'external-connection-point-ref' not in item
for k, v in enumerate(vnfd['connection-point']):
if v['name'] == old['name']:
vnfd['connection-point'][k].update(updated)
+ for vdu in vnfd['vdu']:
+ if 'interface' in vdu:
+ for intf in vdu['interface']:
+ if 'external-connection-point-ref' in intf and intf['external-connection-point-ref'] == old['name']:
+ intf['external-connection-point-ref'] = updated['name']
if node_type == 'vdu':
for k, v in enumerate(vnfd['vdu']):
if v['name'] == old['name']:
"virtual-interface": {
"type": "VIRTIO"
},
- "name": element_id,
+ "name": args["name"],
"mgmt-interface": True,
"type": "EXTERNAL",
"external-connection-point-ref": args["external-connection-point-ref"]
try:
self._create_base_pkg('nsd', pkg_name)
+ headers['Content-Filename'] = pkg_name + '.tar.gz'
r = requests.post(_url, data=open('/tmp/' + pkg_name + '.tar.gz', 'rb'), verify=False, headers=headers)
except Exception as e:
log.exception(e)
return result
if r.status_code == requests.codes.no_content:
result['error'] = False
+ else:
+ try:
+ result['data'] = r.json()
+ except Exception as e:
+ result['data'] = {}
return result
return result
if r.status_code == requests.codes.no_content:
result['error'] = False
+ else:
+ try:
+ result['data'] = r.json()
+ except Exception as e:
+ result['data'] = {}
return result
"short-name": str(pkg_name),
"vdu": [],
"description": "",
- "mgmt-interface": {},
+ "mgmt-interface": {
+ "cp": ""
+ },
"id": str(pkg_name),
"version": "1.0",
"internal-vld": [],
* @returns {boolean}
*/
ModelGraphEditor.prototype.updateGraphParams = function (args, success, error) {
+ var self = this;
var controller = new TCD3.OsmController();
- controller.updateGraphParams(args, function(){
+ controller.updateGraphParams(args, function(result){
+ self.updateData(result);
success && success();
}, error);
};
if (self.model.layer[current_layer].nodes[node_type].removable.callback) {
var c = self.model.callback[self.model.layer[current_layer].nodes[node_type].removable.callback].class;
var controller = new TCD3.OsmController();
- controller[self.model.layer[current_layer].nodes[node_type].removable.callback](self, node, function () {
- self.parent.removeNode.call(self, node);
+ controller[self.model.layer[current_layer].nodes[node_type].removable.callback](self, node, function (result) {
+ self._deselectAllNodes();
+ self.updateData(result);
success && success();
}, error);
} else {
link.directed_edge = direct_edge;
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.parent.addLink.call(self, link);
- if (success)
- success();
+ self.updateData(result);
+ success && success();
}, error);
} else {
log('addLink: callback undefined in model spec.');
graph_editor.addNode(node_information, function () {
console.log("OK")
- }, function (error) {
- showAlert(error)
+ }, function (result) {
+ var data = result.responseJSON;
+ var title = "Error " + (data && data.code ? data.code : 'unknown');
+ var message = data && data.detail ? data.detail : 'No detail available.';
+ bootbox.alert({
+ title: title,
+ message: message
+ });
})
};
palette.append(palette_template)
},
error: function (result) {
- showAlert(result);
+ var data = result.responseJSON;
+ var title = "Error " + (data && data.code ? data.code : 'unknown');
+ var message = data && data.detail ? data.detail : 'No detail available.';
+ bootbox.alert({
+ title: title,
+ message: message
+ });
}
});
}
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;
+ bootbox.prompt("Please insert the vnfd-connection-point-ref:", function(result){
+ if (result){
+ data_form.append('csrfmiddlewaretoken', getCookie('csrftoken'));
+ data_form.append('vnfd-connection-point-ref', result);
+ 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
+ });
+ }
- 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
});
+
+
}
else if (desc_type === 'vnfd') {
if (['vdu', 'cp'].indexOf(link.source.info.type) > -1 && ['vdu', 'cp'].indexOf(link.target.info.type) > -1) {
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);
+ data_form.append('name', "eth_" + generateUID());
$.ajax({
url: '/projects/descriptors/' + desc_type + '/' + desc_id + '/addElement/interface',
type: 'POST',
var vld_node = (link.source.info.type === 'ns_vl') ? link.source : link.target;
data_form.append('csrfmiddlewaretoken', getCookie('csrftoken'));
- data_form.append('vnfd-connection-point-ref', 'cp_temp');
+ //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']);
"vdur": {
"shape": "square",
"color": "#cf1c24",
- "size": 60,
+ "size": 40,
"name": "VDUR"
},
"vnfr": {
"shape": "square",
"color": "#605ca8",
- "size": 60,
+ "size": 40,
"name": "VNFR"
},