Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This simple walkthrough shows how to reconfigure a VM, in this case we will add a volume of external storage using the API in Private cloud.

Prerequisites

This tutorial should be used in a test environment. You can set up the following basic environment in the GUI and then work on the tutorial using the API. After you have finished, you should see the new volume on your VM.

...

  • A deployed VM that is powered off, unless you are working with hot-add and hot-reconfigure on ESXi. A VM with a volume attached.
  • A storage device and a volume that is not attached to a VM
    • Tip: for a test system, enable the creation of small volumes through the GUI by setting sizes of 0.1, 0.2 GB in Configuration view
  • The API ID number of your enterprise and datacenter
  • A user with appropriate privileges. If you are a CLOUD_ADMIN or ENTERPRISE_ADMIN user, no extra privileges are required. Otherwise, add the following privileges, see privilege definitions.
    • ROLE_VDC_ENUMERATE

    • VDC_MANAGE_STORAGE

    • ROLE_VDC_MANAGE_VAPP

    • ROLE_VAPP_CUSTOMISE_SETTINGS

Preparation

First, you can use the AllVirtualMachinesResource to retrieve all your VMs. 

...

From this response we can see that the there is a volume with an ID of 9.

Retrieve

...

available volumes in an

...

enterprise's

...

virtual datacenter

In the VM DTO above, look for the link to the virtual datacenter.

...

From the above response, we will work with the volume "bcdc_tioco_03_vol_02", which has an ID of 11.

Edit the VM

Copy the volume edit link from the volume you wish to attach to the VM from the above response object.

...

Div
classwidecode tinycode



Expand
titleClick here to show or hide the API response example



Code Block
languagehtml/xml
titleThe Virtual Machine
        {
            "id": 182,
            "uuid": "743bfe9e-1e6a-47ee-8146-27bbddc2f3cb",
            "name": "ABQ_743bfe9e-1e6a-47ee-8146-27bbddc2f3cb",
            "label": "yVM_01",
            "fqdn": "box",
            "description": "A virtual machine",
            "cpu": 1,
            "ram": 48,
            "vdrpEnabled": true,
            "vdrpPort": 5914,
            "vdrpIP": "192.168.2.54",
            "idState": 6,
            "state": "OFF",
            "idType": 0,
            "type": "MANAGED",
            "highDisponibility": 0,
            "password": "xXs0fVBf",
            "metadata": null,
            "monitored": false,
            "monitoringLevel": "DEFAULT",
            "protected": false,
            "variables": {},
            "creationTimestamp": 1514900489000,
            "backuppolicies": [],
            "lastSynchronize": 1514904162000,
            "generateGuestInitialPassword": false,
            "links": [
                {
                    "title": "VMX_04",
                    "rel": "machine",
                    "type": "application/vnd.abiquo.machine+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/datacenters/4/racks/4/machines/2"
                },
                {
                    "title": "BCDC",
                    "rel": "location",
                    "type": "application/vnd.abiquo.datacenter+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/locations/4"
                },
                {
                    "title": "ABQ_743bfe9e-1e6a-47ee-8146-27bbddc2f3cb",
                    "rel": "edit",
                    "type": "application/vnd.abiquo.virtualmachine+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182"
                },
                {
                    "title": "send mail",
                    "rel": "sendmail",
                    "type": "application/vnd.abiquo.mail+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/datacenters/4/racks/4/machines/2/virtualmachines/182/action/sendmail"
                },
                {
                    "title": "Tioco",
                    "rel": "enterprise",
                    "type": "application/vnd.abiquo.enterprise+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2"
                },
                {
                    "title": "Cloud Administrator",
                    "rel": "user",
                    "type": "application/vnd.abiquo.user+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/users/1"
                },
                {
                    "title": "bcdc_tioco_03",
                    "rel": "virtualdatacenter",
                    "type": "application/vnd.abiquo.virtualdatacenter+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3"
                },
                {
                    "title": "bcdc_tioco_03_02",
                    "rel": "virtualappliance",
                    "type": "application/vnd.abiquo.virtualappliance+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4"
                },
                {
                    "title": "metadata",
                    "rel": "metadata",
                    "type": "application/vnd.abiquo.metadata+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/metadata"
                },
                {
                    "title": "vlan network configurations",
                    "rel": "configurations",
                    "type": "application/vnd.abiquo.virtualmachinenetworkconfigurations+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/network/configurations"
                },
                {
                    "title": "192.168.0.0/24",
                    "rel": "network_configuration",
                    "type": "application/vnd.abiquo.virtualmachinenetworkconfiguration+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/network/configurations/3"
                },
                {
                    "title": "nics",
                    "rel": "nics",
                    "type": "application/vnd.abiquo.nics+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/network/nics"
                },
                {
                    "title": "disks",
                    "rel": "harddisks",
                    "type": "application/vnd.abiquo.harddisks+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/storage/disks"
                },
                {
                    "title": "OFF",
                    "rel": "state",
                    "type": "application/vnd.abiquo.virtualmachinestate+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/state"
                },
                {
                    "title": "virtual machine undeploy",
                    "rel": "undeploy",
                    "type": "application/vnd.abiquo.acceptedrequest+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/action/undeploy"
                },
                {
                    "title": "virtual machine deploy",
                    "rel": "deploy",
                    "type": "application/vnd.abiquo.acceptedrequest+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/action/deploy"
                },
                {
                    "title": "virtual machine reset",
                    "rel": "reset",
                    "type": "application/vnd.abiquo.acceptedrequest+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/action/reset"
                },
                {
                    "title": "virtual machine snapshot",
                    "rel": "instance",
                    "type": "application/vnd.abiquo.acceptedrequest+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/action/instance"
                },
                {
                    "title": "remote access",
                    "rel": "rdpaccess",
                    "type": "application/vnd.abiquo.virtualmachineconsole+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/config/rdpaccess"
                },
                {
                    "title": "tasks",
                    "rel": "tasks",
                    "type": "application/vnd.abiquo.tasks+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/tasks"
                },
                {
                    "title": "firewalls",
                    "rel": "firewalls",
                    "type": "application/vnd.abiquo.links+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/firewalls"
                },
                {
                    "title": "load balancers",
                    "rel": "loadbalancers",
                    "type": "application/vnd.abiquo.loadbalancers+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/loadbalancers"
                },
                {
                    "title": "request on demand backup",
                    "rel": "requestbackup",
                    "type": "application/vnd.abiquo.ondemandbackup+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/backup/action/request"
                },
                {
                    "title": "request a restore of a backup",
                    "rel": "requestrestore",
                    "type": "application/vnd.abiquo.restore+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/backup/action/restore"
                },
                {
                    "title": "relocate candidates",
                    "rel": "relocatecandidates",
                    "type": "application/vnd.abiquo.links+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/action/relocatecandidates"
                },
                {
                    "title": "relocate",
                    "rel": "relocate",
                    "type": "application/vnd.abiquo.acceptedrequest+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/action/relocate"
                },
                {
                    "title": "volumes",
                    "rel": "volumes",
                    "type": "application/vnd.abiquo.volumes+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/storage/volumes"
                },
                {
                    "title": "bcdc_tioco_03_vol_02",
                    "rel": "disk2",
                    "type": "application/vnd.abiquo.volume+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/volumes/11"
                }, 
                {
                    "diskController": "paravirtual",
                    "diskControllerType": "SCSI",
                    "length": "51",
                    "title": "bcdc_tioco_03_vol_01",
                    "rel": "disk1",
                    "type": "application/vnd.abiquo.volume+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/volumes/9"
                },
                {
                    "diskAllocation": "THIN",
                    "diskControllerType": "IDE",
                    "diskLabel": "Hard disk 1",
                    "length": "64",
                    "title": "bbda1534-5e6c-4d47-8482-c282f383fabd",
                    "rel": "disk0",
                    "type": "application/vnd.abiquo.harddisk+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/disks/6"
                },
                {
                    "title": "Default Tier",
                    "rel": "datastoretier0",
                    "type": "application/vnd.abiquo.datastoretier+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/locations/4/datastoretiers/4"
                },
                {
                    "title": "192.168.0.2",
                    "rel": "nic0",
                    "type": "application/vnd.abiquo.privateip+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/privatenetworks/3/ips/7"
                },
                {
                    "title": "protect",
                    "rel": "protect",
                    "type": "text/plain",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/action/protect"
                },
                {
                    "title": "unprotect",
                    "rel": "unprotect",
                    "type": "text/plain",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/action/unprotect"
                },
                {
                    "title": "metricsmetadata",
                    "rel": "metricsmetadata",
                    "type": "application/vnd.abiquo.metricsmetadata+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/metrics"
                },
                {
                    "title": "enablemonitoring",
                    "rel": "enablemonitoring",
                    "type": "",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/enablemonitoring"
                },
                {
                    "title": "collectd",
                    "rel": "collectd",
                    "type": "application/json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/metrics/collectd"
                },
                {
                    "title": "alarms",
                    "rel": "alarms",
                    "type": "application/vnd.abiquo.alarms+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/alarms"
                },
                {
                    "title": "actionplans",
                    "rel": "actionplans",
                    "type": "application/vnd.abiquo.virtualmachineactionplans+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/actionplans"
                },
                {
                    "title": "actionplansflat",
                    "rel": "actionplansflat",
                    "type": "application/vnd.abiquo.virtualmachineactionplansflat+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/actionplans"
                },
                {
                    "title": "clone",
                    "rel": "clone",
                    "type": "application/vnd.abiquo.virtualmachinecloneoptions+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/action/clone"
                },
                {
                    "title": "VMware vCenter",
                    "rel": "hypervisortype",
                    "type": "application/vnd.abiquo.hypervisortype+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/config/hypervisortypes/VMX_04"
                },
                {
                    "title": "yVM",
                    "rel": "virtualmachinetemplate",
                    "type": "application/vnd.abiquo.virtualmachinetemplate+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/4/virtualmachinetemplates/1"
                },
                {
                    "title": "Others",
                    "rel": "category",
                    "type": "application/vnd.abiquo.category+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/config/categories/1"
                }
            ]
        }

 






Reconfigure the VM


Tip
titleAPI Documentation

For the Abiquo API documentation of this feature, see Abiquo API Resources and the page for this resource EnterpriseResource.

...

Code Block
titleTHE Task just created
{
    "message": "You can keep track of the progress in the link",
    "links": [
        {
            "rel": "status",
            "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/tasks/11ffdcb8-82c7-47f3-9c54-02c702e02a0d"
        }
    ]
}


Check

...

progress

We can check the progress of the task using:

Code Block
titleThe Tasktask
curl -X GET https://mjsabq.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/186/tasks/b6f195f4-7337-4f8e-acd7-73f60fa43c41 \
     -u admin:xabiquo --verbose

...

Expand


Code Block
{
    "taskId": "11ffdcb8-82c7-47f3-9c54-02c702e02a0d",
    "userId": "1",
    "type": "RECONFIGURE",
    "ownerId": "182",
    "state": "FINISHED_SUCCESSFULLY",
    "creationTimestamp": 1514906797,
    "timestamp": 1514906804,
    "jobs": {
        "links": [],
        "collection": [
            {
                "id": "11ffdcb8-82c7-47f3-9c54-02c702e02a0d.8b40afd0-9483-4c96-b173-9ab746c3913d",
                "parentTaskId": "11ffdcb8-82c7-47f3-9c54-02c702e02a0d",
                "type": "UPDATE_RESOURCES",
                "description": "UPD-OK - Update resources OK",
                "state": "DONE",
                "rollbackState": "UNKNOWN",
                "creationTimestamp": 1514906797,
                "timestamp": 1514906797,
                "links": []
            },
            {
                "id": "11ffdcb8-82c7-47f3-9c54-02c702e02a0d.4ab35b47-f65a-41f8-b8fc-3d6388555eb8",
                "parentTaskId": "11ffdcb8-82c7-47f3-9c54-02c702e02a0d",
                "type": "RECONFIGURE",
                "description": "Reconfigure task's reconfigure on virtual machine with id 182",
                "state": "DONE",
                "rollbackState": "UNKNOWN",
                "creationTimestamp": 1514906797,
                "timestamp": 1514906804,
                "links": []
            }
        ]
    },
    "links": [
        {
            "rel": "self",
            "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/tasks/11ffdcb8-82c7-47f3-9c54-02c702e02a0d"
        },
        {
            "rel": "parent",
            "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/tasks"
        },
        {
            "rel": "result",
            "type": "application/vnd.abiquo.virtualmachine+json",
            "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182"
        },
        {
            "title": "admin",
            "rel": "user",
            "type": "application/vnd.abiquo.user+json",
            "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/users/1"
        },
        {
            "title": "ABQ_743bfe9e-1e6a-47ee-8146-27bbddc2f3cb",
            "rel": "virtualmachine",
            "type": "application/vnd.abiquo.virtualmachine+json",
            "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182"
        }
    ]
}


Check the

...

volume is

...

attached

Get the VM and check that the disk2 link is present.

...

Code Block
        {
            "diskController": "paravirtual",
            "diskControllerType": "SCSI",
            "length": "51",
            "title": "bcdc_tioco_03_vol_02",
            "rel": "disk2",
            "type": "application/vnd.abiquo.volume+json",
            "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/volumes/11"
        }, 

 

Detach the

...

volume

To detach a volume, remove the volume link from the DTO and perform a put request for the VM.

...