1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-08 21:17:43 +03:00

F #5217 Added ds requirements instantiate VM (#407)

* Added ds requirements instantiate VM

* Solved bug in VMGroup datatable cloud view

* F #5217 Added DS Requirements cloud view instantiate VM

* F #5217 Added SYSTEM filter in DS datatable

* F #5217 Made configurable ds and host datatables instantiate VM
This commit is contained in:
Abel Coronado 2017-07-21 13:06:41 +02:00 committed by Ruben S. Montero
parent 2911648e07
commit d436795371
10 changed files with 195 additions and 13 deletions

View File

@ -56,6 +56,12 @@ features:
# True to show the option to make an instance persistent
instantiate_persistent: true
# True to show the datastore datatable to instantiate VM
show_ds_instantiate: true
# True to show the host datatable to instantiate VM
show_host_instantiate: true
# True to show an input to specify the the VMs and Template path/folder where a vCenter VM will
# deployed to
vcenter_vm_folder: false

View File

@ -56,6 +56,12 @@ features:
# True to show the option to make an instance persistent
instantiate_persistent: true
# True to show the datastore datatable to instantiate VM
show_ds_instantiate: false
# True to show the host datatable to instantiate VM
show_host_instantiate: false
# True to show an input to specify the the VMs and Template path/folder where a vCenter VM will
# deployed to
vcenter_vm_folder: true

View File

@ -88,6 +88,8 @@ tabs:
vmgroup_select: true
# True to allow DISK size customization
disk_resize: true
# True to allow datastore customization
datastore_select: true
settings-tab:
panel_tabs:
settings_info_tab: false
@ -153,4 +155,20 @@ tabs:
- 4 # Owner
- 5 # Vms
#- 6 # Labels
#- 7 # Search data
#- 7 # Search data
datastores-tab:
table_columns:
- 0 # Checkbox
- 1 # ID
- 2 # Owner
- 3 # Group
- 4 # Name
#- 5 # Capacity
#- 6 # Cluster
#- 7 # Basepath
#- 8 # TM
#- 9 # DS
#- 10 # Type
- 11 # Status
#- 12 # Labels
#- 13 # Search data

View File

@ -56,6 +56,12 @@ features:
# True to show the option to make an instance persistent
instantiate_persistent: true
# True to show the datastore datatable to instantiate VM
show_ds_instantiate: false
# True to show the host datatable to instantiate VM
show_host_instantiate: false
# True to show an input to specify the the VMs and Template path/folder where a vCenter VM will
# deployed to
vcenter_vm_folder: false

View File

@ -56,6 +56,12 @@ features:
# True to show the option to make an instance persistent
instantiate_persistent: true
# True to show the datastore datatable to instantiate VM
show_ds_instantiate: false
# True to show the host datatable to instantiate VM
show_host_instantiate: false
# True to show an input to specify the the VMs and Template path/folder where a vCenter VM will
# deployed to
vcenter_vm_folder: false

View File

@ -40,6 +40,8 @@ define(function(require) {
var UserInputs = require('utils/user-inputs');
var CapacityInputs = require('tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs');
var LabelsUtils = require('utils/labels/utils');
var DatastoresTable = require('tabs/datastores-tab/datatable');
var UniqueId = require('utils/unique-id');
var ProvisionVmsList = require('./provision-tab/vms/list');
var ProvisionTemplatesList = require('./provision-tab/templates/list');
@ -92,6 +94,7 @@ define(function(require) {
$("#vm_name", context).val('');
$(".provision_selected_networks").html("");
$(".provision_vmgroup_selector").html("");
$(".provision_ds_selector").html("");
$(".provision-pricing-table", context).removeClass("selected");
$(".alert-box-error", context).hide();
$(".total_cost_div", context).hide();
@ -569,8 +572,10 @@ define(function(require) {
$("#provision_create_vm .provision_disk_selector").removeData("template_json");
$("#provision_create_vm .provision_network_selector").html("");
$("#provision_create_vm .provision_vmgroup_selector").html("");
$("#provision_create_vm .provision_ds_selector").html("");
$("#provision_create_vm .provision_add_vmgroup").show();
$("#provision_create_vm .provision_vmgroup").hide();
$("#provision_create_vm .provision_ds").hide();
$("#provision_create_vm .provision_custom_attributes_selector").html("")
@ -595,12 +600,13 @@ define(function(require) {
$(".provision_vmgroup_selector", context).html("");
$(".provision_add_vmgroup", context).show();
$(".provision_vmgroup", context).hide();
//$(".provision_ds", context).hide();
$(".provision_custom_attributes_selector", context).html("");
$(".provision_accordion_flow_template .selected_template", context).hide();
$(".provision_accordion_flow_template .select_template", context).show();
$("li:not(.is-active) a[href='#provision_dd_flow_template']", context).trigger("click")
$("li:not(.is-active) a[href='#provision_dd_flow_template']", context).trigger("click");
$(".total_cost_div", context).hide();
$(".alert-box-error", context).hide();
@ -946,6 +952,7 @@ define(function(require) {
$(".provision_accordion_template a").first().trigger("click");
$("#provision_create_vm .provision_vmgroup").show();
$("#provision_create_vm .provision_ds").show();
OpenNebula.Template.show({
data : {
id: template_id,
@ -983,11 +990,45 @@ define(function(require) {
}
if (Config.provision.create_vm.isEnabled("vmgroup_select")) {
$(".provision_vmgroup_selector", create_vm_context).html("");
$("#provision_create_vm .provision_add_vmgroup").show();
VMGroupSection.insert(template_json, $(".vmgroupContext", create_vm_context));
} else {
$(".provision_vmgroup_selector", create_vm_context).html("");
}
if (Config.provision.create_vm.isEnabled("datastore_select")) {
$(".provision_ds_selector", create_vm_context).html("");
var options = {
'select': true,
'selectOptions': {
'multiple_choice': true
}
}
this.datastoresTable = new DatastoresTable('DatastoresTable' + UniqueId.id(), options);
$(".provision_ds_selector", create_vm_context).html(this.datastoresTable.dataTableHTML);
this.datastoresTable.initialize();
this.datastoresTable.filter("system", 10);
this.datastoresTable.refreshResourceTableSelect();
if(template_json.VMTEMPLATE.TEMPLATE.SCHED_DS_REQUIREMENTS){
var dsReqJSON = template_json.VMTEMPLATE.TEMPLATE.SCHED_DS_REQUIREMENTS;
var dsReq = TemplateUtils.escapeDoubleQuotes(dsReqJSON);
var ds_id_regexp = /(\s|\||\b)ID=\\"([0-9]+)\\"/g;
var ds = [];
while (match = ds_id_regexp.exec(dsReq)) {
ds.push(match[2]);
}
var selectedResources = {
ids : ds
}
this.datastoresTable.selectResourceTableSelect(selectedResources);
$(".provision_ds_selector", create_vm_context).data("dsTable", this.datastoresTable);
}
} else {
$(".provision_ds_selector", create_vm_context).html("");
$(".provision_ds", create_vm_context).hide();
}
if (template_json.VMTEMPLATE.TEMPLATE.USER_INPUTS) {
UserInputs.vmTemplateInsert(
$(".provision_custom_attributes_selector", create_vm_context),
@ -1044,6 +1085,20 @@ define(function(require) {
$.extend(extra_info.template, vmgroup);
}
var dsTable = $(".provision_ds_selector", context).data("dsTable");
if(dsTable != undefined){
var req_string = [];
var ds = dsTable.retrieveResourceTableSelect();
if(ds){
$.each(ds, function(index, dsId) {
req_string.push('ID="' + dsId + '"');
});
req_string = req_string.join(" | ");
req_string = TemplateUtils.escapeDoubleQuotes(req_string);
extra_info.template.SCHED_DS_REQUIREMENTS = req_string;
}
}
if (nics.length > 0) {
extra_info.template.nic = nics;
}

View File

@ -140,4 +140,14 @@
</fieldset>
</div>
</div>
<div class="row provision_ds" hidden="true">
<div class="small-12 columns dsContext{{element.ID}}">
<fieldset>
<legend>
<i class="fa fa-globe"></i> {{tr "Datastore"}}
</legend>
<div class="provision_ds_selector" data-tab-content></div>
</fieldset>
</div>
</div>
</form>

View File

@ -129,6 +129,7 @@ define(function(require) {
that.clustersTable.initialize(selectOptions);
that.clustersTable.refreshResourceTableSelect();
that.datastoresTable.initialize(selectOptions);
that.datastoresTable.filter("system", 10);
that.datastoresTable.refreshResourceTableSelect();
}

View File

@ -29,6 +29,7 @@ define(function(require) {
var Tips = require('utils/tips');
var UserInputs = require('utils/user-inputs');
var WizardFields = require('utils/wizard-fields');
var TemplateUtils = require('utils/template-utils');
var DisksResize = require('utils/disks-resize');
var NicsSection = require('utils/nics-section');
var VMGroupSection = require('utils/vmgroup-section');
@ -36,6 +37,7 @@ define(function(require) {
var CapacityInputs = require('tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs');
var Config = require('sunstone-config');
var HostsTable = require('tabs/hosts-tab/datatable');
var DatastoresTable = require('tabs/datastores-tab/datatable');
/*
CONSTANTS
@ -182,6 +184,11 @@ define(function(require) {
tmp_json.SCHED_REQUIREMENTS = sched;
}
var sched_ds = WizardFields.retrieveInput($("#SCHED_DS_REQUIREMENTS" + template_id, context));
if(sched_ds){
tmp_json.SCHED_DS_REQUIREMENTS = sched_ds;
}
var nics = [];
var pcis = [];
@ -266,6 +273,7 @@ define(function(require) {
timeout: true,
success: function (request, template_json) {
that.template_objects.push(template_json);
var options = {
'select': true,
'selectOptions': {
@ -274,26 +282,68 @@ define(function(require) {
}
that.hostsTable = new HostsTable('HostsTable' + template_json.VMTEMPLATE.ID, options);
that.datastoresTable = new DatastoresTable('DatastoresTable' + template_json.VMTEMPLATE.ID, options);
templatesContext.append(
TemplateRowHTML(
{ element: template_json.VMTEMPLATE,
capacityInputsHTML: CapacityInputs.html(),
hostsDatatable: that.hostsTable.dataTableHTML
hostsDatatable: that.hostsTable.dataTableHTML,
dsDatatable: that.datastoresTable.dataTableHTML
}) );
$(".provision_host_selector" + template_json.VMTEMPLATE.ID, context).data("hostsTable", that.hostsTable);
$(".provision_ds_selector" + template_json.VMTEMPLATE.ID, context).data("dsTable", that.datastoresTable);
var selectOptions = {
'selectOptions': {
'select_callback': function(aData, options) {
generateRequirements($(".provision_host_selector" + template_json.VMTEMPLATE.ID, context).data("hostsTable"), context, template_json.VMTEMPLATE.ID);
var hostTable = $(".provision_host_selector" + template_json.VMTEMPLATE.ID, context).data("hostsTable");
var dsTable = $(".provision_ds_selector" + template_json.VMTEMPLATE.ID, context).data("dsTable");
generateRequirements(hostTable, dsTable, context, template_json.VMTEMPLATE.ID);
},
'unselect_callback': function(aData, options) {
generateRequirements($(".provision_host_selector"+ template_json.VMTEMPLATE.ID, context).data("hostsTable"), context, template_json.VMTEMPLATE.ID);
}
var hostTable = $(".provision_host_selector" + template_json.VMTEMPLATE.ID, context).data("hostsTable");
var dsTable = $(".provision_ds_selector" + template_json.VMTEMPLATE.ID, context).data("dsTable");
generateRequirements(hostTable, dsTable, context, template_json.VMTEMPLATE.ID);
}
}
}
that.hostsTable.initialize(selectOptions);
that.hostsTable.refreshResourceTableSelect();
that.datastoresTable.initialize(selectOptions);
that.datastoresTable.filter("system", 10);
that.datastoresTable.refreshResourceTableSelect();
var reqJSON = template_json.VMTEMPLATE.TEMPLATE.SCHED_REQUIREMENTS;
if (reqJSON) {
$('#SCHED_REQUIREMENTS' + template_json.VMTEMPLATE.ID, context).val(reqJSON);
var req = TemplateUtils.escapeDoubleQuotes(reqJSON);
var host_id_regexp = /(\s|\||\b)ID=\\"([0-9]+)\\"/g;
var hosts = [];
while (match = host_id_regexp.exec(req)) {
hosts.push(match[2]);
}
var selectedResources = {
ids : hosts
}
that.hostsTable.selectResourceTableSelect(selectedResources);
}
var dsReqJSON = template_json.VMTEMPLATE.TEMPLATE.SCHED_DS_REQUIREMENTS;
if (dsReqJSON) {
$('#SCHED_DS_REQUIREMENTS' + template_json.VMTEMPLATE.ID, context).val(dsReqJSON);
var dsReq = TemplateUtils.escapeDoubleQuotes(dsReqJSON);
var ds_id_regexp = /(\s|\||\b)ID=\\"([0-9]+)\\"/g;
var ds = [];
while (match = ds_id_regexp.exec(dsReq)) {
ds.push(match[2]);
}
var selectedResources = {
ids : ds
}
that.datastoresTable.selectResourceTableSelect(selectedResources);
}
DisksResize.insert({
template_json: template_json,
@ -383,21 +433,22 @@ define(function(require) {
Tips.setup(context);
return false;
}
function generateRequirements(hosts_table, context, id) {
function generateRequirements(hosts_table, ds_table, context, id) {
var req_string=[];
//var req_ds_string=[];
var req_ds_string=[];
var selected_hosts = hosts_table.retrieveResourceTableSelect();
//var selected_ds = this.datastoresTable.retrieveResourceTableSelect();
var selected_ds = ds_table.retrieveResourceTableSelect();
$.each(selected_hosts, function(index, hostId) {
req_string.push('ID="'+hostId+'"');
});
/*$.each(selected_ds, function(index, dsId) {
$.each(selected_ds, function(index, dsId) {
req_ds_string.push('ID="'+dsId+'"');
});*/
});
$('#SCHED_REQUIREMENTS' + id, context).val(req_string.join(" | "));
//$('#SCHED_DS_REQUIREMENTS', context).val(req_ds_string.join(" | "));
$('#SCHED_DS_REQUIREMENTS' + id, context).val(req_ds_string.join(" | "));
};
});

View File

@ -67,6 +67,7 @@
</fieldset>
</div>
</div>
{{#isFeatureEnabled "show_host_instantiate"}}
<div class="row">
<div class="small-12 columns hostContext{{element.ID}}">
<fieldset>
@ -86,7 +87,29 @@
</fieldset>
</div>
</div>
<div class="row">
{{/isFeatureEnabled}}
{{#isFeatureEnabled "show_ds_instantiate"}}
<div class="row">
<div class="small-12 columns dsContext{{element.ID}}">
<fieldset>
<legend>
<i class="fa fa-globe"></i> {{tr "Datastore"}}
</legend>
<div class="provision_ds_selector{{element.ID}}" data-tab-content>{{{dsDatatable}}}</div>
<div class="row">
<div class="large-12 columns">
<label for="SCHED_DS_REQUIREMENTS">
{{tr "Expression"}}
{{{tip (tr "Boolean expression that rules out entries from the pool of datastores suitable to run this VM.")}}}
</label>
<input type="text" wizard_field="SCHED_DS_REQUIREMENTS" id="SCHED_DS_REQUIREMENTS{{element.ID}}" name="requirements" />
</div>
</div>
</fieldset>
</div>
</div>
{{/isFeatureEnabled}}
<div class="row">
<div class="medium-6 small-12 columns vcenterVMFolderContext{{element.ID}}">
<div class="provision_vcenter_vm_folder_selector">
</div>