Use
Create an instance of VssManager
passing your ITS Private Cloud API access token
and your are all set to start calling any of the self-descriptive methods included:
from pyvss.manager import VssManager
vss = VssManager(tk='api_token')
# list vms
vms = vss.get_vms()
# list folders
folders = vss.get_folders(name='dev')
# networks
networks = vss.get_networks(name='PUBLIC')
# domains
domains = vss.get_domains()
# power cycle vm
vss.power_cycle_vm(vm_id='<uuid-or-moref>')
# vss-service
service = vss.get_vss_services(filter='name,like,%Shibboleth%')
# create vm with vss-service
req = vss.create_vm(
os='ubuntu64Guest', built='os_install',
description='Testing python wrapper',
folder='group-v9270', bill_dept='EIS', disks=[8, 50],
vss_service=service[0].get('id'),
networks=[networks[0].get('moref')]
)
ids = vss.wait_for_request(req['_links']['request'], 'vm_moref', 'PROCESSED')
# creating multiple vms
reqs = vss.create_vms(
count=3, name='python', os='ubuntu64Guest', bill_dept='EIS',
description='Testing multiple deployment from python wrapper',
folder='group-v6736', built='os_install',
networks=[networks[0].get('moref')]
)
ids = [vss.wait_for_request(r['_links']['request'], 'vm_moref', 'PROCESSED') for r in reqs]
# power on recently created vms
for vm_id in ids:
vss.power_on_vm(vm_id)
# create snapshot
req = vss.create_vm_snapshot(
vm_id='5012abcb-a9f3-e112-c1ea-de2fa9dab90a',
desc='Snapshot description',
date_time='2016-08-04 15:30',
valid=1
)
snap_id = vss.wait_for_request(req['_links']['request'], 'snap_id', 'PROCESSED')
# revert to snapshot
req = vss.revert_vm_snapshot(vm_id, snap_id)
An alternative is to generate a token from within the VssManager
class and this can be done
by setting the following environment variables
export VSS_API_USER='username'
export VSS_API_USER_PASS='username_password'
Then, from the VssManager
call the get_token
method as follows:
from pyvss.manager import VssManager
vss = VssManager()
vss.get_token()