Table of Contents |
---|
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.
...
To work through this tutorial, you will need the following prerequisites:
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
...
First, you can use the AllVirtualMachinesResource to retrieve all your VMs.
cURL:
Code Block |
---|
curl -X GET https://mjsabq.bcn.abiquo.com:443/api/cloud/virtualmachines \ -H 'Accept:application/vnd.abiquo.virtualmachines+json;version=4.2' \ -u user:password --verbose |
...
Code Block |
---|
{ "title": "bcdc_tioco_03_vol_02", "rel": "edit", "type": "application/vnd.abiquo.volume+json", "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/volumes/11" }, |
Check how many disks are on the VM already. The example machine has two disks:
disk0 - the system hard disk on the hypervisor datastore
disk1 - another volume
Change the "rel" link to the disk's new sequence number. In this case it will be disk2
Code Block |
---|
{ "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" }, |
...
Your new VM DTO should look similar to the following example.
Div | ||||
---|---|---|---|---|
| ||||
The Virtual Machine
|
...
|
Reconfigure the VM
Tip |
---|
API DocumentationFor the Abiquo API documentation of this feature, see Abiquo API Resources and the page for this resource EnterpriseResource. |
Perform a put request on the VM with the VM entity that you edited to include the new link.
Here the request data is the modified VM shown above.
...
PUT the virtual machine
Code Block |
---|
curl -X PUT https://mjsabq.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182 \ -H 'Accept: application/vnd.abiquo.acceptedrequest+json;version=4.2' \ -H 'Content-type: application/vnd.abiquo.virtualmachine+json;version=4.2' \ -d @virtualmachine_plus_volume.json -u admin:xabiquo --verbose |
The request will return a link that can be used to check the progress of the task.
...
The task just created
Code Block |
---|
{ "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" } ] } |
...
We can check the progress of the task using:
...
The task
Code Block |
---|
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
|
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" } ] } |
...
Code Block |
---|
curl -X PUT https://mjspac.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182 \ -H 'Accept: application/vnd.abiquo.acceptedrequest+json;version=4.2' \ -H 'Content-type: application/vnd.abiquo.virtualmachine+json;version=4.2' \ -d @virtualmachine_minus_volume.json \ -u admin:xabiquo --verbose |
In a test system, you could use the original VM before you added the volume.
Request payload:
Code Block |
---|
{ "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" }, { "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" } ] } |
...