mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-25 23:21:29 +03:00
feature #1712: Add enforce and datastore option to deploy dialog
This commit is contained in:
parent
a44190b16e
commit
6b675d8b77
@ -88,7 +88,7 @@ module OpenNebulaJSON
|
||||
end
|
||||
|
||||
def deploy(params=Hash.new)
|
||||
super(params['host_id'])
|
||||
super(params['host_id'], params['enforce'], params['ds_id'])
|
||||
end
|
||||
|
||||
def undeploy(params=Hash.new)
|
||||
|
@ -704,7 +704,7 @@ var OpenNebula = {
|
||||
OpenNebula.Action.show(params,OpenNebula.VM.resource,"log");
|
||||
},
|
||||
"deploy": function(params){
|
||||
var action_obj = {"host_id": params.data.extra_param};
|
||||
var action_obj = params.data.extra_param;
|
||||
OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,
|
||||
"deploy",action_obj);
|
||||
},
|
||||
|
@ -1366,6 +1366,28 @@ function update_datatable_template_hosts(datatable, fnDrawCallback) {
|
||||
});
|
||||
}
|
||||
|
||||
function update_datatable_template_datastores(datatable, fnDrawCallback) {
|
||||
if (fnDrawCallback) {
|
||||
datatable.unbind('draw');
|
||||
datatable.on('draw', fnDrawCallback);
|
||||
}
|
||||
|
||||
OpenNebula.Datastore.list({
|
||||
timeout: true,
|
||||
success: function (request, datastore_list){
|
||||
var datastore_list_array = [];
|
||||
|
||||
$.each(datastore_list,function(){
|
||||
//Grab table data from the datastore_list
|
||||
datastore_list_array.push(datastoreElementArray(this));
|
||||
});
|
||||
|
||||
updateView(datastore_list_array, datatable);
|
||||
},
|
||||
error: onError
|
||||
});
|
||||
}
|
||||
|
||||
function update_datatable_template_clusters(datatable, fnDrawCallback) {
|
||||
if (fnDrawCallback) {
|
||||
datatable.unbind('draw');
|
||||
@ -3510,23 +3532,17 @@ function setupCreateTemplateDialog(){
|
||||
'<fieldset class="host_rank">'+
|
||||
'<legend>'+tr("Host Rank")+'</legend>'+
|
||||
'<div class="row">'+
|
||||
'<div class="two columns push-two">'+
|
||||
'<input type="radio" id="packingRadio" name="rank_select" value="RUNNING_VMS"> '+tr("Packing")+
|
||||
'<div class="four columns" style="text-align:center">'+
|
||||
'<input type="radio" id="packingRadio" name="rank_select" value="RUNNING_VMS"> '+tr("Packing")+
|
||||
' <span class="tip">'+tr("Pack the VMs in the cluster nodes to reduce VM fragmentation")+'</span>'+
|
||||
'</div>'+
|
||||
'<div class="one columns push-two">'+
|
||||
'<div class="tip">'+tr("Pack the VMs in the cluster nodes to reduce VM fragmentation")+'</div>'+
|
||||
'<div class="four columns" style="text-align:center">'+
|
||||
'<input type="radio" id="stripingRadio" name="rank_select" value="-RUNNING_VMS"> '+tr("Stripping")+
|
||||
' <span class="tip">'+tr("Spread the VMs in the cluster nodes")+'</span>'+
|
||||
'</div>'+
|
||||
'<div class="two columns push-two">'+
|
||||
'<input type="radio" id="stripingRadio" name="rank_select" value="-RUNNING_VMS"> '+tr("Stripping")+
|
||||
'</div>'+
|
||||
'<div class="one columns push-two">'+
|
||||
'<div class="tip">'+tr("Spread the VMs in the cluster nodes")+'</div>'+
|
||||
'</div>'+
|
||||
'<div class="two columns push-two">'+
|
||||
'<input type="radio" id="loadawareRadio" name="rank_select" value="FREECPU"> '+tr("Load-aware")+
|
||||
'</div>'+
|
||||
'<div class="two columns">'+
|
||||
'<div class="tip">'+tr("Maximize the resources available to VMs in a node")+'</div>'+
|
||||
'<div class="four columns" style="text-align:center">'+
|
||||
'<input type="radio" id="loadawareRadio" name="rank_select" value="FREECPU"> '+tr("Load-aware")+
|
||||
' <span class="tip">'+tr("Maximize the resources available to VMs in a node")+'</span>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<hr>'+
|
||||
@ -3546,17 +3562,13 @@ function setupCreateTemplateDialog(){
|
||||
'<fieldset class="ds_rank">'+
|
||||
'<legend>'+tr("Datastore Rank")+'</legend>'+
|
||||
'<div class="row">'+
|
||||
'<div class="four columns push-two">'+
|
||||
'<div class="six columns" style="text-align:center">'+
|
||||
'<input type="radio" id="packingRadio" name="ds_rank_select" value="-FREE_MB"> '+tr("Packing")+
|
||||
' <span class="tip">'+tr("Tries to optimize storage usage by selecting the DS with less free space")+'</span>'+
|
||||
'</div>'+
|
||||
'<div class="two columns">'+
|
||||
'<div class="tip">'+tr("Tries to optimize storage usage by selecting the DS with less free space")+'</div>'+
|
||||
'</div>'+
|
||||
'<div class="four columns push-two">'+
|
||||
'<div class="six columns" style="text-align:center">'+
|
||||
'<input type="radio" id="stripingRadio" name="ds_rank_select" value="FREE_MB"> '+tr("Stripping")+
|
||||
'</div>'+
|
||||
'<div class="two columns">'+
|
||||
'<div class="tip">'+tr("Striping. Tries to optimize I/O by distributing the VMs across datastores.")+'</div>'+
|
||||
' <span class="tip">'+tr("Striping. Tries to optimize I/O by distributing the VMs across datastores.")+'</span>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<hr>'+
|
||||
|
@ -300,9 +300,148 @@ var create_vm_tmpl ='\
|
||||
</form>\
|
||||
</div>';
|
||||
|
||||
var deploy_vm_tmpl ='\
|
||||
<div class="panel">\
|
||||
<h3>\
|
||||
<small id="deploy_vm_header">'+tr("Deploy Virtual Machine")+'</small>\
|
||||
</h3>\
|
||||
</div>\
|
||||
<div class="reveal-body">\
|
||||
<form id="deploy_vm_form" action="">\
|
||||
<div class="row">\
|
||||
<fieldset>\
|
||||
<legend>'+tr("Select a Host")+'</legend>\
|
||||
<div class="row collapse">\
|
||||
<div class="seven columns">\
|
||||
<button id="refresh_deploy_hosts_table_button_class" type="button" class="button small radius secondary"><i class="icon-refresh" /></button>\
|
||||
</div>\
|
||||
<div class="five columns">\
|
||||
<input id="deploy_hosts_table_search" type="text" placeholder="'+tr("Search")+'"/>\
|
||||
</div>\
|
||||
</div>\
|
||||
<table id="deploy_datatable_hosts" class="datatable twelve">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th></th>\
|
||||
<th>' + tr("ID") + '</th>\
|
||||
<th>' + tr("Name") + '</th>\
|
||||
<th>' + tr("Cluster") + '</th>\
|
||||
<th>' + tr("RVMs") + '</th>\
|
||||
<th>' + tr("Real CPU") + '</th>\
|
||||
<th>' + tr("Allocated CPU") + '</th>\
|
||||
<th>' + tr("Real MEM") + '</th>\
|
||||
<th>' + tr("Allocated MEM") + '</th>\
|
||||
<th>' + tr("Status") + '</th>\
|
||||
<th>' + tr("IM MAD") + '</th>\
|
||||
<th>' + tr("VM MAD") + '</th>\
|
||||
<th>' + tr("Last monitored on") + '</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="tbodyhosts">\
|
||||
</tbody>\
|
||||
</table>\
|
||||
<div class="row hidden">\
|
||||
<div class="four columns">\
|
||||
<label class="right inline" for="HOST_ID">'+tr("HOST_ID")+':</label>\
|
||||
</div>\
|
||||
<div class="six columns">\
|
||||
<input type="text" id="HOST_ID" name="HOST_ID"/>\
|
||||
</div>\
|
||||
<div class="two columns">\
|
||||
<div class="tip">\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<br>\
|
||||
<div id="selected_host" class="vm_param kvm_opt xen_opt vmware_opt">\
|
||||
<span id="select_host" class="radius secondary label">'+tr("Please select a Host from the list")+'</span>\
|
||||
<span id="host_selected" class="radius secondary label hidden">'+tr("You selected the following Host:")+'</span>\
|
||||
<span class="radius label" type="text" id="HOST_NAME" name="host"></span>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</div>\
|
||||
<br>\
|
||||
<br>\
|
||||
<div class="show_hide" id="advanced_toggle">\
|
||||
<h4><small><i class=" icon-caret-down"/> '+tr("Advanced options")+'<a id="" class="icon_left" href="#"></a></small></h4>\
|
||||
</div>\
|
||||
<div id="advanced_deploy" class="row advanced">\
|
||||
<div class="row">\
|
||||
<div class="three 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-seven 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>\
|
||||
<br>\
|
||||
<fieldset>\
|
||||
<legend>'+tr("Select a datastore")+'</legend>\
|
||||
<div class="row collapse">\
|
||||
<div class="seven columns">\
|
||||
<button id="refresh_deploy_datastores_table_button_class" type="button" class="button small radius secondary"><i class="icon-refresh" /></button>\
|
||||
</div>\
|
||||
<div class="five columns">\
|
||||
<input id="deploy_datastores_table_search" type="text" placeholder="'+tr("Search")+'"/>\
|
||||
</div>\
|
||||
</div>\
|
||||
<table id="deploy_datatable_datastores" class="datatable twelve">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th></th>\
|
||||
<th>'+tr("ID")+'</th>\
|
||||
<th>'+tr("Owner")+'</th>\
|
||||
<th>'+tr("Group")+'</th>\
|
||||
<th>'+tr("Name")+'</th>\
|
||||
<th>'+tr("Capacity")+'</th>\
|
||||
<th>'+tr("Cluster")+'</th>\
|
||||
<th>'+tr("Basepath")+'</th>\
|
||||
<th>'+tr("TM MAD")+'</th>\
|
||||
<th>'+tr("DS MAD")+'</th>\
|
||||
<th>'+tr("Type")+'</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="tbodydatastores">\
|
||||
</tbody>\
|
||||
</table>\
|
||||
<div class="row hidden">\
|
||||
<div class="four columns">\
|
||||
<label class="right inline" for="DATASTORE_ID">'+tr("DATASTORE_ID")+':</label>\
|
||||
</div>\
|
||||
<div class="six columns">\
|
||||
<input type="text" id="DATASTORE_ID" name="DATASTORE_ID"/>\
|
||||
</div>\
|
||||
<div class="two columns">\
|
||||
<div class="tip">\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<br>\
|
||||
<div id="selected_datastore" class="vm_param kvm_opt xen_opt vmware_opt">\
|
||||
<span id="select_datastore" class="radius secondary label">'+tr("Please select a datastore from the list")+'</span>\
|
||||
<span id="datastore_selected" class="radius secondary label hidden">'+tr("You selected the following datastore:")+'</span>\
|
||||
<span class="radius label" type="text" id="DATASTORE_NAME" name="datastore"></span>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</div>\
|
||||
<div class="form_buttons reveal-footer">\
|
||||
<hr>\
|
||||
<div class="form_buttons">\
|
||||
<button class="button radius right success" id="deploy_vm_proceed" value="VM.deploy">'+tr("Deploy")+'</button>\
|
||||
<button class="close-reveal-modal button secondary radius" type="button" value="close">' + tr("Close") + '</button>\
|
||||
</div>\
|
||||
</div>\
|
||||
<a class="close-reveal-modal">×</a>\
|
||||
</form>\
|
||||
</div>';
|
||||
|
||||
var vmachine_list_json = {};
|
||||
var dataTable_vMachines;
|
||||
var $create_vm_dialog;
|
||||
var $deploy_vm_dialog;
|
||||
var $vnc_dialog;
|
||||
var rfb;
|
||||
|
||||
@ -367,10 +506,16 @@ var vm_actions = {
|
||||
},
|
||||
|
||||
"VM.deploy" : {
|
||||
type: "multiple",
|
||||
type: "custom",
|
||||
call: function(){
|
||||
popUpDeployVMDialog();
|
||||
}
|
||||
},
|
||||
|
||||
"VM.deploy_action" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.deploy,
|
||||
callback: vmShow,
|
||||
elements: vmElements,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
@ -887,11 +1032,10 @@ var vm_buttons = {
|
||||
condition: mustBeAdmin
|
||||
},
|
||||
"VM.deploy" : {
|
||||
type: "confirm_with_select",
|
||||
type: "action",
|
||||
text: tr("Deploy"),
|
||||
tip: tr("This will deploy the selected VMs on the chosen host"),
|
||||
layout: "vmsplanification_buttons",
|
||||
select: hosts_sel,
|
||||
condition: mustBeAdmin
|
||||
},
|
||||
"VM.migrate" : {
|
||||
@ -2980,7 +3124,7 @@ function setupCreateVMDialog(include_select_image){
|
||||
$("#refresh_template_templates_table_button_class").die();
|
||||
$("#refresh_template_templates_table_button_class").live('click', function(){
|
||||
update_datatable_template_templates($('#template_templates_table').dataTable());
|
||||
});
|
||||
});
|
||||
|
||||
if (include_select_image) {
|
||||
$("#select_image_step", dialog).show();
|
||||
@ -3068,7 +3212,7 @@ function setupCreateVMDialog(include_select_image){
|
||||
'image_id': image_id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!vm_name.length){ //empty name use OpenNebula core default
|
||||
for (var i=0; i< n_times_int; i++){
|
||||
@ -3105,6 +3249,165 @@ function popUpCreateVMDialog(include_select_image){
|
||||
$create_vm_dialog.reveal();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Sets up the create-template dialog and all the processing associated to it,
|
||||
// which is a lot.
|
||||
function setupDeployVMDialog(){
|
||||
|
||||
dialogs_context.append('<div id="deploy_vm_dialog"></div>');
|
||||
//Insert HTML in place
|
||||
$deploy_vm_dialog = $('#deploy_vm_dialog')
|
||||
var dialog = $deploy_vm_dialog;
|
||||
dialog.html(deploy_vm_tmpl);
|
||||
dialog.addClass("reveal-modal large max-height");
|
||||
|
||||
var dataTable_deploy_hosts = $('#deploy_datatable_hosts', dialog).dataTable({
|
||||
"iDisplayLength": 4,
|
||||
"bAutoWidth":false,
|
||||
"sDom" : '<"H">t<"F"p>',
|
||||
"aoColumnDefs": [
|
||||
{ "bSortable": false, "aTargets": ["check",5,6,7,8] },
|
||||
{ "sWidth": "35px", "aTargets": [0] }, //check, ID, RVMS, Status,
|
||||
{ "bVisible": false, "aTargets": [3,5,7,10,11,12]}
|
||||
],
|
||||
"fnDrawCallback": function(oSettings) {
|
||||
var nodes = this.fnGetNodes();
|
||||
$.each(nodes, function(){
|
||||
if ($(this).find("td:eq(0)").html() == $('#HOST_ID', dialog).val()) {
|
||||
$("td", this).addClass('markrow');
|
||||
$('input.check_item', this).attr('checked','checked');
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
// Retrieve the images to fill the datatable
|
||||
update_datatable_template_hosts(dataTable_deploy_hosts);
|
||||
|
||||
$('#deploy_hosts_table_search', dialog).keyup(function(){
|
||||
dataTable_deploy_hosts.fnFilter( $(this).val() );
|
||||
})
|
||||
|
||||
$('#deploy_datatable_hosts tbody', dialog).delegate("tr", "click", function(e){
|
||||
var aData = dataTable_deploy_hosts.fnGetData(this);
|
||||
|
||||
$("td.markrow", dataTable_deploy_hosts).removeClass('markrow');
|
||||
$('tbody input.check_item', dataTable_deploy_hosts).removeAttr('checked');
|
||||
|
||||
$('#host_selected', dialog).show();
|
||||
$('#select_host', dialog).hide();
|
||||
$('.alert-box', dialog).hide();
|
||||
|
||||
$("td", this).addClass('markrow');
|
||||
$('input.check_item', this).attr('checked','checked');
|
||||
|
||||
$('#HOST_NAME', dialog).text(aData[2]);
|
||||
$('#HOST_ID', dialog).val(aData[1]);
|
||||
return true;
|
||||
});
|
||||
|
||||
$("#refresh_deploy_hosts_table_button_class").die();
|
||||
$("#refresh_deploy_hosts_table_button_class").live('click', function(){
|
||||
update_datatable_template_hosts($('#deploy_datatable_hosts').dataTable());
|
||||
});
|
||||
|
||||
|
||||
var dataTable_deploy_datastores = $('#deploy_datatable_datastores', dialog).dataTable({
|
||||
"iDisplayLength": 4,
|
||||
"bAutoWidth":false,
|
||||
"sDom" : '<"H">t<"F"p>',
|
||||
"aoColumnDefs": [
|
||||
{ "sWidth": "35px", "aTargets": [0,1] },
|
||||
{ "bVisible": false, "aTargets": [0,5,7,8,9,10] }
|
||||
],
|
||||
"fnDrawCallback": function(oSettings) {
|
||||
var nodes = this.fnGetNodes();
|
||||
$.each(nodes, function(){
|
||||
if ($(this).find("td:eq(0)").html() == $('#DATASTORE_ID', dialog).val()) {
|
||||
$("td", this).addClass('markrow');
|
||||
$('input.check_item', this).attr('checked','checked');
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
// Retrieve the images to fill the datatable
|
||||
update_datatable_template_datastores(dataTable_deploy_datastores);
|
||||
|
||||
$('#deploy_datastores_table_search', dialog).keyup(function(){
|
||||
dataTable_deploy_datastores.fnFilter( $(this).val() );
|
||||
})
|
||||
|
||||
$('#deploy_datatable_datastores tbody', dialog).delegate("tr", "click", function(e){
|
||||
var aData = dataTable_deploy_datastores.fnGetData(this);
|
||||
|
||||
$("td.markrow", dataTable_deploy_datastores).removeClass('markrow');
|
||||
$('tbody input.check_item', dataTable_deploy_datastores).removeAttr('checked');
|
||||
|
||||
$('#datastore_selected', dialog).show();
|
||||
$('#select_datastore', dialog).hide();
|
||||
$('.alert-box', dialog).hide();
|
||||
|
||||
$("td", this).addClass('markrow');
|
||||
$('input.check_item', this).attr('checked','checked');
|
||||
|
||||
$('#DATASTORE_NAME', dialog).text(aData[4]);
|
||||
$('#DATASTORE_ID', dialog).val(aData[1]);
|
||||
return true;
|
||||
});
|
||||
|
||||
$("#refresh_deploy_datastores_table_button_class").die();
|
||||
$("#refresh_deploy_datastores_table_button_class").live('click', function(){
|
||||
update_datatable_template_datastores($('#deploy_datatable_datastores').dataTable());
|
||||
});
|
||||
|
||||
dataTable_deploy_datastores.fnFilter("system",10);
|
||||
|
||||
|
||||
$('#advanced_deploy', dialog).hide();
|
||||
$('#advanced_toggle',dialog).click(function(){
|
||||
$('#advanced_deploy',dialog).toggle();
|
||||
return false;
|
||||
});
|
||||
|
||||
setupTips(dialog);
|
||||
|
||||
$('#deploy_vm_form',dialog).submit(function(){
|
||||
var extra_info = {};
|
||||
|
||||
if ($('#HOST_ID', dialog).val()) {
|
||||
extra_info['host_id'] = $('#HOST_ID', dialog).val();
|
||||
} else {
|
||||
notifyError(tr("You have not selected a host"));
|
||||
return false;
|
||||
}
|
||||
|
||||
extra_info['ds_id'] = $('#DATASTORE_ID', dialog).val() || -1
|
||||
extra_info['enforce'] = $("#enforce", this).is(":checked") ? true : false
|
||||
|
||||
//notifySubmit("Template.instantiate",template_id, extra_msg);
|
||||
|
||||
$.each(getSelectedNodes(dataTable_vMachines), function(index, elem) {
|
||||
Sunstone.runAction("VM.deploy_action", elem, extra_info);
|
||||
});
|
||||
|
||||
$deploy_vm_dialog.trigger("reveal:close")
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// Open creation dialog
|
||||
function popUpDeployVMDialog(){
|
||||
setupDeployVMDialog();
|
||||
$deploy_vm_dialog.reveal();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//Prepares autorefresh
|
||||
function setVMAutorefresh(){
|
||||
setInterval(function(){
|
||||
|
Loading…
Reference in New Issue
Block a user