Example 5 - Osirium/vcdriver GitHub Wiki
Virtual machine management: SSH
Remote machines can be managed with SSH. This method needs the two
corresponding configuration values you can find in the [Virtual Machine Remote Management]
section of the configuration (See
Example 1).
You can use the use_sudo
and quiet
modes, as per the example.
>>> 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.ssh('ls')
Waiting for [Get IP] ... 0:01:03.292489
[[email protected]] run: ls
>>> vm.ssh('ls', use_sudo=True)
[[email protected]] sudo: ls
>>> vm.ssh('ls', quiet=True)
>>>