How to mount a custom ISO to a Virtual Machine

Introduction

The vss-ISOs catalog includes over 130 ISO images stored within our virtual environment to make a faster VM<-->ISO interaction. Users can choose some of the most common Linux distributions, Windows, Solaris, etc. or any other Software like SQL Server. However, if you need to mount temporarily an ISO not listed in our catalog, it can be done by adding a couple of steps to what's been described in the  "ISO Images" guide.  If such an ISO might be of use to others, please email us (vss@eis.utor...) so that it can be added our catalog.

In this guide, we will mount the Debian Live CD debian-live-8.5.0-amd64-gnome-desktop.iso to a virtual machine.

Prerequisites

  1. Valid access token or User and Password
  2. Access to Virtual Machine.
  3. Virtual Machine name.
  4. Copy of iso to mount (debian-live-8.5.0-amd64-gnome-desktop.iso)

Table of Contents

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.

  1. Create an instance of VssManager, generate token via get_token, and create an instance of the webdavclient using get_vskey_stor method as follows:

    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 
  2. Upload the given iso to any given directory or to your home. In this case, we will use the isos folder:

    # 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'}
  3. Get the path to mount in the Virtual Machine 

     

    isos = vss.get_isos(name='debian-live')
    iso = isos[0].get('path')
  4. Get VM and Mount given ISO:

    # 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

  1. Login to vskey-stor here.

  2. Upload the desired iso file  to your account. After uploading you will see the item available in the web interface:

Get ISO path

  1. With your token make a request to the /iso endpoint filtered by name to get the actual ISO path:

    Request
    http GET "https://vss-api.eis.utoronto.ca/v2/iso?name=gnome" "Authorization: Bearer $TK"
    Response Body
    {
        "_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"
        }
    }

    Save [vssUser-xfers] jm/debian-live-8.5.0-amd64-gnome-desktop.iso string, since you'll need this eventually

Mount the ISO

  1. Get virtual machine UUID using the search feature in the /vm resource:

    Request
    http GET "https://vss-api.eis.utoronto.ca/v2/vm?name=vm-testing&summary" "Authorization: Bearer $TK"
    Response Body
    {
        "_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"
        }
    }
  2. 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:

    Request
    http GET "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd/1" "Authorization: Bearer $TK"
    Response Body
    {
        "_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"
        }
    }
  3. 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

    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"
  4. After a few seconds, the ISO file will be mounted and the CD1 would show something like:

    http GET "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd/1" "Authorization: Bearer $TK"
    Response Body
    {
        "_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

 

  1. 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.

    http PUT "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd/1" "Authorization: Bearer $TK" attribute='client' value=''
  2. If the request has been successfully processed, the CD 1 endpoint will show show the following response body:

    http GET "https://vss-api.eis.utoronto.ca/v2/vm/<vm_uuid>/cd/1" "Authorization: Bearer $TK"
    Response Body
    {
        "_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"
        }
    }