-
Notifications
You must be signed in to change notification settings - Fork 5
Example 4
Carlos edited this page Aug 4, 2017
·
1 revision
Virtual machines can be destroyed easily with the idempotent destroy
method.
>>> from vcdriver.vm import VirtualMachine
>>> from vcdriver.config import load
>>> load('path/to/vcdriver.ini')
>>> vm = VirtualMachine(name='vm_name', template='vm_template')
>>> vm.create()
Vcenter session opened with ID 52d75977-360d-0923-39ff-b914fd323d61
Waiting for [Create virtual machine "vm_name" from template "vm_template"] ... 0:00:10.074632
>>> vm.destroy()
Waiting for [Power off virtual machine "vm_name"] ... 0:00:01.327433
Waiting for [Destroy virtual machine "vm_name"] ... 0:00:01.019329There are three idempotent power methods that don't rely on Vmwaretools:
power_on, power_off and reset.
>>> from vcdriver.vm import VirtualMachine
>>> from vcdriver.config import load
>>> load('path/to/vcdriver.ini')
>>> vm = VirtualMachine(name='vm_name', template='vm_template')
>>> vm.create()
Vcenter session opened with ID 52d75977-360d-0923-39ff-b914fd323d61
Waiting for [Create virtual machine "vm_name" from template "vm_template"] ... 0:00:10.074632
>>> vm.power_off()
Waiting for [Power off virtual machine "vm_name"] ... 0:00:01.183452
>>> vm.power_on()
Waiting for [Power on virtual machine "vm_name"] ... 0:00:01.678678
>>> vm.reset()
Waiting for [Reset virtual machine "vm_name"] ... 0:00:01.345543reboot and shutdown methods need Vmware tools. These methods are
async, that is, they are not blocking, they just trigger the OS call.
>>> from vcdriver.vm import VirtualMachine
>>> from vcdriver.config import load
>>> load('path/to/vcdriver.ini')
>>> vm = VirtualMachine(name='vm_name', template='vm_template')
>>> vm.create()
Vcenter session opened with ID 52d75977-360d-0923-39ff-b914fd323d61
Waiting for [Create virtual machine "vm_name" from template "vm_template"] ... 0:00:10.074632
>>> vm.reboot()
Waiting for [Vmware tools readiness] ... 0:00:01.884545
>>> vm.shutdown()
Waiting for [Vmware tools readiness] ... 0:00:01.137234- Example 1: Setting up vcdriver
- Example 2: Managing the session
- Example 3: Creating and finding virtual machines
- Example 4: Destroying virtual machines and power methods
- Example 5: Virtual machine management: SSH
- Example 6: Virtual machine management: SFTP
- Example 7: Virtual machine management: WinRM
- Example 8: Snapshots
- Example 9: Using vcdriver for testing
- Example 10: Further management