Commit 0c0e68f1 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

ui: Update firewall profile API calls

using port ids in action parameters
parent 308d6da5
......@@ -1347,7 +1347,16 @@
}
return synnefo.config.ui_console_url + '?' + $.param(url_params);
},
set_firewall: function(nic, value, success_cb, error_cb) {
var success = function() { success_cb() }
var error = function() { error_cb() }
var data = {'nic': nic.id, 'profile': value, 'display': true};
var url = this.url() + "/action";
//var params = {skip_api_error: false, display: true};
this.call('firewallProfile', success, error, data);
},
connect_floating_ip: function(ip, cb) {
this.set({'status': 'CONNECTING'});
synnefo.storage.ports.create({
......@@ -1452,6 +1461,16 @@
},
error, 'destroy', params);
break;
case 'firewallProfile':
this.__make_api_call(this.get_action_url(), // vm actions url
"create",
{firewallProfile:{nic:params.nic, profile:params.profile}}, // payload
function() {
success.apply(this, arguments);
snf.api.trigger("call");
},
error, 'start', params);
break;
default:
throw "Invalid VM action ("+action_name+")";
}
......
......@@ -399,19 +399,6 @@
],
},
set_firewall: function(value, callback, error, options) {
// MOCK CALL
window.setTimeout(_.bind(function() {
var vm = this.get('vm');
var attachments = [];
attachments.push({id: this.id, firewallProfile: value});
vm.set({attachments: attachments});
}, this), 2000);
window.setTimeout(_.bind(function() {
callback();
}), 300);
},
disconnect: function(cb) {
var network = this.get('network');
var vm = this.get('vm');
......
......@@ -107,7 +107,7 @@
// appends global ajax handlers
// handles changed-since url parameter based on api path
api.sync = function(method, model, options) {
var type = methodMap[method];
if (model && (model.skipMethods || []).indexOf(method) >= 0) {
......
......@@ -332,12 +332,23 @@
set_firewall: function() {
var value = this.get_selected_value();
this.firewall_apply.addClass("in-progress");
var vm = this.model.get('vm');
if (!vm) { return }
this.model.set({'pending_firewall': value});
this.model.set_firewall(value, this.set_firewall_complete,
this.set_firewall_complete);
vm.set_firewall(this.model, value, this.set_firewall_success,
this.set_firewall_error)
this.in_progress = true;
},
set_firewall_success: function() {
this.set_firewall_complete();
},
set_firewall_error: function() {
this.model.set({'pending_firewall': undefined});
this.set_firewall_complete();
},
set_firewall_complete: function() {
this.in_progress = false;
this.toggle_firewall({}, false, _.bind(function() {
......@@ -945,8 +956,7 @@
complete: function() {
synnefo.storage.quotas.fetch();
self.reset_creating();
},
skip_api_error: true
}
});
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment