mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
Feature 4823 (#185)
* F#2921 Fix DISKIO info. Accumulate values and ignore negative values for vCenter * F#4823 Add option to specify vCenter VM folder
This commit is contained in:
parent
fd8158f0cc
commit
f904fdd103
@ -371,7 +371,7 @@ IM_MAD = [ NAME="dummy", SUNSTONE_NAME="Testing", EXECUTABLE="one_im_dummy"]
|
||||
#
|
||||
# type : driver type, supported drivers: xen, kvm, xml
|
||||
#
|
||||
# keep_snapshots: do not remove snapshots on power on/off cycles and live
|
||||
# keep_snapshots: do not remove snapshots on power on/off cycles and live
|
||||
# migrations if the hypervisor supports that.
|
||||
#
|
||||
# imported_vms_actions : comma-separated list of actions supported
|
||||
@ -770,6 +770,7 @@ VM_RESTRICTED_ATTR = "MEMORY_COST"
|
||||
VM_RESTRICTED_ATTR = "DISK_COST"
|
||||
VM_RESTRICTED_ATTR = "PCI"
|
||||
VM_RESTRICTED_ATTR = "USER_INPUTS"
|
||||
VM_RESTRICTED_ATTR = "DEPLOY_FOLDER"
|
||||
|
||||
#VM_RESTRICTED_ATTR = "RANK"
|
||||
#VM_RESTRICTED_ATTR = "SCHED_RANK"
|
||||
|
@ -824,6 +824,7 @@ VM_RESTRICTED_ATTR = "EMULATOR"
|
||||
VM_RESTRICTED_ATTR = "USER_INPUTS/CPU"
|
||||
VM_RESTRICTED_ATTR = "USER_INPUTS/MEMORY"
|
||||
VM_RESTRICTED_ATTR = "USER_INPUTS/VCPU"
|
||||
VM_RESTRICTED_ATTR = "DEPLOY_FOLDER"
|
||||
|
||||
#VM_RESTRICTED_ATTR = "RANK"
|
||||
#VM_RESTRICTED_ATTR = "SCHED_RANK"
|
||||
|
@ -352,6 +352,13 @@ EOT
|
||||
:name => 'report_ready',
|
||||
:large => '--report_ready',
|
||||
:description => 'Sends READY=YES to OneGate, useful for OneFlow'
|
||||
},
|
||||
{
|
||||
:name => 'deploy_folder',
|
||||
:large => '--deploy_folder path',
|
||||
:format => String,
|
||||
:description => "In a vCenter environment sets the the VMs and Template folder where the VM will be placed in." \
|
||||
" The path uses slashes to separate folders. For example: --deploy_folder \"/Management/VMs\""
|
||||
}
|
||||
]
|
||||
|
||||
@ -1126,6 +1133,8 @@ EOT
|
||||
template<<' ]' << "\n"
|
||||
end
|
||||
|
||||
template<<"DEPLOY_FOLDER=#{options[:deploy_folder]}\n" if options[:deploy_folder]
|
||||
|
||||
context=create_context(options)
|
||||
template<<context if context
|
||||
|
||||
|
@ -48,6 +48,10 @@ features:
|
||||
# will be set to the same value as VCPU, that will still be visible for the
|
||||
# end users
|
||||
instantiate_hide_cpu: false
|
||||
|
||||
# True to show an input to specify the the VMs and Template path/folder where a vCenter VM will
|
||||
# deployed to
|
||||
vcenter_deploy_folder: false
|
||||
tabs:
|
||||
dashboard-tab:
|
||||
# The following widgets can be used inside any of the '_per_row' settings
|
||||
|
@ -48,6 +48,10 @@ features:
|
||||
# will be set to the same value as VCPU, that will still be visible for the
|
||||
# end users
|
||||
instantiate_hide_cpu: false
|
||||
|
||||
# True to show an input to specify the the VMs and Template path/folder where a vCenter VM will
|
||||
# deployed to
|
||||
vcenter_deploy_folder: true
|
||||
tabs:
|
||||
dashboard-tab:
|
||||
# The following widgets can be used inside any of the '_per_row' settings
|
||||
|
@ -48,6 +48,10 @@ features:
|
||||
# will be set to the same value as VCPU, that will still be visible for the
|
||||
# end users
|
||||
instantiate_hide_cpu: false
|
||||
|
||||
# True to show an input to specify the the VMs and Template path/folder where a vCenter VM will
|
||||
# deployed to
|
||||
vcenter_deploy_folder: false
|
||||
tabs:
|
||||
dashboard-tab:
|
||||
# The following widgets can be used inside any of the '_per_row' settings
|
||||
|
@ -48,6 +48,10 @@ features:
|
||||
# will be set to the same value as VCPU, that will still be visible for the
|
||||
# end users
|
||||
instantiate_hide_cpu: true
|
||||
|
||||
# True to show an input to specify the the VMs and Template path/folder where a vCenter VM will
|
||||
# deployed to
|
||||
vcenter_deploy_folder: false
|
||||
tabs:
|
||||
dashboard-tab:
|
||||
# The following widgets can be used inside any of the '_per_row' settings
|
||||
|
@ -48,6 +48,10 @@ features:
|
||||
# will be set to the same value as VCPU, that will still be visible for the
|
||||
# end users
|
||||
instantiate_hide_cpu: false
|
||||
|
||||
# True to show an input to specify the the VMs and Template path/folder where a vCenter VM will
|
||||
# deployed to
|
||||
vcenter_deploy_folder: false
|
||||
tabs:
|
||||
dashboard-tab:
|
||||
# The following widgets can be used inside any of the '_per_row' settings
|
||||
|
@ -114,7 +114,7 @@ define(function(require) {
|
||||
memory *= 1024;
|
||||
memory = memory * 24 * 30; //24 hours and 30 days
|
||||
document.getElementById('total_value_memory').textContent = convertCostNumber(memory);
|
||||
$(".total_memory_cost", context).show();
|
||||
$(".total_memory_cost", context).show();
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
@ -137,14 +137,14 @@ define(function(require) {
|
||||
context.on("change", "#CPU_COST", function() {
|
||||
var cpu = document.getElementById('CPU_COST').value;
|
||||
document.getElementById('total_value_cpu').textContent = convertCostNumber(cpu * 24 * 30);
|
||||
$(".total_cpu_cost", context).show();
|
||||
$(".total_cpu_cost", context).show();
|
||||
CapacityCreate.calculatedRealCpu();
|
||||
});
|
||||
|
||||
context.on("change", "#DISK_COST", function() {
|
||||
var disk = document.getElementById('DISK_COST').value;
|
||||
document.getElementById('total_value_disk').textContent = convertCostNumber(disk * 1024 * 24 * 30);
|
||||
$(".total_disk_cost", context).show();
|
||||
$(".total_disk_cost", context).show();
|
||||
});
|
||||
|
||||
context.on("change", "#LOGO", function() {
|
||||
@ -187,6 +187,9 @@ define(function(require) {
|
||||
'VM_TEMPLATE': WizardFields.retrieveInput($("#vcenter_template_uuid", context))
|
||||
};
|
||||
|
||||
if (Config.isFeatureEnabled("vcenter_deploy_folder")) {
|
||||
templateJSON["DEPLOY_FOLDER"] = WizardFields.retrieveInput($("#vcenter_deploy_folder", context))
|
||||
}
|
||||
templateJSON["KEEP_DISKS_ON_DONE"] = $("#KEEP_DISKS", context).is(':checked')?"YES":"NO"
|
||||
}
|
||||
|
||||
@ -201,7 +204,7 @@ define(function(require) {
|
||||
}
|
||||
|
||||
var userInputs = {};
|
||||
|
||||
|
||||
// Retrieve Datastore Attribute
|
||||
var dsInput = $(".vcenter_datastore_input", context);
|
||||
if (dsInput.length > 0) {
|
||||
@ -275,6 +278,17 @@ define(function(require) {
|
||||
|
||||
delete templateJSON["KEEP_DISKS_ON_DONE"];
|
||||
|
||||
if (Config.isFeatureEnabled("vcenter_deploy_folder")) {
|
||||
if (templateJSON["HYPERVISOR"] == 'vcenter' &&
|
||||
templateJSON["DEPLOY_FOLDER"]) {
|
||||
WizardFields.fillInput($("#vcenter_deploy_folder", context), templateJSON["DEPLOY_FOLDER"]);
|
||||
}
|
||||
} else {
|
||||
$(".vcenter_deploy_folder_input", context).remove();
|
||||
}
|
||||
|
||||
delete templateJSON["DEPLOY_FOLDER"];
|
||||
|
||||
if (templateJSON["HYPERVISOR"] == 'vcenter') {
|
||||
var publicClouds = templateJSON["PUBLIC_CLOUD"];
|
||||
|
||||
|
@ -120,6 +120,15 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vcenter_deploy_folder_input row">
|
||||
<div class="medium-6 columns">
|
||||
<label for="vcenter_deploy_folder">
|
||||
{{tr "Deployment Folder"}}
|
||||
{{{tip (tr "If specified, the the VMs and Template folder path where the VM will be created inside the data center. The path is delimited by slashes e.g /Management/VMs. If no path is set the VM will be deployed in the same folder where the template exists.")}}}
|
||||
</label>
|
||||
<input type="text" id="vcenter_deploy_folder"/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="row">
|
||||
<div class="capacityCreate large-12 columns">{{{capacityCreateHTML}}}</div>
|
||||
|
@ -31,6 +31,7 @@ define(function(require) {
|
||||
var WizardFields = require('utils/wizard-fields');
|
||||
var DisksResize = require('utils/disks-resize');
|
||||
var NicsSection = require('utils/nics-section');
|
||||
var DeployFolder = require('utils/deploy-folder');
|
||||
var CapacityInputs = require('tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs');
|
||||
var Config = require('sunstone-config');
|
||||
|
||||
@ -206,6 +207,13 @@ define(function(require) {
|
||||
tmp_json.PCI = pcis;
|
||||
}
|
||||
|
||||
if (Config.isFeatureEnabled("vcenter_deploy_folder")){
|
||||
if(!$.isEmptyObject(original_tmpl.TEMPLATE.PUBLIC_CLOUD.TYPE) &&
|
||||
original_tmpl.TEMPLATE.PUBLIC_CLOUD.TYPE === 'vcenter'){
|
||||
$.extend(tmp_json, DeployFolder.retrieveChanges($(".deployFolderContext" + template_id)));
|
||||
}
|
||||
}
|
||||
|
||||
capacityContext = $(".capacityContext" + template_id, context);
|
||||
$.extend(tmp_json, CapacityInputs.retrieveChanges(capacityContext));
|
||||
|
||||
@ -262,6 +270,10 @@ define(function(require) {
|
||||
'securityGroups': Config.isFeatureEnabled("secgroups")
|
||||
});
|
||||
|
||||
deployFolderContext = $(".deployFolderContext" + template_json.VMTEMPLATE.ID, context);
|
||||
DeployFolder.setup(deployFolderContext);
|
||||
DeployFolder.fill(deployFolderContext, template_json.VMTEMPLATE);
|
||||
|
||||
var inputs_div = $(".template_user_inputs" + template_json.VMTEMPLATE.ID, context);
|
||||
|
||||
UserInputs.vmTemplateInsert(
|
||||
|
@ -51,4 +51,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="medium-6 small-12 columns deployFolderContext{{element.ID}}">
|
||||
<div class="provision_deploy_folder_selector">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
74
src/sunstone/public/app/utils/deploy-folder.js
Normal file
74
src/sunstone/public/app/utils/deploy-folder.js
Normal file
@ -0,0 +1,74 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems */
|
||||
/* */
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
|
||||
/* not use this file except in compliance with the License. You may obtain */
|
||||
/* a copy of the License at */
|
||||
/* */
|
||||
/* http://www.apache.org/licenses/LICENSE-2.0 */
|
||||
/* */
|
||||
/* Unless required by applicable law or agreed to in writing, software */
|
||||
/* distributed under the License is distributed on an "AS IS" BASIS, */
|
||||
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
||||
/* See the License for the specific language governing permissions and */
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
define(function(require){
|
||||
var Locale = require('utils/locale');
|
||||
var Config = require('sunstone-config');
|
||||
var OpenNebula = require('opennebula');
|
||||
var OpenNebulaImage = require('opennebula/image');
|
||||
var UserInputs = require('utils/user-inputs');
|
||||
var WizardFields = require('utils/wizard-fields');
|
||||
var DeployFolderTemplate = require('hbs!./deploy-folder/html');
|
||||
|
||||
return {
|
||||
'setup': _setup,
|
||||
'fill': _fill,
|
||||
'retrieveChanges': _retrieveChanges
|
||||
};
|
||||
|
||||
function _setup(context) {
|
||||
if (!Config.isFeatureEnabled("vcenter_deploy_folder")){
|
||||
$(context).remove();
|
||||
}
|
||||
}
|
||||
|
||||
function _fill(context, element) {
|
||||
|
||||
if (Config.isFeatureEnabled("vcenter_deploy_folder")){
|
||||
var deployFolderContext = context;
|
||||
var template_public_cloud_type = element.TEMPLATE.PUBLIC_CLOUD.TYPE
|
||||
|
||||
if ($.isEmptyObject(template_public_cloud_type)) {
|
||||
deployFolderContext.html("");
|
||||
} else {
|
||||
if (template_public_cloud_type === 'vcenter') {
|
||||
var deploy_folder = element.TEMPLATE.DEPLOY_FOLDER
|
||||
deployFolderContext.html(DeployFolderTemplate());
|
||||
$("#deploy_folder_input", deployFolderContext).val(deploy_folder);
|
||||
$("#deploy_folder_input", deployFolderContext).data("original_value",deploy_folder);
|
||||
} else {
|
||||
deployFolderContext.html("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function _retrieveChanges(context) {
|
||||
|
||||
var templateJSON = WizardFields.retrieve(context);
|
||||
var fields = $('[wizard_field]', context);
|
||||
|
||||
fields.each(function() {
|
||||
var field_name = $(this).attr('wizard_field');
|
||||
if (templateJSON[field_name] == $(this).data("original_value")){
|
||||
delete templateJSON[field_name];
|
||||
}
|
||||
});
|
||||
|
||||
return templateJSON;
|
||||
}
|
||||
});
|
29
src/sunstone/public/app/utils/deploy-folder/html.hbs
Normal file
29
src/sunstone/public/app/utils/deploy-folder/html.hbs
Normal file
@ -0,0 +1,29 @@
|
||||
{{! -------------------------------------------------------------------------- }}
|
||||
{{! Copyright 2002-2016, OpenNebula Project, OpenNebula Systems }}
|
||||
{{! }}
|
||||
{{! Licensed under the Apache License, Version 2.0 (the "License"); you may }}
|
||||
{{! not use this file except in compliance with the License. You may obtain }}
|
||||
{{! a copy of the License at }}
|
||||
{{! }}
|
||||
{{! http://www.apache.org/licenses/LICENSE-2.0 }}
|
||||
{{! }}
|
||||
{{! Unless required by applicable law or agreed to in writing, software }}
|
||||
{{! distributed under the License is distributed on an "AS IS" BASIS, }}
|
||||
{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }}
|
||||
{{! See the License for the specific language governing permissions and }}
|
||||
{{! limitations under the License. }}
|
||||
{{! -------------------------------------------------------------------------- }}
|
||||
|
||||
<fieldset>
|
||||
<legend>
|
||||
<i class="fa fa-folder"></i> {{tr "vCenter Deployment"}}
|
||||
</legend>
|
||||
<div class="deployContainer">
|
||||
<label for="deploy_folder_input">
|
||||
{{tr "Deployment Folder"}}
|
||||
{{{tip (tr "If specified, the VMs and Template folder path where the VM will be created inside the data center. The path is delimited by slashes e.g /Management/VMs. If no path is set the VM will be deployed in the same folder where the template exists.")}}}
|
||||
</label>
|
||||
<input type="text" name="deploy_folder_input" id="deploy_folder_input" wizard_field="DEPLOY_FOLDER"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
@ -2490,6 +2490,21 @@ private
|
||||
connection = VIClient.new(hid)
|
||||
vc_template = connection.find_vm_fast(uuid, ops[:ref], ops[:name])
|
||||
|
||||
deploy_folder = nil
|
||||
deploy_folder_name = xml.root.elements["/VM/USER_TEMPLATE/DEPLOY_FOLDER"]
|
||||
|
||||
if !deploy_folder_name.nil?
|
||||
deploy_folder_name = deploy_folder_name.text
|
||||
if !deploy_folder_name.empty?
|
||||
# Look for folder object
|
||||
deploy_folder = connection.dc.find_folder(deploy_folder_name)
|
||||
end
|
||||
end
|
||||
|
||||
if deploy_folder.nil?
|
||||
deploy_folder = vc_template.parent
|
||||
end
|
||||
|
||||
# Find out requested and available resource pool
|
||||
|
||||
req_rp = nil
|
||||
@ -2598,7 +2613,7 @@ private
|
||||
storage_spec = RbVmomi::VIM.StoragePlacementSpec(
|
||||
type: 'clone',
|
||||
cloneName: vcenter_name,
|
||||
folder: vc_template.parent,
|
||||
folder: deploy_folder,
|
||||
podSelectionSpec: pod_spec,
|
||||
vm: vc_template,
|
||||
cloneSpec: clone_spec
|
||||
@ -2624,7 +2639,7 @@ private
|
||||
|
||||
begin
|
||||
vm = vc_template.CloneVM_Task(
|
||||
:folder => vc_template.parent,
|
||||
:folder => deploy_folder,
|
||||
:name => vcenter_name,
|
||||
:spec => clone_spec).wait_for_completion
|
||||
rescue Exception => e
|
||||
@ -2639,7 +2654,7 @@ private
|
||||
|
||||
vm.Destroy_Task.wait_for_completion
|
||||
vm = vc_template.CloneVM_Task(
|
||||
:folder => vc_template.parent,
|
||||
:folder => deploy_folder,
|
||||
:name => vcenter_name,
|
||||
:spec => clone_spec).wait_for_completion
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user