Skip to content

Instantly share code, notes, and snippets.

@phil-monroe
Created November 14, 2012 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phil-monroe/4074327 to your computer and use it in GitHub Desktop.
Save phil-monroe/4074327 to your computer and use it in GitHub Desktop.
Clone vm with IP
identity = RbVmomi::VIM.CustomizationLinuxPrep({
hostName: RbVmomi::VIM.CustomizationFixedName(name: "test"),
domain: "test.com"
})
global_ip_settings = RbVmomi::VIM.CustomizationGlobalIPSettings({
dnsServerList: ["172.31.10.37"],
dnsSuffixList: ["identified.com"]
})
ip_address = RbVmomi::VIM.CustomizationFixedIp(ipAddress: "172.31.30.38")
ip_settings = RbVmomi::VIM.CustomizationIPSettings ip: ip_address
adapter_mapping = RbVmomi::VIM.CustomizationAdapterMapping adapter: ip_settings
customize_spec = RbVmomi::VIM.CustomizationSpec({
identity: identity,
nicSettingMap: [adapter_mapping],
globalIPSettings: global_ip_settings
})
relocation_spec = RbVmomi::VIM.VirtualMachineRelocateSpec(:pool => resource_pool)
clone_spec = RbVmomi::VIM.VirtualMachineCloneSpec({
location: relocation_spec,
customization: customize_spec,
powerOn: true,
template: false
})
res = vm.CloneVM_Task({
folder: folder,
spec: clone_spec,
name: name
}).wait_for_completion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment