Step-by-step guide with PyVss
This section assumes, you have already set up both VSS_API_USER and VSS_API_USER_PASS environment variables and installed PyVss.
Create an instance of VssManager, generate token via get_token, and create an instance of the webdavclient using get_vskey_stor method as follows:
Code Block from pyvss.manager import VssManager vss = VssManager(None) vss.get_token() # generates token vss.get_vskey_stor() # creates a WebDav Client instance to interact with VSKEY-STOR
Upload the given iso to any given directory or to your home. In this case, we will use the isos folder:
Code Block # upload vss.vskey_stor.upload_sync(local_path='~/Downloads/debian-live-8.6.0-amd64-gnome-desktop.iso', remote_path='isos/debian-live-8.6.0-amd64-gnome-desktop.iso') # check if uploaded vss.vskey_stor.info('isos/debian-live-8.6.0-amd64-gnome-desktop.iso') {'created': None, 'name': None, 'modified': 'Tue, 01 Nov 2016 13:49:31 GMT', 'size': '1394147328'}
- Get the path to mount in the Virtual Machine
Code Block isos = vss.get_isos(name='debian-live') iso = isos[0].get('path')
Get VM and Mount given ISO:
Code Block # get target vm uuid vms = vss.get_vms(name='vm-testing') uuid = vms[0].get('uuid') # submit change request r = vss.update_vm_cd(uuid=uuid, cd=1, iso=iso) # wait for request to be processed completed = vss.wait_for_request(request_url=r.get('_links').get('request'), request_attr='status', required_status='Processed')
Step-by-step guide with API Calls
Upload ISO to VSKEY-STOR
Login to vskey-stor here.
Upload the desired iso file to your account. After uploading you will see the item available in the web interface:
Get ISO path
With your token make a request to the /iso endpoint filtered by name to get the actual ISO path:
Code Block language bash title Request http GET "https://vss-api.eis.utoronto.ca/v2/iso?name=gnome" "Authorization: Bearer $TK"
Code Block language py title Response Body collapse true { "_links": { "api": "https://vss-api.eis.utoronto.ca/v2/", "self": "https://vss-api.eis.utoronto.ca/v2/iso" }, "data": [ { "name": "debian-live-8.5.0-amd64-gnome-desktop", "path": "[vssUser-xfers] jm/debian-live-8.5.0-amd64-gnome-desktop.iso" } ], "meta": { "count": 1, "time": "1.33549s", "user": "jm" } }
Tip Save [vssUser-xfers] jm/debian-live-8.5.0-amd64-gnome-desktop.iso string, since you'll need this eventually
Mount the ISO
Get virtual machine UUID using the search feature in the /vm resource:
Code Block language bash title Request http GET "https://vss-api.eis.utoronto.ca/v2/vm?name=vm-testing&summary" "Authorization: Bearer $TK"
Code Block language py title Response Body collapse true { "_links": { "api": "https://vss-api.eis.utoronto.ca/v2/", "self": "https://vss-api.eis.utoronto.ca/v2/vm" }, "data": [ { "_links": { "self": "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>" }, "name": "1606D-vm-testing", "uuid": "<vm_uuid>" } ], "meta": { "count": 1, "time": "1.13983s", "user": "josem" } }
Now, we need to verify CD 1 settings, specifically the backing attribute in the data object which has to be set to "client" by default:
Code Block language bash title Request http GET "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd/1" "Authorization: Bearer $TK"
Code Block language py title Response Body collapse true { "_links": { "self": "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd/1", "vm": "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd" }, "data": [ { "backing": "client", "connected": "Disconnected", "controller": { "type": "IDE 1", "virtualDeviceNode": "IDE 1:0" }, "description": "Remote device CD-ROM 1", "key": 3002, "label": "CD/DVD drive 1", "unit": 0 } ], "meta": { "count": 1, "time": "0.04656s", "user": "jm" } }
To update CD 1 backend according to the docs, it can be done by making a PUT request to the /vm/<vm_uuid>/cd/1 endpoint with the attribute set to iso and value set to the ISO path, in this case [vssUser-xfers] jm/debian-live-8.5.0-amd64-gnome-desktop.iso
Code Block http PUT "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd/1" attribute='iso' value="[vssUser-xfers] jm/debian-live-8.5.0-amd64-gnome-desktop.iso" "Authorization: Bearer $TK"
After a few seconds, the ISO file will be mounted and the CD1 would show something like:
Code Block http GET "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd/1" "Authorization: Bearer $TK"
Code Block language py title Response Body collapse true { "_links": { "self": "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd/1", "vm": "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd" }, "data": [ { "backing": "[vssUser-xfers] jm/debian-live-8.5.0-amd64-gnome-desktop.iso", "connected": "Connected", "controller": { "type": "IDE 1", "virtualDeviceNode": "IDE 1:0" }, "description": "ISO [vssUser-xfers] jm/debian-live-8.5.0-amd64-gnome-desktop.iso", "key": 3002, "label": "CD/DVD drive 1", "unit": 0 } ], "meta": { "count": 1, "time": "0.04492s", "user": "jm" } }
Unmount the ISO
Once the ISO file is no longer required, you can unmount it by making a PUT request to the same endpoint /vm/<vm_uuid>/cd/1 with attribute set to client and value set to empty.
Code Block http PUT "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd/1" "Authorization: Bearer $TK" attribute='client' value=''
If the request has been successfully processed, the CD 1 endpoint will show show the following response body:
Code Block http GET "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd/1" "Authorization: Bearer $TK"
Code Block language py title Response Body collapse true { "_links": { "self": "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd/1", "vm": "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd" }, "data": [ { "backing": "client", "connected": "Disconnected", "controller": { "type": "IDE 1", "virtualDeviceNode": "IDE 1:0" }, "description": "Remote device", "key": 3002, "label": "CD/DVD drive 1", "unit": 0 } ], "meta": { "count": 1, "time": "0.04782s", "user": "jm" } }
Related articles
Filter by label (Content by label) | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Page Properties | ||
---|---|---|
| ||
|