1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +03:00

Feature #2858: New vnet methods in sunstone api

This commit is contained in:
Carlos Martín 2014-05-28 18:29:57 +02:00
parent 15d096885d
commit 822ef4d113
8 changed files with 68 additions and 84 deletions

View File

@ -341,10 +341,11 @@ tabs:
Network.chgrp: true
Network.chmod: true
Network.delete: true
Network.addleases: true
Network.hold_lease: true
Network.remove_lease: true
Network.release_lease: true
Network.add_ar: true
Network.remove_ar: true
Network.update_ar: true
marketplace-tab:
panel_tabs:
marketplace_info_tab: true

View File

@ -338,10 +338,11 @@ tabs:
Network.chgrp: false
Network.chmod: true
Network.delete: false
Network.addleases: false
Network.hold_lease: false
Network.remove_lease: false
Network.release_lease: false
Network.add_ar: false
Network.remove_ar: false
Network.update_ar: false
marketplace-tab:
panel_tabs:
marketplace_info_tab: true

View File

@ -341,10 +341,11 @@ tabs:
Network.chgrp: false
Network.chmod: true
Network.delete: false
Network.addleases: false
Network.hold_lease: false
Network.remove_lease: false
Network.release_lease: false
Network.add_ar: false
Network.remove_ar: false
Network.update_ar: false
marketplace-tab:
panel_tabs:
marketplace_info_tab: true

View File

@ -338,10 +338,11 @@ tabs:
Network.chgrp: false
Network.chmod: true
Network.delete: false
Network.addleases: false
Network.hold_lease: false
Network.remove_lease: false
Network.release_lease: false
Network.add_ar: false
Network.remove_ar: false
Network.update_ar: false
marketplace-tab:
panel_tabs:
marketplace_info_tab: true

View File

@ -341,10 +341,11 @@ tabs:
Network.chgrp: false
Network.chmod: false
Network.delete: false
Network.addleases: false
Network.hold_lease: false
Network.remove_lease: false
Network.release_lease: false
Network.add_ar: false
Network.remove_ar: false
Network.update_ar: false
marketplace-tab:
panel_tabs:
marketplace_info_tab: true

View File

@ -42,8 +42,6 @@ module OpenNebulaJSON
end
rc = case action_hash['perform']
when "addleases" then self.addleases(action_hash['params'])
when "rmleases" then self.rmleases(action_hash['params'])
when "publish" then self.publish
when "unpublish" then self.unpublish
when "update" then self.update(action_hash['params'])
@ -53,6 +51,8 @@ module OpenNebulaJSON
when "release" then self.release(action_hash['params'])
when "rename" then self.rename(action_hash['params'])
when "rm_ar" then self.rm_ar(action_hash['params'])
when "add_ar" then self.add_ar(action_hash['params'])
when "update_ar" then self.update_ar(action_hash['params'])
else
error_msg = "#{action_hash['perform']} action not " <<
" available for this resource"
@ -60,14 +60,6 @@ module OpenNebulaJSON
end
end
def addleases(params=Hash.new)
super(params['ip'],params['mac'])
end
def rmleases(params=Hash.new)
super(params['ip'])
end
def update(params=Hash.new)
super(params['template_raw'])
end
@ -95,5 +87,13 @@ module OpenNebulaJSON
def rm_ar(params=Hash.new)
super(params['ar_id'])
end
def add_ar(params=Hash.new)
super(params['ar_template_raw'])
end
def update_ar(params=Hash.new)
super(params['ar_template_raw'])
end
end
end

View File

@ -767,20 +767,6 @@ var OpenNebula = {
"unpublish": function(params){
OpenNebula.Action.simple_action(params,OpenNebula.Network.resource,"unpublish");
},
"addleases" : function(params){
var action_obj = params.data.extra_param;
OpenNebula.Action.simple_action(params,
OpenNebula.Network.resource,
"addleases",
action_obj);
},
"rmleases" : function(params){
var action_obj = params.data.extra_param;
OpenNebula.Action.simple_action(params,
OpenNebula.Network.resource,
"rmleases",
action_obj);
},
"hold" : function(params){
var action_obj = params.data.extra_param;
OpenNebula.Action.simple_action(params,
@ -795,6 +781,13 @@ var OpenNebula = {
"release",
action_obj);
},
"add_ar" : function(params){
var action_obj = {"ar_template_raw" : params.data.extra_param };
OpenNebula.Action.simple_action(params,
OpenNebula.Network.resource,
"add_ar",
action_obj);
},
"rm_ar" : function(params){
var action_obj = params.data.extra_param;
OpenNebula.Action.simple_action(params,
@ -802,6 +795,13 @@ var OpenNebula = {
"rm_ar",
action_obj);
},
"update_ar": function(params){
var action_obj = {"ar_template_raw" : params.data.extra_param };
OpenNebula.Action.simple_action(params,
OpenNebula.Network.resource,
"update_ar",
action_obj);
},
"update": function(params){
var action_obj = {"template_raw" : params.data.extra_param };
OpenNebula.Action.simple_action(params,

View File

@ -401,24 +401,6 @@ var vnet_actions = {
error: onError
},
"Network.addleases" : {
type: "single",
call: OpenNebula.Network.addleases,
callback: function(req) {
Sunstone.runAction("Network.show",req.request.data[0][0]);
},
error: onError
},
"Network.rmleases" : {
type: "single",
call: OpenNebula.Network.rmleases,
callback: function(req) {
Sunstone.runAction("Network.show",req.request.data[0][0]);
},
error: onError
},
"Network.hold" : {
type: "single",
call: OpenNebula.Network.hold,
@ -437,6 +419,15 @@ var vnet_actions = {
error: onError
},
"Network.add_ar" : {
type: "single",
call: OpenNebula.Network.add_ar,
callback: function(req) {
Sunstone.runAction("Network.show",req.request.data[0][0]);
},
error: onError
},
"Network.rm_ar" : {
type: "single",
call: OpenNebula.Network.rm_ar,
@ -446,6 +437,15 @@ var vnet_actions = {
error: onError
},
"Network.update_ar" : {
type: "single",
call: OpenNebula.Network.update_ar,
callback: function(req) {
Sunstone.runAction("Network.show",req.request.data[0][0]);
},
error: onError
},
"Network.chown" : {
type: "multiple",
call: OpenNebula.Network.chown,
@ -836,11 +836,17 @@ function printLeases(vn_info){
html +=
'</tbody>\
</table>\
<div class="large-12 columns text-center">\
</table>';
if (Config.isTabActionEnabled("vnets-tab", "Network.remove_ar")) {
html +=
'<div class="large-12 columns text-center">\
<button class="button small radius" id="rm_ar_button">'+tr("Remove Address Range")+'</button>\
</div>\
</div>\
</div>';
}
html +=
'</div>\
</div>';
// TODO: extra ar config attributes
@ -1327,19 +1333,6 @@ function popUpCreateVnetDialog() {
// Listeners to the add, hold, release, delete leases operations in the
// extended information panel.
function setupLeasesOps(){
if (Config.isTabActionEnabled("vnets-tab", "Network.addleases")) {
$('button#panel_add_lease_button').live("click",function(){
var lease = $('input#panel_add_lease').val();
//var mac = $(this).previous().val();
var id = $(this).parents('form').attr('vnid');
if (lease.length){
var obj = {ip: lease};
Sunstone.runAction('Network.addleases',id,obj);
}
return false;
});
}
if (Config.isTabActionEnabled("vnets-tab", "Network.hold_lease")) {
//ranged networks hold lease
$('button#panel_hold_lease_button').live("click",function(){
@ -1365,20 +1358,6 @@ function setupLeasesOps(){
});
}
if (Config.isTabActionEnabled("vnets-tab", "Network.remove_lease")) {
$('form#leases_form a.delete_lease').live("click",function(){
var lease = $(this).parents('tr').attr('ip');
var id = $(this).parents('form').attr('vnid');
var obj = { ip: lease};
Sunstone.runAction('Network.rmleases',id,obj);
//Set spinner
$(this).parents('tr').html('<td class="key_td">'+spinner+'</td><td class="value_td"></td>');
return false;
});
}
if (Config.isTabActionEnabled("vnets-tab", "Network.release_lease")) {
$('a.release_lease').live("click",function(){
var lease = $(this).parents('tr').attr('ip');
@ -1391,7 +1370,7 @@ function setupLeasesOps(){
});
}
if (Config.isTabActionEnabled("vnets-tab", "Network.remove_lease")) {
if (Config.isTabActionEnabled("vnets-tab", "Network.remove_ar")) {
$('button#rm_ar_button').live("click",function(){
// TODO: confirm?
var id = $(this).parents('form').attr('vnid');