Example 6 - Osirium/vcdriver GitHub Wiki
Virtual machine management: SFTP
SFTP can be used to transfer files between the client and the virtual
machine using the ssh_download
and ssh_upload
methods, which rely on
Fabric's get
and put
respectively.
These methods needs the two SSH configuration values you can find in
the [Virtual Machine Remote Management]
section of the configuration
(See Example 1).
You can also use the use_sudo
and quiet
flags.
>>> 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_upload(remote_path='remote/path', local_path='local/path', use_sudo=True)
Waiting for [Get IP] ... 0:01:03.292489
[[email protected]] put: local/path -> remote/path
>>> vm.ssh_download(remote_path='remote/path', local_path='local/path', quiet=True)
>>>