Versions Compared

Key

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

Table of Contents

...

To continue working with the same VM that you deployed in the last tutorial, you will need to undeploy the VM and delete its NIC, which you can easily do with the Abiquo UI. Or you can create a new VM for this tutorial.

...


Modify an entity using the API

Because the VM entity is a special case, we are going to look at two types of modifications: configuring a VM and changing the state of a VM.

...

  1. Open the browser console to the Network tab and record actions
  2. Edit the VM and go to NetworkPrivate → select network → drag an IP address into the NICs panel, and Save 
  3. Examine the PUT request and look for the link to the NIC and expand itin the expanded VM response. It will probably be at the end of the links section.

Image Modified

Tip
titleDeployed VMs

If your VM has been deployed, then it will already have a NIC. To work with a deployed VM, you may need to create another private network, because by default, you may not be able to add two NICs in the same private network. To change the configuration of a deployed VM, if the VM doesn't have network hot-reconfigure, then you will need to shut it down first.

...

Expand


Code Block
 {
  "id": 19454,
  "uuid": "2fb11009-8157-4d61-915d-40fa45f440ac",
  "fqdn": "box.localdomain",
  "description": "A virtual machine",
  "coresPerSocket": 1,
  "idState": 1,
  "idType": 0,
  "type": "MANAGED",
  "highDisponibility": 0,
  "monitored": false,
  "monitoringLevel": "DEFAULT",
  "protected": false,
  "variables": {},
  "backuppolicies": [],
  "lastSynchronize": 1596032874000,
  "generateGuestInitialPassword": false,
  "natrules": [],
  "vdrpEnabled": true,
  "vdrpPort": 0,
  "password": "ybu1f6iT",
  "deallocated": false,
  "name": "ABQ_2fb11009-8157-4d61-915d-40fa45f440ac",
  "label": "yVM_New",
  "ram": 48,
  "cpu": 1,
  "state": "NOT_ALLOCATED",
  "creationTimestamp": 1596029202000,
  "links": [
    {
      "title": "5.1.0_Snapshot Enterprise testing",
      "rel": "enterprise",
      "type": "application/vnd.abiquo.enterprise+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/admin/enterprises/336"
    },
    {
      "title": "ABQ_2fb11009-8157-4d61-915d-40fa45f440ac",
      "rel": "edit",
      "type": "application/vnd.abiquo.virtualmachine+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454"
    },
    {
      "rel": "asynctasks",
      "type": "application/vnd.abiquo.asynctasks+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/asynctasks"
    },
    {
      "title": "send mail",
      "rel": "sendmail",
      "type": "application/vnd.abiquo.mail+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/admin/publiccloudregions/1/enterprises/336/virtualmachines/19454/action/sendmail"
    },
    {
      "title": "cloudadmin cloudadmin",
      "rel": "user",
      "type": "application/vnd.abiquo.user+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/admin/enterprises/336/users/10"
    },
    {
      "title": "vdc_api_tutorial",
      "rel": "virtualdatacenter",
      "type": "application/vnd.abiquo.virtualdatacenter+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486"
    },
    {
      "title": "vap_api_tutorial",
      "rel": "virtualappliance",
      "type": "application/vnd.abiquo.virtualappliance+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990"
    },
    {
      "title": "metadata",
      "rel": "metadata",
      "type": "application/vnd.abiquo.metadata+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/metadata"
    },
    {
      "title": "vlan network configurations",
      "rel": "configurations",
      "type": "application/vnd.abiquo.virtualmachinenetworkconfigurations+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/network/configurations"
    },
    {
      "title": "nics",
      "rel": "nics",
      "type": "application/vnd.abiquo.nics+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/network/nics"
    },
    {
      "title": "disks",
      "rel": "harddisks",
      "type": "application/vnd.abiquo.harddisks+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/storage/disks"
    },
    {
      "title": "NOT_ALLOCATED",
      "rel": "state",
      "type": "application/vnd.abiquo.virtualmachinestate+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/state"
    },
    {
      "title": "virtual machine undeploy",
      "rel": "undeploy",
      "type": "application/vnd.abiquo.acceptedrequest+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/action/undeploy"
    },
    {
      "title": "virtual machine deploy",
      "rel": "deploy",
      "type": "application/vnd.abiquo.acceptedrequest+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/action/deploy"
    },
    {
      "title": "virtual machine reset",
      "rel": "reset",
      "type": "application/vnd.abiquo.acceptedrequest+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/action/reset"
    },
    {
      "title": "virtual machine snapshot",
      "rel": "instance",
      "type": "application/vnd.abiquo.acceptedrequest+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/action/instance"
    },
    {
      "title": "remote access",
      "rel": "rdpaccess",
      "type": "application/vnd.abiquo.virtualmachineconsole+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/config/rdpaccess"
    },
    {
      "title": "tasks",
      "rel": "tasks",
      "type": "application/vnd.abiquo.tasks+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/tasks"
    },
    {
      "title": "firewalls",
      "rel": "firewalls",
      "type": "application/vnd.abiquo.links+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/firewalls"
    },
    {
      "title": "load balancers",
      "rel": "loadbalancers",
      "type": "application/vnd.abiquo.loadbalancers+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/loadbalancers"
    },
    {
      "title": "request on demand backup",
      "rel": "requestbackup",
      "type": "application/vnd.abiquo.ondemandbackup+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/backup/action/request"
    },
    {
      "title": "request a restore of a backup",
      "rel": "requestrestore",
      "type": "application/vnd.abiquo.restore+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/backup/action/restore"
    },
    {
      "title": "move VM to a virtual appliance",
      "rel": "vappmove",
      "type": "application/vnd.abiquo.links+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/action/vappmove"
    },
    {
      "title": "move VM to another virtual datacenter",
      "rel": "move",
      "type": "application/vnd.abiquo.movevm+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/action/move"
    },
    {
      "title": "volumes",
      "rel": "volumes",
      "type": "application/vnd.abiquo.volumes+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/storage/volumes"
    },
    {
      "diskAllocation": "THIN",
      "diskControllerType": "IDE",
      "diskLabel": "Hard disk 1",
      "length": "64",
      "title": "4ffdcc26-6b30-47db-99b7-20bccbe285ea",
      "rel": "disk0",
      "type": "application/vnd.abiquo.harddisk+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/disks/18018"
    },
    {
      "title": "datastoretierESXI6.0_2.29",
      "rel": "datastoretier0",
      "type": "application/vnd.abiquo.datastoretier+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/locations/1/datastoretiers/58"
    },
    {
      "title": "protect",
      "rel": "protect",
      "type": "text/plain",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/action/protect"
    },
    {
      "title": "unprotect",
      "rel": "unprotect",
      "type": "text/plain",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/action/unprotect"
    },
    {
      "title": "metricsmetadata",
      "rel": "metricsmetadata",
      "type": "application/vnd.abiquo.metricsmetadata+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/metrics"
    },
    {
      "title": "enablemonitoring",
      "rel": "enablemonitoring",
      "type": "",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/enablemonitoring"
    },
    {
      "title": "collectd",
      "rel": "collectd",
      "type": "application/json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/metrics/collectd"
    },
    {
      "title": "alarmssearch",
      "rel": "alarmssearch",
      "type": "application/vnd.abiquo.alarms+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/alarms"
    },
    {
      "title": "clone",
      "rel": "clone",
      "type": "application/vnd.abiquo.virtualmachinecloneoptions+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/action/clone"
    },
    {
      "title": "VMware vCenter Cluster",
      "rel": "hypervisortype",
      "type": "application/vnd.abiquo.hypervisortype+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/config/hypervisortypes/VCENTER_CLUSTER"
    },
    {
      "title": "yVM_Abiquo_enterprise",
      "rel": "virtualmachinetemplate",
      "type": "application/vnd.abiquo.virtualmachinetemplate+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/admin/enterprises/336/datacenterrepositories/1/virtualmachinetemplates/2"
    },
    {
      "title": "Others",
      "rel": "category",
      "type": "application/vnd.abiquo.category+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/config/categories/1"
    },
    {
      "title": "privateip",
      "rel": "nic0",
      "type": "application/vnd.abiquo.privateip+json",
      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/privatenetworks/3490/ips/18027"
    } 
  ],
  "usageStatistics": []
} 


...


Update the VM to add the NIC

Send a PUT request to update the whole VM, including all the links. As the VM object is quite large, instead of adding it to the -d option between single quotation marks, you can save it to a file, for example, "VMnic.json", and then use the @ notation to reference the file in the cURL.

...

In the UI, when you select the VM, and open the control panel in the Network tab, the NIC should display. Note that this example shows a different VM to the one used in the request examples!

Image Modified

The example request is given here.

...

Include Page
VM power actions using the API
VM power actions using the API


...


Delete an entity using the API

To delete an entity, simply perform a DELETE request to the API link. But remember that there may be restrictions on what you can delete. For example, you cannot delete a virtual datacenter that contains virtual appliances. If we delete the VM using the following query, it will be removed from the platform (and if it exists on the hypervisor, it will be destroyed). The NIC we added will be detached and released back into the virtual datacenter. 

Code Block
curl -X DELETE https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454 \
     	-H 'Accept: text/json,application/json;' \

	 -u user:password -k


...


...