mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-20 20:02:38 +09:00
F #4913: Add support for VM folder selection F#4823. Replace DEPLOY_FOLDER with VCENTER_VM_FOLDER
This commit is contained in:
1 parent
d03f991da8
commit
39fc6e110c
15 files changed
+54
-144
No files matched your search
@@ -770,7 +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 = "VCENTER_VM_FOLDER"
|
||||
|
||||
#VM_RESTRICTED_ATTR = "RANK"
|
||||
#VM_RESTRICTED_ATTR = "SCHED_RANK"
|
||||
|
||||
+5
-5
@@ -248,10 +248,10 @@ VXLAN_IDS = [
|
||||
# DEFAULT_CDROM_DEVICE_PREFIX: Same as above but for CDROM devices.
|
||||
#
|
||||
# DEFAULT_IMAGE_PERSISTENT: Control the default value for the PERSISTENT
|
||||
# attribute on image creation (oneimage clone, onevm disk-saveas). If blank
|
||||
# attribute on image creation (oneimage clone, onevm disk-saveas). If blank
|
||||
# images will inherit the persistent attribute from the base image.
|
||||
#
|
||||
# DEFAULT_IMAGE_PERSISTENT_NEW: Control the default value for the PERSISTENT
|
||||
# DEFAULT_IMAGE_PERSISTENT_NEW: Control the default value for the PERSISTENT
|
||||
# attribute on image creation (oneimage create). By default images are no
|
||||
# persistent if not set.
|
||||
#*******************************************************************************
|
||||
@@ -814,8 +814,8 @@ DEFAULT_UMASK = 177
|
||||
|
||||
VM_ADMIN_OPERATIONS = "migrate, delete, recover, retry, deploy, resched"
|
||||
|
||||
VM_MANAGE_OPERATIONS = "undeploy, hold, release, stop, suspend, resume, reboot,
|
||||
poweroff, disk-attach, nic-attach, disk-snapshot, terminate, disk-resize,
|
||||
VM_MANAGE_OPERATIONS = "undeploy, hold, release, stop, suspend, resume, reboot,
|
||||
poweroff, disk-attach, nic-attach, disk-snapshot, terminate, disk-resize,
|
||||
snapshot, updateconf, rename, resize, update, disk-saveas"
|
||||
|
||||
VM_USE_OPERATIONS = ""
|
||||
@@ -856,7 +856,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 = "VCENTER_VM_FOLDER"
|
||||
|
||||
#VM_RESTRICTED_ATTR = "RANK"
|
||||
#VM_RESTRICTED_ATTR = "SCHED_RANK"
|
||||
|
||||
@@ -354,11 +354,11 @@ EOT
|
||||
:description => 'Sends READY=YES to OneGate, useful for OneFlow'
|
||||
},
|
||||
{
|
||||
:name => 'deploy_folder',
|
||||
:large => '--deploy_folder path',
|
||||
:name => 'vcenter_vm_folder',
|
||||
:large => '--vcenter_vm_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\""
|
||||
" The path uses slashes to separate folders. For example: --vcenter_vm_folder \"/Management/VMs\""
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1133,7 +1133,7 @@ EOT
|
||||
template<<' ]' << "\n"
|
||||
end
|
||||
|
||||
template<<"DEPLOY_FOLDER=#{options[:deploy_folder]}\n" if options[:deploy_folder]
|
||||
template<<"VCENTER_VM_FOLDER=#{options[:vcenter_vm_folder]}\n" if options[:vcenter_vm_folder]
|
||||
|
||||
context=create_context(options)
|
||||
template<<context if context
|
||||
|
||||
@@ -52,7 +52,7 @@ features:
|
||||
|
||||
# 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
|
||||
vcenter_vm_folder: false
|
||||
tabs:
|
||||
dashboard-tab:
|
||||
# The following widgets can be used inside any of the '_per_row' settings
|
||||
|
||||
@@ -52,7 +52,7 @@ features:
|
||||
|
||||
# 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
|
||||
vcenter_vm_folder: true
|
||||
tabs:
|
||||
dashboard-tab:
|
||||
# The following widgets can be used inside any of the '_per_row' settings
|
||||
|
||||
@@ -52,7 +52,7 @@ features:
|
||||
|
||||
# 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
|
||||
vcenter_vm_folder: false
|
||||
tabs:
|
||||
dashboard-tab:
|
||||
# The following widgets can be used inside any of the '_per_row' settings
|
||||
|
||||
@@ -52,7 +52,7 @@ features:
|
||||
|
||||
# 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
|
||||
vcenter_vm_folder: false
|
||||
tabs:
|
||||
dashboard-tab:
|
||||
# The following widgets can be used inside any of the '_per_row' settings
|
||||
|
||||
@@ -52,7 +52,7 @@ features:
|
||||
|
||||
# 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
|
||||
vcenter_vm_folder: false
|
||||
tabs:
|
||||
dashboard-tab:
|
||||
# The following widgets can be used inside any of the '_per_row' settings
|
||||
|
||||
+7
-7
@@ -189,8 +189,8 @@ define(function(require) {
|
||||
if (templateJSON["HYPERVISOR"] == 'vcenter') {
|
||||
templateJSON["VCENTER_TEMPLATE_REF"] = WizardFields.retrieveInput($("#vcenter_template_ref", context));
|
||||
|
||||
if (Config.isFeatureEnabled("vcenter_deploy_folder")) {
|
||||
templateJSON["DEPLOY_FOLDER"] = WizardFields.retrieveInput($("#vcenter_deploy_folder", context))
|
||||
if (Config.isFeatureEnabled("vcenter_vm_folder")) {
|
||||
templateJSON["VCENTER_VM_FOLDER"] = WizardFields.retrieveInput($("#vcenter_vm_folder", context))
|
||||
}
|
||||
templateJSON["KEEP_DISKS_ON_DONE"] = $("#KEEP_DISKS", context).is(':checked')?"YES":"NO"
|
||||
}
|
||||
@@ -280,16 +280,16 @@ define(function(require) {
|
||||
|
||||
delete templateJSON["KEEP_DISKS_ON_DONE"];
|
||||
|
||||
if (Config.isFeatureEnabled("vcenter_deploy_folder")) {
|
||||
if (Config.isFeatureEnabled("vcenter_vm_folder")) {
|
||||
if (templateJSON["HYPERVISOR"] == 'vcenter' &&
|
||||
templateJSON["DEPLOY_FOLDER"]) {
|
||||
WizardFields.fillInput($("#vcenter_deploy_folder", context), templateJSON["DEPLOY_FOLDER"]);
|
||||
templateJSON["VCENTER_VM_FOLDER"]) {
|
||||
WizardFields.fillInput($("#vcenter_vm_folder", context), templateJSON["VCENTER_VM_FOLDER"]);
|
||||
}
|
||||
} else {
|
||||
$(".vcenter_deploy_folder_input", context).remove();
|
||||
$(".vcenter_vm_folder_input", context).remove();
|
||||
}
|
||||
|
||||
delete templateJSON["DEPLOY_FOLDER"];
|
||||
delete templateJSON["VCENTER_VM_FOLDER"];
|
||||
|
||||
if (templateJSON["HYPERVISOR"] == 'vcenter') {
|
||||
var publicClouds = templateJSON["PUBLIC_CLOUD"];
|
||||
|
||||
+5
-5
@@ -120,13 +120,13 @@
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="vcenter_deploy_folder_input row">
|
||||
<div class="vcenter_vm_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 for="vcenter_vm_folder">
|
||||
{{tr "vCenter VM 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 placed in the same folder where the template is located.")}}}
|
||||
</label>
|
||||
<input type="text" id="vcenter_deploy_folder"/>
|
||||
<input type="text" id="vcenter_vm_folder"/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -32,7 +32,7 @@ define(function(require) {
|
||||
var DisksResize = require('utils/disks-resize');
|
||||
var NicsSection = require('utils/nics-section');
|
||||
var VMGroupSection = require('utils/vmgroup-section');
|
||||
var DeployFolder = require('utils/deploy-folder');
|
||||
var VcenterVMFolder = require('utils/vcenter-vm-folder');
|
||||
var CapacityInputs = require('tabs/templates-tab/form-panels/create/wizard-tabs/general/capacity-inputs');
|
||||
var Config = require('sunstone-config');
|
||||
|
||||
@@ -214,10 +214,10 @@ define(function(require) {
|
||||
tmp_json.PCI = pcis;
|
||||
}
|
||||
|
||||
if (Config.isFeatureEnabled("vcenter_deploy_folder")){
|
||||
if (Config.isFeatureEnabled("vcenter_vm_folder")){
|
||||
if(!$.isEmptyObject(original_tmpl.TEMPLATE.HYPERVISOR) &&
|
||||
original_tmpl.TEMPLATE.HYPERVISOR === 'vcenter'){
|
||||
$.extend(tmp_json, DeployFolder.retrieveChanges($(".deployFolderContext" + template_id)));
|
||||
$.extend(tmp_json, VcenterVMFolder.retrieveChanges($(".vcenterVMFolderContext" + template_id)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,9 +279,9 @@ define(function(require) {
|
||||
VMGroupSection.insert(template_json,
|
||||
$(".vmgroupContext"+ template_json.VMTEMPLATE.ID, context));
|
||||
|
||||
deployFolderContext = $(".deployFolderContext" + template_json.VMTEMPLATE.ID, context);
|
||||
DeployFolder.setup(deployFolderContext);
|
||||
DeployFolder.fill(deployFolderContext, template_json.VMTEMPLATE);
|
||||
vcenterVMFolderContext = $(".vcenterVMFolderContext" + template_json.VMTEMPLATE.ID, context);
|
||||
VcenterVMFolder.setup(vcenterVMFolderContext);
|
||||
VcenterVMFolder.fill(vcenterVMFolderContext, template_json.VMTEMPLATE);
|
||||
|
||||
var inputs_div = $(".template_user_inputs" + template_json.VMTEMPLATE.ID, context);
|
||||
|
||||
|
||||
@@ -68,8 +68,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="medium-6 small-12 columns deployFolderContext{{element.ID}}">
|
||||
<div class="provision_deploy_folder_selector">
|
||||
<div class="medium-6 small-12 columns vcenterVMFolderContext{{element.ID}}">
|
||||
<div class="provision_vcenter_vm_folder_selector">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* 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.HYPERVISOR
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
@@ -1,29 +0,0 @@
|
||||
{{! -------------------------------------------------------------------------- }}
|
||||
{{! 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>
|
||||
|
||||
@@ -330,11 +330,24 @@ class VirtualMachine
|
||||
|
||||
clone_spec = RbVmomi::VIM.VirtualMachineCloneSpec(spec_hash)
|
||||
|
||||
# Specify vm folder in vSpere's VM and Templates view F#4823
|
||||
vcenter_vm_folder = nil
|
||||
vcenter_vm_folder = one_item["USER_TEMPLATE/VCENTER_VM_FOLDER"]
|
||||
vcenter_vm_folder_object = nil
|
||||
|
||||
dc = cluster.get_dc
|
||||
if !!vcenter_vm_folder && !vcenter_vm_folder.empty?
|
||||
# Look for folder object
|
||||
vcenter_vm_folder_object = dc.item.find_folder(vcenter_vm_folder)
|
||||
end
|
||||
|
||||
vm_folder = vc_template.parent if vcenter_vm_folder_object.nil?
|
||||
|
||||
if ds.instance_of? RbVmomi::VIM::StoragePod
|
||||
# VM is cloned using Storage Resource Manager for StoragePods
|
||||
begin
|
||||
vm = storagepod_clonevm_task(vc_template, vcenter_name,
|
||||
clone_spec, ds)
|
||||
clone_spec, ds, vcenter_vm_folder_object)
|
||||
rescue Exception => e
|
||||
raise "Cannot clone VM Template to StoragePod: #{e.message}"
|
||||
end
|
||||
@@ -342,7 +355,7 @@ class VirtualMachine
|
||||
vm = nil
|
||||
begin
|
||||
vm = vc_template.CloneVM_Task(
|
||||
:folder => vc_template.parent,
|
||||
:folder => vcenter_vm_folder_object,
|
||||
:name => vcenter_name,
|
||||
:spec => clone_spec).wait_for_completion
|
||||
rescue Exception => e
|
||||
@@ -350,7 +363,7 @@ class VirtualMachine
|
||||
raise "Cannot clone VM Template: #{e.message}\n#{e.backtrace}"
|
||||
end
|
||||
|
||||
vm_folder = cluster.get_dc.vm_folder
|
||||
vm_folder = dc.vm_folder
|
||||
vm_folder.fetch!
|
||||
vm = vm_folder.items
|
||||
.select{|k,v| v.item.name == vcenter_name}
|
||||
@@ -359,7 +372,7 @@ class VirtualMachine
|
||||
if vm
|
||||
vm.Destroy_Task.wait_for_completion
|
||||
vm = vc_template.CloneVM_Task(
|
||||
:folder => vc_template.parent,
|
||||
:folder => vcenter_vm_folder_object,
|
||||
:name => vcenter_name,
|
||||
:spec => clone_spec).wait_for_completion
|
||||
else
|
||||
@@ -374,7 +387,7 @@ class VirtualMachine
|
||||
end
|
||||
|
||||
|
||||
def storagepod_clonevm_task(vc_template, vcenter_name, clone_spec, storpod)
|
||||
def storagepod_clonevm_task(vc_template, vcenter_name, clone_spec, storpod, vcenter_vm_folder_object)
|
||||
|
||||
storage_manager = vc_template
|
||||
._connection.serviceContent.storageResourceManager
|
||||
@@ -382,7 +395,7 @@ class VirtualMachine
|
||||
storage_spec = RbVmomi::VIM.StoragePlacementSpec(
|
||||
type: 'clone',
|
||||
cloneName: vcenter_name,
|
||||
folder: vc_template.parent,
|
||||
folder: vcenter_vm_folder_object,
|
||||
podSelectionSpec: RbVmomi::VIM.StorageDrsPodSelectionSpec(storagePod: storpod),
|
||||
vm: vc_template,
|
||||
cloneSpec: clone_spec
|
||||
|
||||
Reference in new issue
Block a user