Skip to content

Instantly share code, notes, and snippets.

@hartsock
Forked from michaelrice/nic.groovy
Created August 5, 2014 21:14
Show Gist options
  • Save hartsock/e8c6c04adc64d0cbc343 to your computer and use it in GitHub Desktop.
Save hartsock/e8c6c04adc64d0cbc343 to your computer and use it in GitHub Desktop.
// Create the updated device spec
VirtualDeviceConfigSpec nicSpec = new VirtualDeviceConfigSpec()
nicSpec.device = nic
nicSpec.operation = VirtualDeviceConfigSpecOperation.edit
// Create the VM update spec
VirtualMachineConfigSpec spec = new VirtualMachineConfigSpec()
spec.deviceChange = [nicSpec]
// Do the update
try {
Task task = virtualMachine.reconfigVM_Task(spec)
// Wait for it to complete
task.waitForMe()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment