def create_vm attributes = { }
vm_cfg = {
:name => attributes[:name],
:guestId => attributes[:guest_id],
:files => { :vmPathName => vm_path_name(attributes) },
:numCPUs => attributes[:cpus],
:memoryMB => attributes[:memory_mb],
:deviceChange => device_change(attributes),
:extraConfig => extra_config(attributes),
}
resource_pool = if attributes[:resource_pool]
get_raw_resource_pool(attributes[:resource_pool], attributes[:cluster], attributes[:datacenter])
else
get_raw_cluster(attributes[:cluster], attributes[:datacenter]).resourcePool
end
vmFolder = get_raw_vmfolder(attributes[:path], attributes[:datacenter])
vm = vmFolder.CreateVM_Task(:config => vm_cfg, :pool => resource_pool).wait_for_completion
vm.config.instanceUuid
rescue => e
raise e, "failed to create vm: #{e}"
end