diff --git a/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb b/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb
index 6cc98c0404..3ab1f957c7 100644
--- a/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb
+++ b/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb
@@ -65,6 +65,7 @@ module OpenNebulaJSON
when "attachdisk" then self.attachdisk(action_hash['params'])
when "detachdisk" then self.detachdisk(action_hash['params'])
when "update" then self.update(action_hash['params'])
+ when "rename" then self.rename(action_hash['params'])
else
error_msg = "#{action_hash['perform']} action not " <<
" available for this resource"
@@ -113,5 +114,9 @@ module OpenNebulaJSON
def update(params=Hash.new)
super(params['template_raw'])
end
+
+ def rename(params=Hash.new)
+ super(params['name'])
+ end
end
end
diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js
index 4da64bd64e..16c4d86fa7 100644
--- a/src/sunstone/public/js/opennebula.js
+++ b/src/sunstone/public/js/opennebula.js
@@ -732,6 +732,13 @@ var OpenNebula = {
var action_obj = {"disk_id": params.data.extra_param};
OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,
"detachdisk",action_obj);
+ },
+ "rename" : function(params){
+ var action_obj = params.data.extra_param;
+ OpenNebula.Action.simple_action(params,
+ OpenNebula.VM.resource,
+ "rename",
+ action_obj);
}
},
diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js
index 64715a6e48..ac0472de66 100644
--- a/src/sunstone/public/js/plugins/vms-tab.js
+++ b/src/sunstone/public/js/plugins/vms-tab.js
@@ -127,54 +127,6 @@ var create_vm_tmpl ='
';
-var update_vm_tmpl =
- '';
-
var vmachine_list_json = {};
var dataTable_vMachines;
var $create_vm_dialog;
@@ -197,11 +149,6 @@ var vm_actions = {
call: popUpCreateVMDialog
},
- "VM.update_dialog" : {
- type: "custom",
- call: popUpVMTemplateUpdateDialog
- },
-
"VM.list" : {
type: "list",
call: OpenNebula.VM.list,
@@ -450,16 +397,7 @@ var vm_actions = {
error: onError,
notify: true
},
- "VM.fetch_permissions" : {
- type: "single",
- call: OpenNebula.VM.show,
- callback : function(request, vm_json){
- var dialog = $('#vm_template_update_dialog form');
- var vm = vm_json.VM;
- setPermissionsTable(vm,dialog);
- },
- error: onError
- },
+
"VM.chmod" : {
type: "single",
call: OpenNebula.VM.chmod,
@@ -490,6 +428,18 @@ var vm_actions = {
}
},
+ "VM.rename" : {
+ type: "single",
+ call: OpenNebula.VM.rename,
+ callback: function(request) {
+ notifyMessage("VirtualMachine renamed correctly");
+ Sunstone.runAction('VM.showinfo',request.request.data[0]);
+ Sunstone.runAction("VM.list");
+ },
+ error: onError,
+ notify: true
+ },
+
"VM.update_template" : { // Update template
type: "single",
call: OpenNebula.VM.update,
@@ -516,12 +466,6 @@ var vm_buttons = {
alwaysActive: true
},
- "VM.update_dialog" : {
- type: "action",
- text: tr("Update properties"),
- alwaysActive: true
- },
-
"VM.chown" : {
type: "confirm_with_select",
text: tr("Change owner"),
@@ -985,10 +929,14 @@ function updateVMInfo(request,vm){
'+tr("ID")+' | \
'+vm_info.ID+' | \
\
- \
- | '+tr("Name")+' | \
- '+vm_info.NAME+' | \
-
\
+ \
+ | '+tr("Name")+' | \
+ '+vm_info.NAME+' | \
+ \
+ | \
+
\
\
| '+tr("Owner")+' | \
'+vm_info.UNAME+' | \
@@ -1080,6 +1028,25 @@ function updateVMInfo(request,vm){
content: generateHistoryTable(vm_info)
};
+ $("#div_edit_rename_link").die();
+ $(".input_edit_value_rename").die();
+
+ // Listener for key,value pair edit action
+ $("#div_edit_rename_link").live("click", function() {
+ var value_str = $(".value_td_rename").text();
+ $(".value_td_rename").html('');
+ });
+
+ $(".input_edit_value_rename").live("change", function() {
+ var value_str = $(".input_edit_value_rename").val();
+ if(value_str!="")
+ {
+ // Let OpenNebula know
+ var name_template = {"name": value_str};
+ Sunstone.runAction("VM.rename",vm_info.ID,name_template);
+ }
+ });
+
Sunstone.updateInfoPanelTab("vm_info_panel","vm_info_tab",info_tab);
Sunstone.updateInfoPanelTab("vm_info_panel","vm_hotplugging_tab",hotplugging_tab);
Sunstone.updateInfoPanelTab("vm_info_panel","vm_template_tab",template_tab);
@@ -1375,98 +1342,6 @@ function popUpCreateVMDialog(){
$create_vm_dialog.dialog('open');
}
-function setupVMTemplateUpdateDialog(){
- //Append to DOM
- dialogs_context.append('');
- var dialog = $('#vm_template_update_dialog',dialogs_context);
-
- //Put HTML in place
- dialog.html(update_vm_tmpl);
-
- var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window
-
- //Convert into jQuery
- dialog.dialog({
- autoOpen:false,
- width:500,
- modal:true,
- height:height,
- resizable:true
- });
-
- $('button',dialog).button();
-
- $('#vm_template_update_select',dialog).change(function(){
- var id = $(this).val();
- $('.permissions_table input',dialog).removeAttr('checked');
- $('.permissions_table',dialog).removeAttr('update');
- if (id && id.length){
- var dialog = $('#vm_template_update_dialog');
- Sunstone.runAction("VM.fetch_permissions",id);
- };
- });
-
- $('.permissions_table input',dialog).change(function(){
- $(this).parents('table').attr('update','update');
- });
-
- $('form',dialog).submit(function(){
- var dialog = $(this);
- var id = $('#vm_template_update_select',dialog).val();
- if (!id || !id.length) {
- $(this).parents('#vm_template_update_dialog').dialog('close');
- return false;
- };
-
- var permissions = $('.permissions_table',dialog);
- if (permissions.attr('update')){
- var perms = {
- octet : buildOctet(permissions)
- };
- Sunstone.runAction("VM.chmod",id,perms);
- };
-
- $(this).parents('#vm_template_update_dialog').dialog('close');
- return false;
- });
-};
-
-function popUpVMTemplateUpdateDialog(){
- var select = makeSelectOptions(dataTable_vMachines,
- 1,//id_col
- 4,//name_col
- [],
- []
- );
- var sel_elems = getSelectedNodes(dataTable_vMachines);
-
-
- var dialog = $('#vm_template_update_dialog');
- $('#vm_template_update_select',dialog).html(select);
- $('#vm_template_update_textarea',dialog).val("");
- $('.permissions_table input',dialog).removeAttr('checked');
- $('.permissions_table',dialog).removeAttr('update');
-
- if (sel_elems.length >= 1){ //several items in the list are selected
- //grep them
- var new_select= sel_elems.length > 1? '' : "";
- $('option','').each(function(){
- var val = $(this).val();
- if ($.inArray(val,sel_elems) >= 0){
- new_select+='';
- };
- });
- $('#vm_template_update_select',dialog).html(new_select);
- if (sel_elems.length == 1) {
- $('#vm_template_update_select option',dialog).attr('selected','selected');
- $('#vm_template_update_select',dialog).trigger("change");
- };
- };
-
- dialog.dialog('open');
- return false;
-};
-
//Prepares autorefresh
function setVMAutorefresh(){
setInterval(function(){
@@ -1639,7 +1514,6 @@ $(document).ready(function(){
Sunstone.runAction("VM.list");
setupCreateVMDialog();
- setupVMTemplateUpdateDialog();
setVMAutorefresh();
setupVNC();
hotpluggingOps();
diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js
index 9df754f66e..153c5b0e04 100644
--- a/src/sunstone/public/js/plugins/vnets-tab.js
+++ b/src/sunstone/public/js/plugins/vnets-tab.js
@@ -361,6 +361,7 @@ var vnet_actions = {
callback: function(request) {
notifyMessage("VirtualNetwork renamed correctly");
Sunstone.runAction('Network.showinfo',request.request.data[0]);
+ Sunstone.runAction("Network.list");
},
error: onError,
notify: true