Libraries
Introduction
Programming libraries wrapping the ITS Private Cloud API.
VSS Command Line Interface (vss-cli)
The VSS Command Line Interface is a unified tool to manage your ITS Private Cloud services.
Table of Contents
Install
The easiest way to install vss-cli is to use pip:
pip install vss-cli
or, if you are not installing in a virtual environment:
pip install --user vss-cli
This will install the vss-cli package as well as all dependencies. You can also just download tarball.
Once you have the vsscli directory structure on your workstation, you can just run:
cd <path_to_vsscli> python setup.py install
Usage
Before using vss-cli, you need to tell it about your VSS credentials. You can do this in a couple of ways:
- Environment variables
- Config file
The quickest way to get started is to run the vss-cli configure mk command:
vss configure mk Endpoint [https://cloud-api.eis.utoronto.ca]: Endpoint Name [cloud-api]: Username: username Password: Repeat for confirmation: Successfully configured credentials for https://cloud-api.eis.utoronto.ca. You are ready to use the vss-cli
Docker
docker run -it -v ~/:/root/ -v ~/Downloads:/data uofteis/vss-cli sh / # vss-cli configure Endpoint [https://cloud-api.eis.utoronto.ca]: Endpoint Name [cloud-api]: Username: username Password: Repeat for confirmation: Successfully configured credentials for https://cloud-api.eis.utoronto.ca. You are ready to use the vss-cli
For more information, please take a look at the GitLab repo or PyPI.
Python client for the ITS Private Cloud APIÂ
 The python client allows you to interact with the API using self-descriptive methods.
Install
Installing the library is quite simple. Either clone the GitLab repository or download the source code or use pip to do everything for you:
# pip python3 -m venv ~/venvs/pyvss . ~/VirtualEnvs/pyvss/activate pip3 install pyvss  # git git clone https://gitlab.eis.utoronto.ca/vss/py-vss cd py-vss python setup.py install
Docker
If you prefer running your scripts in a docker container, the uofteis/pyvss image is the solution. It's based on Alpine Linux with Python 2.7.12 and works as follows:
# with access token docker run -it -v .:/data -e VSS_API_TOKEN=token_here uofteis/pyvss # user and pass docker run -it -v .:/data -e VSS_API_USER=user_here -e VSS_API_USER_PASS=user_pass_here uofteis/pyvss # env file containing either VSS_API_USER and VSS_API_USER_PASS or VSS_API_TOKEN docker run -it -v .:/data --env-file vss.env uofteis/pyvss
Usage
Creating a virtual machine is as easy as calling the create_vm method as follows:
from pyvss.manager import VssManager vss = VssManager(tk='api_token') Â # get vms vms = vss.get_vms() Â # create vm req = vss.create_vm(os='ubuntu64Guest', built='os_install', description='Testing python wrapper', folder='group-v6736', client='EIS', disks=[100, 100]) uuid = vss.wait_for_request(req['_links']['request'], 'vm_uuid', 'Processed')
By setting the VSS_API_TOKEN environment variable and then executing the manager.py script and using as input args the function name followed by any parameters, the response is displayed to stdout.
python pyvss/manager.py get_vms 'summary=1&name=pm' [{u'_links': {u'self': u'https://vss-api.eis.utoronto.ca:8001/v2/vm/<vm_uuid>'}, u'cpuCount': 2, u'folder': {u'_links': {u'self': u'https://vss-api.eis.utoronto.ca:8001/v2/folder/group-v519'}, u'moref': u'group-v519', u'name': u'Public', u'parent': u'API'}, u'guestFullName': u'Ubuntu Linux (64-bit)', u'ipAddress': u'<ip_addr>', u'memoryMB': 4096, u'name': u'1502P-pm', u'overallStatus': u'green', u'powerState': u'poweredOn', u'storageB': 96637166467, u'uuid': u'<vm_uuid>'}]