-
Notifications
You must be signed in to change notification settings - Fork 5
Example 10
Carlos edited this page Aug 4, 2017
·
1 revision
There are a couple of methods that let you do further management. One retrieves all the existing virtual machines that the user can access:
>>> from vcdriver.vm import get_all_virtual_machines
>>> vms = get_all_virtual_machines()
Vcenter session opened with ID 52d75977-360d-0923-39ff-b914fd323d61
Retrieving all Vcenter objects of type "<class 'pyVmomi.VmomiSupport.vim.VirtualMachine'>" ... 0:00:00.317417
>>> vms[5].name
'vm_name'
>>> vms[5].ip()
Waiting for [Get IP] ... 0:01:03.292489
'10.0.0.1'
>>> vms[5].ssh('ls', vcdriver_vm_ssh_username='admin', vcdriver_vm_ssh_password='pass')
[admin@10.0.0.1] run: lsThe other method lets you empty a Vsphere folder. Be careful with this one!
>>> from vcdriver.folder import destroy_virtual_machines
>>> from vcdriver.config import load
>>> load('path/to/vcdriver.ini')
>>> destroy_virtual_machines('folder_name')
Vcenter session opened with ID 52d75977-360d-0923-39ff-b914fd323d61
Waiting for [Power off virtual machine "vm_name1"] ... 0:00:01.084497
Waiting for [Destroy virtual machine "vm_name1"] ... 0:00:01.081120
Waiting for [Power off virtual machine "vm_name2"] ... 0:00:01.084497
Waiting for [Destroy virtual machine "vm_name2"] ... 0:00:01.081120
Waiting for [Power off virtual machine "vm_name3"] ... 0:00:01.084497
Waiting for [Destroy virtual machine "vm_name3"] ... 0:00:01.081120- 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