Skip to content

Example 5

Carlos Ruiz Lantero edited this page Oct 10, 2017 · 3 revisions

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
[admin@10.0.0.1] run: ls
>>> vm.ssh('ls', use_sudo=True)
[admin@10.0.0.1] sudo: ls
>>> vm.ssh('ls', quiet=True)
>>> 

Clone this wiki locally