mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-19 03:12:55 +09:00
feature #1664: Add capacity tab and resize functionality
This commit is contained in:
1 parent
6bf572d77d
commit
a69b85c1d2
8 files changed
+496
-333
No files matched your search
@@ -42,7 +42,8 @@ module OpenNebula
|
||||
:snapshotrevert => "vm.snapshotrevert",
|
||||
:snapshotdelete => "vm.snapshotdelete",
|
||||
:attachnic => "vm.attachnic",
|
||||
:detachnic => "vm.detachnic"
|
||||
:detachnic => "vm.detachnic",
|
||||
:resize => "vm.resize"
|
||||
}
|
||||
|
||||
VM_STATE=%w{INIT PENDING HOLD ACTIVE STOPPED SUSPENDED DONE FAILED
|
||||
|
||||
@@ -62,6 +62,7 @@ module OpenNebulaJSON
|
||||
when "resubmit" then self.resubmit
|
||||
when "chown" then self.chown(action_hash['params'])
|
||||
when "chmod" then self.chmod_octet(action_hash['params'])
|
||||
when "resize" then self.resize(action_hash['params'])
|
||||
when "attachdisk" then self.attachdisk(action_hash['params'])
|
||||
when "detachdisk" then self.detachdisk(action_hash['params'])
|
||||
when "attachnic" then self.attachnic(action_hash['params'])
|
||||
@@ -103,6 +104,12 @@ module OpenNebulaJSON
|
||||
super(params['octet'])
|
||||
end
|
||||
|
||||
def resize(params=Hash.new)
|
||||
template_json = params['vm_template']
|
||||
template = template_to_str(template_json)
|
||||
super(template, params['enforce'])
|
||||
end
|
||||
|
||||
def attachdisk(params=Hash.new)
|
||||
template_json = params['disk_template']
|
||||
template = template_to_str(template_json)
|
||||
|
||||
@@ -6774,3 +6774,8 @@ a.footer.button {
|
||||
.vm_log_error {
|
||||
color: #c0392b;
|
||||
}
|
||||
|
||||
/* line 773, ../sass/app.scss */
|
||||
.noUiSlider {
|
||||
margin: 10px;
|
||||
}
|
||||
@@ -734,6 +734,11 @@ var OpenNebula = {
|
||||
"pool_monitor" : function(params){
|
||||
OpenNebula.Action.monitor(params,OpenNebula.VM.resource,true);
|
||||
},
|
||||
"resize" : function(params){
|
||||
var action_obj = params.data.extra_param;
|
||||
OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,
|
||||
"resize",action_obj);
|
||||
},
|
||||
"attachdisk" : function(params){
|
||||
var action_obj = {"disk_template": params.data.extra_param};
|
||||
OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,
|
||||
|
||||
@@ -467,6 +467,247 @@ function updateTemplatesView(request, templates_list){
|
||||
updateVResDashboard("templates",templates_list);
|
||||
}
|
||||
|
||||
function generate_capacity_tab_content() {
|
||||
var html = '<div id="template_name_form" class="row vm_param">'+
|
||||
'<div class="two columns">'+
|
||||
'<label class="inline right" for="NAME">'+tr("NAME")+':</label>'+
|
||||
'</div>'+
|
||||
'<div class="nine columns">'+
|
||||
'<input type="text" id="NAME" name="name"/>'+
|
||||
'</div>'+
|
||||
'<div class="one columns">'+
|
||||
'<div class="tip">'+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>.")+'</div>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<hr>'+
|
||||
'<br>'+
|
||||
'<div class="row vm_param">'+
|
||||
'<div class="two columns">'+
|
||||
'<label class="inline right" for="CPU">'+tr("CPU")+':</label>'+
|
||||
'</div>'+
|
||||
'<div id="cpu_slider" class="seven columns">'+
|
||||
'</div>'+
|
||||
'<div class="one columns">'+
|
||||
'<input type="text" id="CPU" name="cpu" size="2"/>'+
|
||||
'</div>'+
|
||||
'<div class="one right columns">'+
|
||||
'<div class="tip">'+tr("Percentage of CPU divided by 100 required for the Virtual Machine. Half a processor is written 0.5.")+'</div>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div class="vm_param">'+
|
||||
'<input type="hidden" id="MEMORY" name="memory" />'+
|
||||
'</div>'+
|
||||
'<div class="row">'+
|
||||
'<div class="two columns">'+
|
||||
'<label class="inline right" for="MEMORY">'+tr("MEMORY")+':</label>'+
|
||||
'</div>'+
|
||||
'<div id="memory_slider" class="five columns">'+
|
||||
'</div>'+
|
||||
'<div class="two columns">'+
|
||||
'<input type="text" id="MEMORY_TMP" name="memory_tmp" size="4" />'+
|
||||
'</div>'+
|
||||
'<div class="one columns">'+
|
||||
'<select id="memory_unit" name="MEMORY_UNIT">'+
|
||||
'<option value="MB">'+tr("MB")+'</option>'+
|
||||
'<option value="GB">'+tr("GB")+'</option>'+
|
||||
'</select>'+
|
||||
'</div>'+
|
||||
'<div class="one right columns">'+
|
||||
'<div class="tip">'+tr("Amount of RAM required for the VM, in Megabytes.")+'</div>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div class="show_hide" id="advanced_capacity">'+
|
||||
'<h4><small><i class=" icon-plus-sign-alt"/> '+tr("Advanced options")+'<a id="add_os_boot_opts" class="icon_left" href="#"></a></small></h4>'+
|
||||
'</div>'+
|
||||
'<div class="advanced">'+
|
||||
'<div class="row vm_param">'+
|
||||
'<div class="two columns">'+
|
||||
'<label class="inline right" for="VCPU">'+tr("VCPU")+':</label>'+
|
||||
'</div>'+
|
||||
'<div id="vcpu_slider" class="seven columns">'+
|
||||
'</div>'+
|
||||
'<div class="one columns">'+
|
||||
'<input type="text" id="VCPU" name="vcpu" size="3" />'+
|
||||
'</div>'+
|
||||
'<div class="one right columns">'+
|
||||
'<div class="tip">'+tr("Number of virtual cpus. This value is optional, the default hypervisor behavior is used, usually one virtual CPU.")+'</div>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'</div>'
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
function setup_capacity_tab_content(capacity_section) {
|
||||
setupTips(capacity_section);
|
||||
|
||||
// Hide advanced options
|
||||
$('.advanced',capacity_section).hide();
|
||||
|
||||
$('#advanced_capacity',capacity_section).click(function(){
|
||||
$('.advanced',capacity_section).toggle();
|
||||
return false;
|
||||
});
|
||||
|
||||
// Define the cpu slider
|
||||
|
||||
var cpu_input = $( "#CPU", capacity_section);
|
||||
|
||||
var cpu_slider = $( "#cpu_slider", capacity_section).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", capacity_section).noUiSlider('move',{to: 100});
|
||||
|
||||
|
||||
// Define the memory slider
|
||||
|
||||
var final_memory_input = $( "#MEMORY", capacity_section );
|
||||
var memory_input = $( "#MEMORY_TMP", capacity_section );
|
||||
var memory_unit = $( "#memory_unit", capacity_section );
|
||||
|
||||
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", capacity_section).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', capacity_section).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", capacity_section );
|
||||
|
||||
var vcpu_slider = $( "#vcpu_slider", capacity_section).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});
|
||||
}
|
||||
|
||||
function generate_disk_tab_content(str_disk_tab_id, str_datatable_id){
|
||||
var html = '<div class="row">'+
|
||||
'<div class="three columns push-three">'+
|
||||
@@ -582,8 +823,7 @@ function generate_disk_tab_content(str_disk_tab_id, str_datatable_id){
|
||||
'<div class="two columns">'+
|
||||
'<label class="inline right" for="SIZE">'+tr("SIZE")+':</label>'+
|
||||
'</div>'+
|
||||
'<div class="five columns">'+
|
||||
'<div id="size_slider"></div>'+
|
||||
'<div id="size_slider" class="five columns">'+
|
||||
'</div>'+
|
||||
'<div class="two columns">'+
|
||||
'<input type="text" id="SIZE" name="size"/>'+
|
||||
@@ -1330,254 +1570,15 @@ function setupCreateTemplateDialog(){
|
||||
// Set ups the capacity section
|
||||
var add_capacityTab = function(){
|
||||
var html_tab_content = '<li id="capacityTab" class="active wizard_tab">'+
|
||||
'<div class="row vm_param">'+
|
||||
'<div class="two columns">'+
|
||||
'<label class="inline right" for="NAME">'+tr("NAME")+':</label>'+
|
||||
'</div>'+
|
||||
'<div class="nine columns">'+
|
||||
'<input type="text" id="NAME" name="name"/>'+
|
||||
'</div>'+
|
||||
'<div class="one columns">'+
|
||||
'<div class="tip">'+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>.")+'</div>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<hr>'+
|
||||
'<br>'+
|
||||
'<div class="row vm_param">'+
|
||||
'<div class="two columns">'+
|
||||
'<label class="inline right" for="CPU">'+tr("CPU")+':</label>'+
|
||||
'</div>'+
|
||||
'<div class="seven columns">'+
|
||||
'<div id="cpu_slider"></div>'+
|
||||
'</div>'+
|
||||
'<div class="two columns">'+
|
||||
'<input type="text" id="CPU" name="cpu" size="2"/>'+
|
||||
'</div>'+
|
||||
'<div class="one columns">'+
|
||||
'<div class="tip">'+tr("Percentage of CPU divided by 100 required for the Virtual Machine. Half a processor is written 0.5.")+'</div>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div class="row vm_param">'+
|
||||
'<input type="hidden" id="MEMORY" name="memory" />'+
|
||||
'</div>'+
|
||||
'<div>'+
|
||||
'<div class="two columns">'+
|
||||
'<label class="inline right" for="MEMORY">'+tr("MEMORY")+':</label>'+
|
||||
'</div>'+
|
||||
'<div class="five columns">'+
|
||||
'<div id="memory_slider"></div>'+
|
||||
'</div>'+
|
||||
'<div class="two columns">'+
|
||||
'<input type="text" id="MEMORY_TMP" name="memory_tmp" size="4" />'+
|
||||
'</div>'+
|
||||
'<div class="two columns">'+
|
||||
'<select id="memory_unit" name="MEMORY_UNIT">'+
|
||||
'<option value="MB">'+tr("MB")+'</option>'+
|
||||
'<option value="GB">'+tr("GB")+'</option>'+
|
||||
'</select>'+
|
||||
'</div>'+
|
||||
'<div class="one columns">'+
|
||||
'<div class="tip">'+tr("Amount of RAM required for the VM, in Megabytes.")+'</div>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div class="show_hide" id="advanced_capacity">'+
|
||||
'<h4><small><i class=" icon-plus-sign-alt"/> '+tr("Advanced options")+'<a id="add_os_boot_opts" class="icon_left" href="#"></a></small></h4>'+
|
||||
'</div>'+
|
||||
'<div class="advanced">'+
|
||||
'<div class="row vm_param">'+
|
||||
'<div class="two columns">'+
|
||||
'<label class="inline right" for="VCPU">'+tr("VCPU")+':</label>'+
|
||||
'</div>'+
|
||||
'<div class="seven columns">'+
|
||||
'<div id="vcpu_slider"></div>'+
|
||||
'</div>'+
|
||||
'<div class="two columns">'+
|
||||
'<input type="text" id="VCPU" name="vcpu" size="3" />'+
|
||||
'</div>'+
|
||||
'<div class="one columns">'+
|
||||
'<div class="tip">'+tr("Number of virtual cpus. This value is optional, the default hypervisor behavior is used, usually one virtual CPU.")+'</div>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
generate_capacity_tab_content() +
|
||||
'</li>'
|
||||
|
||||
|
||||
$("<dd class='active'><a href='#capacity'>General</a></dd>").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);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
||||
@@ -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:
|
||||
'\
|
||||
<div class="">\
|
||||
<div class="six columns">\
|
||||
<div class="row graph_legend">\
|
||||
<h3 class="subheader"><small>'+tr("CPU")+'</small></h3>\
|
||||
</div>\
|
||||
<div class="row">\
|
||||
<div class="ten columns centered graph" id="vm_cpu_graph" style="height: 100px;">\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="row graph_legend">\
|
||||
<div class="ten columns centered" id="vm_cpu_legend">\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="six columns">\
|
||||
<div class="row graph_legend">\
|
||||
<h3 class="subheader"><small>'+tr("MEMORY")+'</small></h3>\
|
||||
</div>\
|
||||
<div class="row">\
|
||||
<div class="ten columns centered graph" id="vm_memory_graph" style="height: 100px;">\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="row graph_legend">\
|
||||
<div class="ten columns centered" id="vm_memory_legend">\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="six columns">\
|
||||
<div class="row graph_legend">\
|
||||
<h3 class="subheader"><small>'+tr("NET RX")+'</small></h3>\
|
||||
@@ -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 ='\
|
||||
<div class="">\
|
||||
<div>\
|
||||
<form id="tab_capacity_form" vmid="'+vm_info.ID+'" >\
|
||||
<div class="twelve columns">\
|
||||
<div id="refresh_capacity" class="button small secondary radius" ><i class="icon-refresh"/></div>'
|
||||
|
||||
// If VM is not RUNNING, then we forget about the attach nic form.
|
||||
if (vm_info.STATE == "0" || vm_info.STATE == "1" || vm_info.STATE == "2" || vm_info.STATE == "7" || vm_info.STATE == "8"){
|
||||
html += '\
|
||||
<button id="resize_capacity" class="button small secondary radius" >' + tr("Resize VM capacity") +'</button>'
|
||||
} else {
|
||||
html += '\
|
||||
<button id="resize_capacity" class="button small secondary radius" disabled="disabled">' + tr("Resize VM capacity") +'</button>'
|
||||
}
|
||||
|
||||
html += '\
|
||||
</div>\
|
||||
<br>\
|
||||
<br>'
|
||||
|
||||
html += '\
|
||||
<div class="twelve columns">\
|
||||
<table class="info_table twelve extended_table">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th>'+tr("CPU")+'</th>\
|
||||
<th>'+tr("VCPU")+'</th>\
|
||||
<th>'+tr("MEMORY")+'</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody>\
|
||||
<tr>\
|
||||
<td>' + vm_info.TEMPLATE.CPU + '</td>\
|
||||
<td>' + (vm_info.TEMPLATE.VCPU ? vm_info.TEMPLATE.VCPU : '-') + '</td>\
|
||||
<td>' + humanize_size_from_mb(vm_info.TEMPLATE.MEMORY) + '</td>\
|
||||
</tr>\
|
||||
</tbody>\
|
||||
</table>\
|
||||
</div>\
|
||||
<div class="six columns">\
|
||||
<div class="row graph_legend">\
|
||||
<h3 class="subheader"><small>'+tr("CPU")+'</small></h3>\
|
||||
</div>\
|
||||
<div class="row">\
|
||||
<div class="ten columns centered graph" id="vm_cpu_graph" style="height: 100px;">\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="row graph_legend">\
|
||||
<div class="ten columns centered" id="vm_cpu_legend">\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="six columns">\
|
||||
<div class="row graph_legend">\
|
||||
<h3 class="subheader"><small>'+tr("MEMORY")+'</small></h3>\
|
||||
</div>\
|
||||
<div class="row">\
|
||||
<div class="ten columns centered graph" id="vm_memory_graph" style="height: 100px;">\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="row graph_legend">\
|
||||
<div class="ten columns centered" id="vm_memory_legend">\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</form>';
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
function setupResizeCapacityDialog(){
|
||||
dialogs_context.append('<div id="resize_capacity_dialog"></div>');
|
||||
$resize_capacity_dialog = $('#resize_capacity_dialog',dialogs_context);
|
||||
var dialog = $resize_capacity_dialog;
|
||||
|
||||
dialog.html('<div class="panel">\
|
||||
<h3>\
|
||||
<small id="">'+tr("Resize VM capacity")+'</small>\
|
||||
</h3>\
|
||||
</div>\
|
||||
<form id="resize_capacity_form" action="">\
|
||||
<div class="row centered">\
|
||||
<div class="eight columns">\
|
||||
<div class="four columns">\
|
||||
<label class="inline right" for="vm_id">'+tr("Virtual Machine ID")+':</label>\
|
||||
</div>\
|
||||
<div class="seven columns">\
|
||||
<input type="text" name="vm_id" id="vm_id" disabled/>\
|
||||
</div>\
|
||||
<div class="one columns">\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="four columns">\
|
||||
<div class="four columns">\
|
||||
<label class="inline right" for="vm_id">'+tr("Enforce")+':</label>\
|
||||
</div>\
|
||||
<div class="two columns">\
|
||||
<input type="checkbox" name="enforce" id="enforce"/>\
|
||||
</div>\
|
||||
<div class="one columns pull-five">\
|
||||
<div class="tip">'
|
||||
+ tr("If it is set to true, the host capacity will be checked. This will only affect oneadmin requests, regular users resize requests will always be enforced") +
|
||||
'</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>' +
|
||||
generate_capacity_tab_content() +
|
||||
'<hr>\
|
||||
<div class="form_buttons">\
|
||||
<button class="button radius right success" id="resize_capacity_button" type="submit" value="VM.resize">'+tr("Resize")+'</button>\
|
||||
<button class="close-reveal-modal button secondary radius" type="button" value="close">' + tr("Close") + '</button>\
|
||||
</div>\
|
||||
<a class="close-reveal-modal">×</a>\
|
||||
</form>')
|
||||
|
||||
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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -768,4 +768,8 @@ a.footer.button {
|
||||
|
||||
.vm_log_error {
|
||||
color: $alertColor;
|
||||
}
|
||||
|
||||
.noUiSlider {
|
||||
margin: 10px;
|
||||
}
|
||||
Reference in new issue
Block a user