(DIO-1059) Optionally add snapshot tuning params at clone time

This commit is contained in:
suckatrash 2020-10-13 13:16:59 -07:00
parent a42ed6cb5d
commit b2ac53fa76
No known key found for this signature in database
GPG key ID: 3857A763831B0756
3 changed files with 72 additions and 11 deletions

View file

@ -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)