mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Merge pull request #419 from puppetlabs/dio-1059
(DIO-1059) Optionally add snapshot tuning params at clone time
This commit is contained in:
commit
217bdd7bd0
3 changed files with 72 additions and 11 deletions
|
|
@ -306,19 +306,26 @@ module Vmpooler
|
|||
|
||||
template_vm_object = find_template_vm(pool, connection)
|
||||
|
||||
extra_config = [
|
||||
{ key: 'guestinfo.hostname', value: new_vmname }
|
||||
]
|
||||
|
||||
if pool.key?('snapshot_mainMem_ioBlockPages')
|
||||
ioblockpages = pool['snapshot_mainMem_ioBlockPages']
|
||||
extra_config.push(
|
||||
{ key: 'mainMem.ioBlockPages', value: ioblockpages }
|
||||
)
|
||||
end
|
||||
if pool.key?('snapshot_mainMem_iowait')
|
||||
iowait = pool['snapshot_mainMem_iowait']
|
||||
extra_config.push(
|
||||
{ key: 'mainMem.iowait', value: iowait }
|
||||
)
|
||||
end
|
||||
|
||||
# Annotate with creation time, origin template, etc.
|
||||
# Add extraconfig options that can be queried by vmtools
|
||||
config_spec = RbVmomi::VIM.VirtualMachineConfigSpec(
|
||||
annotation: JSON.pretty_generate(
|
||||
name: new_vmname,
|
||||
created_by: provider_config['username'],
|
||||
base_template: template_path,
|
||||
creation_timestamp: Time.now.utc
|
||||
),
|
||||
extraConfig: [
|
||||
{ key: 'guestinfo.hostname', value: new_vmname }
|
||||
]
|
||||
)
|
||||
config_spec = create_config_spec(new_vmname, template_path, extra_config)
|
||||
|
||||
# Check if alternate network configuration is specified and add configuration
|
||||
if pool.key?('network')
|
||||
|
|
@ -358,6 +365,18 @@ module Vmpooler
|
|||
vm_hash
|
||||
end
|
||||
|
||||
def create_config_spec(vm_name, template_name, extra_config)
|
||||
RbVmomi::VIM.VirtualMachineConfigSpec(
|
||||
annotation: JSON.pretty_generate(
|
||||
name: vm_name,
|
||||
created_by: provider_config['username'],
|
||||
base_template: template_name,
|
||||
creation_timestamp: Time.now.utc
|
||||
),
|
||||
extraConfig: extra_config
|
||||
)
|
||||
end
|
||||
|
||||
def create_relocate_spec(target_datastore, target_datacenter_name, pool_name, connection)
|
||||
pool = pool_config(pool_name)
|
||||
target_cluster_name = get_target_cluster_from_config(pool_name)
|
||||
|
|
|
|||
|
|
@ -689,6 +689,37 @@ EOT
|
|||
expect(result['name']).to eq(vmname)
|
||||
end
|
||||
end
|
||||
|
||||
context 'Given valid snapshot tuning settings' do
|
||||
let(:folder_object) { mock_RbVmomi_VIM_Folder({ :name => 'pool1'}) }
|
||||
let(:now) { Time.now }
|
||||
let(:config_spec) {
|
||||
[
|
||||
{ key: 'guestinfo.hostname', value: vmname },
|
||||
{ key: 'mainMem.ioBlockPages', value: '300' },
|
||||
{ key: 'mainMem.iowait', value: '2' }
|
||||
]
|
||||
}
|
||||
|
||||
before(:each) do
|
||||
template_vm = new_template_object
|
||||
allow(subject).to receive(:find_template_vm).and_return(new_template_object)
|
||||
allow(template_vm).to receive(:CloneVM_Task).and_return(clone_vm_task)
|
||||
allow(clone_vm_task).to receive(:wait_for_completion).and_return(new_vm_object)
|
||||
allow(subject).to receive(:find_vm_folder).and_return(folder_object)
|
||||
allow(Time).to receive(:now).and_return(Time.now)
|
||||
config[:pools][0]['snapshot_mainMem_ioBlockPages'] = '300'
|
||||
config[:pools][0]['snapshot_mainMem_iowait'] = '2'
|
||||
end
|
||||
|
||||
it 'should apply the appropriate extraConfig settings' do
|
||||
result = subject.create_config_spec(vmname, "template1", config_spec)
|
||||
expect(result.extraConfig).to include(
|
||||
{ :key => 'mainMem.ioBlockPages', :value => '300' },
|
||||
{ :key => 'mainMem.iowait', :value => '2'}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#set_network_device' do
|
||||
|
|
|
|||
|
|
@ -654,6 +654,15 @@
|
|||
# The datacenter within vCenter to manage VMs.
|
||||
# (optional: default is the first datacenter in vSphere)
|
||||
#
|
||||
# - snapshot_mainMem_ioBlockPages
|
||||
# Provisions VMs with the option "mainMem.ioBlockPages". This setting can be useful
|
||||
# (paired with mainMem.iowait below) for tuning the performance of snapshot management actions.
|
||||
# See: https://kb.vmware.com/s/article/76687
|
||||
#
|
||||
# - snapshot_mainMem_iowait
|
||||
# Provisions VMs with the option "mainMem.iowait". This setting can be useful
|
||||
# for tuning the performance of snapshot management actions
|
||||
#
|
||||
# Example:
|
||||
|
||||
:pools:
|
||||
|
|
@ -677,3 +686,5 @@
|
|||
ready_ttl: 1440
|
||||
provider: vsphere
|
||||
create_linked_clone: false
|
||||
snapshot_mainMem_ioBlockPages: '2048'
|
||||
snapshot_mainMem_iowait: '0'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue