Revision 952ad8c1
Added by Ivan Necas over 8 years ago
app/models/compute_resources/foreman/model/vmware.rb | ||
---|---|---|
# Fog calls +cluster.resourcePool.find("Resources")+ that actually calls
|
||
# +searchIndex.FindChild("Resources")+ in RbVmomi that then returns nil
|
||
# because it has no children.
|
||
def clone_vm(args)
|
||
args = parse_args args
|
||
def clone_vm(raw_args)
|
||
args = parse_args(raw_args)
|
||
path_replace = %r{/[^/]+/#{datacenter}/vm(/|)}
|
||
|
||
interfaces = client.list_vm_interfaces(args[:image_id])
|
||
interface = interfaces.detect{|i| i[:name].end_with?('1') }
|
||
network_adapter_device_key = interface[:key]
|
||
|
||
opts = {
|
||
"datacenter" => datacenter,
|
||
"template_path" => args[:image_id],
|
||
... | ... | |
"numCPUs" => args[:cpus],
|
||
"memoryMB" => args[:memory_mb],
|
||
"datastore" => args[:volumes].first[:datastore],
|
||
"network_label" => args[:interfaces].first[:network],
|
||
"nic_type" => args[:interfaces].first[:type],
|
||
"network_adapter_device_key" => network_adapter_device_key
|
||
}
|
||
|
||
vm_model = new_vm(raw_args)
|
||
opts['interfaces'] = vm_model.interfaces
|
||
opts['volumes'] = vm_model.volumes
|
||
opts["customization_spec"] = client.cloudinit_to_customspec(args[:user_data]) if args[:user_data]
|
||
client.servers.get(client.vm_clone(opts)['new_vm']['id'])
|
||
end
|
Also available in: Unified diff
Fixes #9704,#9705 - ability to customize vmware VM on image-based provisioning
Allows applying the changes form the form to the VM when cloning from
a template.
Depends on https://github.com/fog/fog/pull/3570