'+
'
'+
@@ -1330,254 +1570,15 @@ function setupCreateTemplateDialog(){
// Set ups the capacity section
var add_capacityTab = function(){
var html_tab_content = '
'+
- ''+
- '
'+
- ''+tr("NAME")+': '+
- '
'+
- '
'+
- ' '+
- '
'+
- '
'+
- '
'+tr("Name that the VM will get for description purposes. If NAME is not supplied a name generated by one will be in the form of one-<VID>.")+'
'+
- '
'+
- '
'+
- ' '+
- ' '+
- ''+
- '
'+
- ''+tr("CPU")+': '+
- '
'+
- '
'+
- '
'+
- ' '+
- '
'+
- '
'+
- '
'+tr("Percentage of CPU divided by 100 required for the Virtual Machine. Half a processor is written 0.5.")+'
'+
- '
'+
- '
'+
- ''+
- ' '+
- '
'+
- ''+
- '
'+
- ''+tr("MEMORY")+': '+
- '
'+
- '
'+
- '
'+
- ' '+
- '
'+
- '
'+
- ''+
- ''+tr("MB")+' '+
- ''+tr("GB")+' '+
- ' '+
- '
'+
- '
'+
- '
'+tr("Amount of RAM required for the VM, in Megabytes.")+'
'+
- '
'+
- '
'+
- ''+
- '
'+tr("Advanced options")+''+
- '
'+
- ''+
- '
'+
- '
'+
- ''+tr("VCPU")+': '+
- '
'+
- '
'+
- '
'+
- ' '+
- '
'+
- '
'+
- '
'+tr("Number of virtual cpus. This value is optional, the default hypervisor behavior is used, usually one virtual CPU.")+'
'+
- '
'+
- '
'+
- '
'+
+ generate_capacity_tab_content() +
' '
$("
General ").appendTo($("dl#template_create_tabs"));
$(html_tab_content).appendTo($("ul#template_create_tabs_content"));
- setupTips(dialog);
- // Enhace buttons
- //$('button',dialog).button();
-
- // Change tab if the DISKs button is clicked
- //$(".tf_btn_nics", dialog).click(add_nic_tab);
- //$(".tf_btn_nics").live('click', add_nic_tab);
-
- // Hide advanced options
- $('.advanced',section_capacity).hide();
-
- $('#advanced_capacity',section_capacity).click(function(){
- $('.advanced',section_capacity).toggle();
- return false;
- });
-
- // Define the cpu slider
-
- var cpu_input = $( "#CPU", section_capacity );
-
- var cpu_slider = $( "#cpu_slider").noUiSlider('init', {
- handles: 1,
- connect: "lower",
- scale: [0,800],
-// start: 100,
- step: 50,
- change: function(type) {
- if ( type != "move")
- {
- var values = $(this).noUiSlider( 'value' );
-
- cpu_input.val(values[1] / 100);
- }
- },
- });
-
- cpu_slider.addClass("noUiSlider");
-
- cpu_input.change(function() {
- cpu_slider.noUiSlider('move',{
- to: this.value * 100
- })
- });
-
- cpu_input.val(1);
-
- // init::start is ignored for some reason
- cpu_slider.noUiSlider('move',{to: 100});
-
-
- // Define the memory slider
-
- var final_memory_input = $( "#MEMORY", section_capacity );
- var memory_input = $( "#MEMORY_TMP", section_capacity );
- var memory_unit = $( "#memory_unit", section_capacity );
-
- var current_memory_unit = memory_unit.val();
-
- var update_final_memory_input = function() {
- if (current_memory_unit == 'MB') {
- final_memory_input.val( Math.floor(memory_input.val()) );
- }
- else {
- final_memory_input.val( Math.floor(memory_input.val() * 1024) );
- }
- }
-
- var memory_slider_change = function(type) {
- if ( type != "move")
- {
- var values = $(this).noUiSlider( 'value' );
-
- memory_input.val(values[1] / 100);
-
- update_final_memory_input();
- }
- };
-
- var memory_slider = $( "#memory_slider").noUiSlider('init', {
- handles: 1,
- connect: "lower",
- scale: [0,409600],
- step: 12800,
- change: memory_slider_change,
- });
-
- memory_slider.addClass("noUiSlider");
-
- memory_input.change(function() {
- memory_slider.noUiSlider('move',{
- to: this.value * 100
- })
-
- update_final_memory_input();
- });
-
- // init::start is ignored for some reason
- memory_slider.noUiSlider('move',{
- to: 0
- });
-
- memory_unit.change(function() {
- var memory_unit_val = $('#memory_unit :selected').val();
-
- if (current_memory_unit != memory_unit_val)
- {
- current_memory_unit = memory_unit_val
-
- if (memory_unit_val == 'GB') {
-
- memory_slider.empty().noUiSlider('init', {
- handles: 1,
- connect: "lower",
- scale: [0,1600],
- step: 50,
- change: memory_slider_change,
- });
-
- var new_val = memory_input.val() / 1024;
-
- memory_input.val( new_val );
- memory_slider.noUiSlider('move',{to: new_val * 100});
- }
- else if (memory_unit_val == 'MB') {
-
- memory_slider.empty().noUiSlider('init', {
- handles: 1,
- connect: "lower",
- scale: [0,409600],
- step: 12800,
- change: memory_slider_change,
- });
-
- var new_val = Math.floor( memory_input.val() * 1024 );
-
- memory_input.val( new_val );
- memory_slider.noUiSlider('move',{to: new_val * 100});
- }
-
- update_final_memory_input();
- }
- });
-
-
- // Define the vcpu slider
-
- var vcpu_input = $( "#VCPU", section_capacity );
-
- var vcpu_slider = $( "#vcpu_slider").noUiSlider('init', {
- handles: 1,
- connect: "lower",
- scale: [0,8],
- step: 1,
- change: function(type) {
- if ( type != "move")
- {
- var values = $(this).noUiSlider( 'value' );
-
- vcpu_input.val(values[1]);
- }
- },
- });
-
- vcpu_slider.addClass("noUiSlider");
-
- vcpu_input.change(function() {
- vcpu_slider.noUiSlider('move',{
- to: this.value
- })
- });
-
- // init::start is ignored for some reason
- vcpu_slider.noUiSlider('move',{to: 0});
+ var capacity_section = $('li#capacityTab', dialog);
+ setup_capacity_tab_content(capacity_section);
}
/**************************************************************************
diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js
index 1d435c02d8..44493123ae 100644
--- a/src/sunstone/public/js/plugins/vms-tab.js
+++ b/src/sunstone/public/js/plugins/vms-tab.js
@@ -212,6 +212,15 @@ var vm_actions = {
},
error: onError
},
+ "VM.showcapacity" : {
+ type: "single",
+ call: OpenNebula.VM.show,
+ callback: function(request, vm){
+ updateVMachineElement(request, vm);
+ updateVMCapacityInfo(request, vm);
+ },
+ error: onError
+ },
"VM.refresh" : {
type: "custom",
call : function (){
@@ -568,6 +577,15 @@ var vm_actions = {
error: onError,
notify: true
},
+ "VM.resize" : {
+ type: "single",
+ call: OpenNebula.VM.resize,
+ callback: function(request) {
+ Sunstone.runAction("VM.showcapacity", request.request.data[0]);
+ },
+ error: onError,
+ notify: true
+ },
"VM.detachnic" : {
type: "single",
call: OpenNebula.VM.detachnic,
@@ -752,30 +770,7 @@ var vm_buttons = {
}
var vm_info_panel = {
- "vm_info_tab" : {
- title: tr("Virtual Machine information"),
- content: ""
- },
- "vm_hotplugging_tab" : {
- title: tr("Disks & Hotplugging"),
- content: ""
- },
- "vm_template_tab" : {
- title: tr("VM template"),
- content: ""
- },
- "vm_log_tab" : {
- title: tr("VM log"),
- content: ""
- },
- "vm_history_tab" : {
- title: tr("History information"),
- content: ""
- },
- "vm_monitoring_tab" : {
- title: tr("Graphs"),
- content: ""
- }
+
};
var vms_tab = {
@@ -1244,6 +1239,11 @@ function updateVMInfo(request,vm){
content: printNics(vm_info)
};
+ var capacity_tab = {
+ title: tr("Capacity"),
+ content: printCapacity(vm_info)
+ };
+
var template_tab = {
title: tr("VM Template"),
content:
@@ -1263,32 +1263,6 @@ function updateVMInfo(request,vm){
content:
'\
\
-
\
-
\
\
\
\
@@ -1369,6 +1343,7 @@ function updateVMInfo(request,vm){
});
Sunstone.updateInfoPanelTab("vm_info_panel","vm_info_tab",info_tab);
+ Sunstone.updateInfoPanelTab("vm_info_panel","vm_capacity_tab",capacity_tab);
Sunstone.updateInfoPanelTab("vm_info_panel","vm_hotplugging_tab",hotplugging_tab);
Sunstone.updateInfoPanelTab("vm_info_panel","vm_network_tab",network_tab);
Sunstone.updateInfoPanelTab("vm_info_panel","vm_template_tab",template_tab);
@@ -1475,7 +1450,7 @@ function printDisks(vm_info){
disk.HOTPLUG_SAVE_AS_ACTIVE == "YES")
) {
save_as = (disk.SAVE_AS ? disk.SAVE_AS : '-');
- actions = 'hot snapshot in progress'
+ actions = 'hot snapshot in progress'
}
// Attach / Detach
else if (
@@ -1739,33 +1714,6 @@ function hotpluggingOps(){
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
function updateVMNicsInfo(request,vm){
$("li#vm_network_tabTab").html(printNics(vm.VM));
}
@@ -1967,6 +1915,197 @@ function setup_vm_network_tab(){
+function updateVMCapacityInfo(request,vm){
+ $("li#vm_capacity_tabTab").html(printCapacity(vm.VM));
+ Sunstone.runAction("VM.monitor",vm.VM.ID,
+ { monitor_resources : "CPU,MEMORY,NET_TX,NET_RX"});
+}
+
+function printCapacity(vm_info){
+ var html ='\
+
\
+
\
+
';
+
+ return html;
+}
+
+function setupResizeCapacityDialog(){
+ dialogs_context.append('
');
+ $resize_capacity_dialog = $('#resize_capacity_dialog',dialogs_context);
+ var dialog = $resize_capacity_dialog;
+
+ dialog.html('
\
+
\
+ '+tr("Resize VM capacity")+' \
+ \
+ \
+
')
+
+ dialog.addClass("reveal-modal large");
+ setupTips(dialog);
+
+ $("#template_name_form", dialog).hide();
+
+ setup_capacity_tab_content(dialog);
+
+ $('#resize_capacity_form',dialog).submit(function(){
+ var vm_id = $('#vm_id', this).val();
+
+ var enforce = false;
+ if ($("#enforce", this).is(":checked")) {
+ enforce = true;
+ }
+
+ var data = {};
+ addSectionJSON(data, this);
+
+ var obj = {
+ "vm_template": data,
+ "enforce": (enforce == "on" ? true : false),
+ }
+ console.log(enforce)
+ console.log(obj)
+
+ Sunstone.runAction('VM.resize', vm_id, obj);
+
+ $resize_capacity_dialog.trigger("reveal:close")
+ return false;
+ });
+};
+
+function popUpResizeCapacityDialog(vm_id){
+ $('#vm_id',$resize_capacity_dialog).val(vm_id);
+ $resize_capacity_dialog.reveal();
+}
+
+
+// Listeners to the nics operations (detach, saveas, attach)
+function setup_vm_capacity_tab(){
+ //setupSaveAsDialog();
+ setupResizeCapacityDialog();
+
+
+ $('#resize_capacity').live('click', function(){
+ var b = $(this);
+ var vm_id = b.parents('form').attr('vmid');
+
+ popUpResizeCapacityDialog(vm_id);
+
+ //b.html(spinner);
+ return false;
+ });
+
+ $('#refresh_capacity').live('click', function(){
+ var b = $(this);
+ var vm_id = b.parents('form').attr('vmid');
+ Sunstone.runAction("VM.showcapacity", vm_id);
+
+ return false;
+ });
+}
+
+
+
+
+
+
@@ -2219,6 +2358,7 @@ $(document).ready(function(){
setupVNC();
hotpluggingOps();
setup_vm_network_tab();
+ setup_vm_capacity_tab();
initCheckAllBoxes(dataTable_vMachines);
diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js
index fa0f51f977..f0fd3c0d6b 100644
--- a/src/sunstone/public/js/sunstone-util.js
+++ b/src/sunstone/public/js/sunstone-util.js
@@ -152,10 +152,10 @@ function recountCheckboxes(dataTable){
if (checked_length) { //at least 1 element checked
//enable action buttons
- $('.top_button, .list_button',context).removeAttr('disabled');
+ $('.top_button, .list_button',context).attr('disabled', false);
//check if the last_action_button should be enabled
if (last_action_b.length && last_action_b.val().length){
- last_action_b.prop('disabled', false);
+ last_action_b.attr('disabled', false);
};
//enable checkall box
if (total_length == checked_length){
@@ -167,12 +167,12 @@ function recountCheckboxes(dataTable){
//disable action buttons, uncheck checkAll
$('.check_all',dataTable).removeAttr('checked');
$('.top_button, .list_button',context).attr('disabled', true);
- last_action_b.prop('disabled', true);
+ last_action_b.attr('disabled', true);
};
//any case the create dialog buttons should always be enabled.
- $('.create_dialog_button',context).prop('disabled', false);
- $('.alwaysActive',context).prop('disabled', false);
+ $('.create_dialog_button',context).attr('disabled', false);
+ $('.alwaysActive',context).attr('disabled', false);
}
//Init action buttons and checkboxes listeners
@@ -180,11 +180,11 @@ function tableCheckboxesListener(dataTable){
//Initialization - disable all buttons
var context = dataTable.parents('form');
- $('.last_action_button',context).prop('disabled', true);
+ $('.last_action_button',context).attr('disabled', true);
$('.top_button, .list_button',context).attr('disabled', true);
//These are always enabled
- $('.create_dialog_button',context).prop('disabled', false);
- $('.alwaysActive',context).prop('disabled', false);
+ $('.create_dialog_button',context).attr('disabled', false);
+ $('.alwaysActive',context).attr('disabled', false);
//listen to changes in the visible inputs
$('tbody input.check_item',dataTable).live("change",function(){
@@ -700,7 +700,7 @@ function plot_graph(response, info) {
var data = response.monitoring[attribute];
- if(info.derivative) {
+ if(info.derivative == true) {
derivative(data);
}
@@ -783,7 +783,7 @@ function plot_totals(response, info) {
if(id != "resource") {
var data = response[id][attribute];
- if(info.derivative) {
+ if(info.derivative == true) {
derivative(data);
}
diff --git a/src/sunstone/public/sass/app.scss b/src/sunstone/public/sass/app.scss
index d6bfe56971..217e7e507a 100644
--- a/src/sunstone/public/sass/app.scss
+++ b/src/sunstone/public/sass/app.scss
@@ -768,4 +768,8 @@ a.footer.button {
.vm_log_error {
color: $alertColor;
+}
+
+.noUiSlider {
+ margin: 10px;
}
\ No newline at end of file