Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 20 Next »

Introduction

This tutorial continues on from Get started with the Abiquo API.

In this tutorial, you will:

  1. Configure a VM by adding an IP address (NIC)
  2. Change the state of a VM




Requirements

This tutorial requires two VMs that are:

  1. not deployed
  2. do not have any IP addresses.

To use a VM from the last tutorial, in the UI undeploy it and delete its IP address. 

Working with Deployed VMs

A deployed VM must always have a NIC. If you want to add another NIC, you may need to create another network to avoid trying to add two IP addresses in the same 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.




Get and modify an entity using the API

In general, to modify an entity using the API:

  1. Use a GET request to retrieve the entity's data object
  2. Modify the data object
  3. Use a PUT request to update the entity


Within a data object, links can define an entity's configuration.

When you edit the VM data object, be careful not to accidentally delete links because you could change the configuration, e.g. delete a disk from your VM!





Configure a VM to add a NIC using the UI

First add a NIC using the UI, in order to view the request made in the API.

We will add a network interface card (NIC) with an IP address in a private network to the first VM we created. In this case, we will assume that the VM is not deployed.

  1. Open the browser console to the Network tab and record actions
  2. Edit the VM and go to Network → Private → select network → drag an IP address into the NICs panel, and Save
  3. Find the PUT request and copy it, or get the NIC link and VM data object


 Click here to show/hide the screenshot


Obtain the link to the NIC

In the VM object, you will probably find the link to the NIC near the end of the VM links section.

      {
         "title":"privateip",
         "rel":"nic0",
         "type":"application/vnd.abiquo.privateip+json",
         "href":"https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips/326"
      }, 




Get an IP address to add to the VM

To find a free IP address:

  1. From the link to the NIC in the previous step, get only the networks IPs link

    https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips
  2. Use a GET request to obtain the first 3 IP addresses in this network, with the parameter "limit=3".  

    curl --verbose 'href":"https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips?limit=3' \
         -H 'Accept: application/vnd.abiquo.privateips+json; version=5.2' \
    	 -u user:password -k | jq . 

    To only retrieve IPs that are available for use, you can use the query parameter "free=true".

  3. The response has 3 IP addresses: the gateway and the IP addresses we created specifically for this exercise.

    √ Abiquo % curl --verbose 'https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips?limit=3' \  
         -H 'Accept: application/vnd.abiquo.privateips+json; version=5.2' \
             -u user:password  -k | jq .
     
    > GET /api/cloud/virtualdatacenters/42/privatenetworks/53/ips?limit=3 HTTP/1.1
    > Host: linatest.bcn.abiquo.com
    > Authorization: Basic XXXXXXX
    > User-Agent: curl/7.64.1
    > Accept: application/vnd.abiquo.privateips+json; version=5.2
    > 
    < HTTP/1.1 200 200
    < Date: Fri, 16 Apr 2021 19:00:47 GMT
    < Server: Apache
    < Set-Cookie: ABQSESSIONID=3701578778846185265; Max-Age=1800; Expires=Fri, 16-Apr-2021 19:30:48 GMT; Path=/; Secure; HttpOnly; SameSite=strict
    < X-Abiquo-TracerContext: aff6905e-3a00-47e5-a640-e70556ab7ffc
    < X-Abiquo-Token: a2e19816735381c1d074441cbd002aa0b2dfac898841de657740584d88f344f6868d440ef8c65b7687ac23cb388ca40e78f93c9d3156bff79e474f6222358857
    < Cache-Control: no-cache, no-store, max-age=0, must-revalidate
    < Pragma: no-cache
    < Expires: 0
    < Strict-Transport-Security: max-age=31536000 ; includeSubDomains
    < X-XSS-Protection: 1; mode=block
    < X-Frame-Options: DENY
    < X-Content-Type-Options: nosniff
    < Content-Type: application/vnd.abiquo.privateips+json; version=5.2
    < Transfer-Encoding: chunked
    < 
    
    {
      "totalSize": 10,
      "links": [
        {
          "rel": "first",
          "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips?limit=3&by=ip&asc=true"
        },
        {
          "rel": "next",
          "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips?startwith=3&limit=3&by=ip&asc=true"
        },
        {
          "rel": "last",
          "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips?startwith=7&limit=3&by=ip&asc=true"
        }
      ],
      "collection": [
        {
          "id": 324,
          "ip": "192.168.0.1",
          "mac": "00:50:56:2B:4D:8D",
          "name": "0050562B4D8D_host",
          "networkName": "default_private_network",
          "ipv6": false,
          "quarantine": false,
          "available": true,
          "links": [
            {
              "title": "default_private_network",
              "rel": "privatenetwork",
              "type": "application/vnd.abiquo.vlan+json",
              "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53"
            },
            {
              "title": "privateip",
              "rel": "self",
              "type": "application/vnd.abiquo.privateip+json",
              "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips/324"
            },
            {
              "title": "vdc_ESXI_vCenter",
              "rel": "virtualdatacenter",
              "type": "application/vnd.abiquo.virtualdatacenter+json",
              "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42"
            }
          ]
        },
        {
          "id": 326,
          "ip": "192.168.0.2",
          "mac": "00:50:56:05:FE:8F",
          "name": "00505605FE8F_host",
          "networkName": "default_private_network",
          "ipv6": false,
          "usedBy": "ABQ_039b03e9-1639-4c46-a915-b53af7ea3445",
          "quarantine": false,
          "available": true,
          "links": [
            {
              "title": "default_private_network",
              "rel": "privatenetwork",
              "type": "application/vnd.abiquo.vlan+json",
              "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53"
            },
            {
              "title": "privateip",
              "rel": "self",
              "type": "application/vnd.abiquo.privateip+json",
              "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips/326"
            },
            {
              "title": "vdc_ESXI_vCenter",
              "rel": "virtualdatacenter",
              "type": "application/vnd.abiquo.virtualdatacenter+json",
              "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42"
            },
            {
              "title": "vapp_web",
              "rel": "virtualappliance",
              "type": "application/vnd.abiquo.virtualappliance+json",
              "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110"
            },
            {
              "title": "ABQ_039b03e9-1639-4c46-a915-b53af7ea3445",
              "rel": "virtualmachine",
              "type": "application/vnd.abiquo.virtualmachine+json",
              "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1918"
            }
          ]
        },
        {
          "id": 335,
          "ip": "192.168.0.3",
          "mac": "00:50:56:0D:BE:B9",
          "name": "0050560DBEB9_host",
          "networkName": "default_private_network",
          "ipv6": false,
          "quarantine": false,
          "available": true,
          "links": [
            {
              "title": "default_private_network",
              "rel": "privatenetwork",
              "type": "application/vnd.abiquo.vlan+json",
              "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53"
            },
            {
              "title": "privateip",
              "rel": "self",
              "type": "application/vnd.abiquo.privateip+json",
              "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips/335"
            },
            {
              "title": "vdc_ESXI_vCenter",
              "rel": "virtualdatacenter",
              "type": "application/vnd.abiquo.virtualdatacenter+json",
              "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42"
            }
          ]
        }
      ]
    }
    
    
    

In the above example, the IP that is being used on a VM has a link to the VM. 

The available IP that we will use has the identifier "335".

From the IP address object in the above step, get the link with a "rel" value of "self".

        {
          "title": "privateip",
          "rel": "self",
          "type": "application/vnd.abiquo.privateip+json",
          "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips/335"
        },

To prepare it for the VM, change "self" to "nicX", where "X" represents the number of the new NIC in the VM. So if there are no NICs, add "nic0" as shown here.

        {
          "title": "privateip",
          "rel": "nic0",
          "type": "application/vnd.abiquo.privateip+json",
          "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips/335"
        },


Add the NIC link to the VM object

Go the end of the links section and add the NIC from the previous step.

(warning) If this is the last link, add a comma before it, and remove any comma after it.

This is an example of the modified VM object, with the nic0 link at the end of the links section. 

 {
  "id": 1920,
  "uuid": "6b2d0d93-7f23-4a78-af5f-a9398be58773",
  "fqdn": "box.localdomain",
  "description": "A virtual machine",
  "coresPerSocket": 1,
  "idState": 1,
  "idType": 0,
  "type": "MANAGED",
  "highDisponibility": 0,
  "monitored": true,
  "monitoringLevel": "DEFAULT",
  "protected": false,
  "variables": {},
  "backuppolicies": [],
  "lastSynchronize": 1618592955000,
  "generateGuestInitialPassword": false,
  "natrules": [],
  "vdrpEnabled": true,
  "vdrpPort": 0,
  "password": "xPUOwNxb",
  "deallocated": false,
  "name": "ABQ_6b2d0d93-7f23-4a78-af5f-a9398be58773",
  "label": "yVM_mj_2",
  "ram": 48,
  "cpu": 1,
  "state": "NOT_ALLOCATED",
  "creationTimestamp": 1618588107000,
  "links": [
    {
      "title": "Abiquo",
      "rel": "enterprise",
      "type": "application/vnd.abiquo.enterprise+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/admin/enterprises/1"
    },
    {
      "title": "ABQ_6b2d0d93-7f23-4a78-af5f-a9398be58773",
      "rel": "edit",
      "type": "application/vnd.abiquo.virtualmachine+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920"
    },
    {
      "rel": "asynctasks",
      "type": "application/vnd.abiquo.asynctasks+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/asynctasks"
    },
    {
      "title": "send mail",
      "rel": "sendmail",
      "type": "application/vnd.abiquo.mail+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/admin/publiccloudregions/7/enterprises/1/virtualmachines/1920/action/sendmail"
    },
    {
      "title": "cloudadmin",
      "rel": "user",
      "type": "application/vnd.abiquo.user+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/admin/enterprises/1/users/10"
    },
    {
      "title": "vdc_ESXI_vCenter",
      "rel": "virtualdatacenter",
      "type": "application/vnd.abiquo.virtualdatacenter+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42"
    },
    {
      "title": "vapp_web",
      "rel": "virtualappliance",
      "type": "application/vnd.abiquo.virtualappliance+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110"
    },
    {
      "title": "metadata",
      "rel": "metadata",
      "type": "application/vnd.abiquo.metadata+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/metadata"
    },
    {
      "title": "vlan network configurations",
      "rel": "configurations",
      "type": "application/vnd.abiquo.virtualmachinenetworkconfigurations+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/network/configurations"
    },
    {
      "title": "nics",
      "rel": "nics",
      "type": "application/vnd.abiquo.nics+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/network/nics"
    },
    {
      "title": "disks",
      "rel": "harddisks",
      "type": "application/vnd.abiquo.harddisks+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/storage/disks"
    },
    {
      "title": "NOT_ALLOCATED",
      "rel": "state",
      "type": "application/vnd.abiquo.virtualmachinestate+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/state"
    },
    {
      "title": "virtual machine undeploy",
      "rel": "undeploy",
      "type": "application/vnd.abiquo.acceptedrequest+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/undeploy"
    },
    {
      "title": "virtual machine deploy",
      "rel": "deploy",
      "type": "application/vnd.abiquo.acceptedrequest+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/deploy"
    },
    {
      "title": "virtual machine reset",
      "rel": "reset",
      "type": "application/vnd.abiquo.acceptedrequest+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/reset"
    },
    {
      "title": "virtual machine snapshot",
      "rel": "instance",
      "type": "application/vnd.abiquo.acceptedrequest+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/instance"
    },
    {
      "title": "remote access",
      "rel": "rdpaccess",
      "type": "application/vnd.abiquo.virtualmachineconsole+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/config/rdpaccess"
    },
    {
      "title": "tasks",
      "rel": "tasks",
      "type": "application/vnd.abiquo.tasks+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tasks"
    },
    {
      "title": "firewalls",
      "rel": "firewalls",
      "type": "application/vnd.abiquo.links+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/firewalls"
    },
    {
      "title": "load balancers",
      "rel": "loadbalancers",
      "type": "application/vnd.abiquo.loadbalancers+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/loadbalancers"
    },
    {
      "title": "request on demand backup",
      "rel": "requestbackup",
      "type": "application/vnd.abiquo.ondemandbackup+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/backup/action/request"
    },
    {
      "title": "request a restore of a backup",
      "rel": "requestrestore",
      "type": "application/vnd.abiquo.restore+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/backup/action/restore"
    },
    {
      "title": "move VM to a virtual appliance",
      "rel": "vappmove",
      "type": "application/vnd.abiquo.links+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/vappmove"
    },
    {
      "title": "move VM to another virtual datacenter",
      "rel": "move",
      "type": "application/vnd.abiquo.movevm+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/move"
    },
    {
      "title": "volumes",
      "rel": "volumes",
      "type": "application/vnd.abiquo.volumes+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/storage/volumes"
    },
    {
      "diskAllocation": "THIN",
      "diskControllerType": "IDE",
      "diskLabel": "Hard disk 1",
      "length": "64",
      "title": "4166504b-d350-439e-adcb-1bc2b57814e0",
      "rel": "disk0",
      "type": "application/vnd.abiquo.harddisk+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/disks/1896"
    },
    {
      "title": "dstier_shared",
      "rel": "datastoretier0",
      "type": "application/vnd.abiquo.datastoretier+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/locations/7/datastoretiers/9"
    },
    {
      "title": "protect",
      "rel": "protect",
      "type": "text/plain",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/protect"
    },
    {
      "title": "unprotect",
      "rel": "unprotect",
      "type": "text/plain",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/unprotect"
    },
    {
      "title": "metricsmetadata",
      "rel": "metricsmetadata",
      "type": "application/vnd.abiquo.metricsmetadata+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/metrics"
    },
    {
      "title": "disablemonitoring",
      "rel": "disablemonitoring",
      "type": "",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/disablemonitoring"
    },
    {
      "title": "collectd",
      "rel": "collectd",
      "type": "application/json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/metrics/collectd"
    },
    {
      "title": "alarmssearch",
      "rel": "alarmssearch",
      "type": "application/vnd.abiquo.alarms+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/alarms"
    },
    {
      "title": "clone",
      "rel": "clone",
      "type": "application/vnd.abiquo.virtualmachinecloneoptions+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/action/clone"
    },
    {
      "rel": "tags",
      "type": "application/vnd.abiquo.resourcetags+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tags"
    },
    {
      "rel": "tags-update",
      "type": "application/vnd.abiquo.tags+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tags"
    },
    {
      "rel": "tags-format",
      "type": "application/vnd.abiquo.tagformatrestrictions+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tags"
    },
    {
      "rel": "tags-create",
      "type": "application/vnd.abiquo.tags+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tags/action/create"
    },
    {
      "rel": "tags-delete",
      "type": "application/vnd.abiquo.tagkeys+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tags/action/delete"
    },
    {
      "rel": "tags-edit",
      "type": "application/vnd.abiquo.tags+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tags/action/edit"
    },
    {
      "rel": "tags-sync",
      "type": "",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920/tags/action/sync"
    },
    {
      "title": "VMware vCenter",
      "rel": "hypervisortype",
      "type": "application/vnd.abiquo.hypervisortype+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/config/hypervisortypes/VMX_04"
    },
    {
      "title": "yVM_mj",
      "rel": "virtualmachinetemplate",
      "type": "application/vnd.abiquo.virtualmachinetemplate+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/admin/enterprises/1/datacenterrepositories/7/virtualmachinetemplates/520"
    },
    {
      "title": "Others",
      "rel": "category",
      "type": "application/vnd.abiquo.category+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/config/categories/1"
    },
    {
      "title": "privateip",
      "rel": "nic0",
      "type": "application/vnd.abiquo.privateip+json",
      "href": "https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/privatenetworks/53/ips/335"
    }
  ],
  "usageStatistics": []
}


Update the VM to add the NIC

Create a PUT request to update the whole VM, including all the links.

To easily manage the large data object, we saved it to a file called  "VMnic.json", and then used the @ notation to reference the file.

curl --verbose -X PUT 'https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920' \
   -H 'Content-Type: application/vnd.abiquo.virtualmachine+json; version=5.2' \
   -H 'Accept: application/vnd.abiquo.acceptedrequest+json; version=5.2' \
   -u user:password \
   -d @VMwithNIC.json -k 

Send the PUT request.

If it is successful, the response status and message will be "204  No content" for an undeployed VM.

The example request is given here.

 √ Abiquo % curl --verbose -X PUT 'https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920' \
   -H 'Content-Type: application/vnd.abiquo.virtualmachine+json; version=5.2' \
   -H 'Accept: application/vnd.abiquo.acceptedrequest+json; version=5.2' \
   -u user:password \
   -d @VMwithNIC.json -k

> PUT /api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920 HTTP/1.1
> Host: linatest.bcn.abiquo.com
> Authorization: Basic XXXXXX
> User-Agent: curl/7.64.1
> Content-Type: application/vnd.abiquo.virtualmachine+json; version=5.2
> Accept: application/vnd.abiquo.acceptedrequest+json; version=5.2
> Content-Length: 11899
> Expect: 100-continue
> 
< HTTP/1.1 100 Continue

< HTTP/1.1 204 204
< Date: Fri, 16 Apr 2021 19:19:17 GMT
< Server: Apache
< Set-Cookie: ABQSESSIONID=8608303820936303687; Max-Age=1800; Expires=Fri, 16-Apr-2021 19:49:17 GMT; Path=/; Secure; HttpOnly; SameSite=strict
< X-Abiquo-TracerContext: 93272692-df60-4efa-a478-a4fcfd3a859b
< X-Abiquo-Token: a2e19816735381c1d074441cbd002aa06429084b01dc4d254adc14535eae44c5c3f4ad90e8e51aabe5134b3d3b841586306916bfe4fdcb486f331e2501f490c0
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< Strict-Transport-Security: max-age=31536000 ; includeSubDomains
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: DENY
< X-Content-Type-Options: nosniff
< 


Check your VM in the UI

In the UI, when you select the VM, and open the control panel in the Network tab, the NIC should display.

Power actions on a VM

To prepare a VM to change power states, deploy a VM using the UI or the API.

Then see Administer and troubleshoot VMs in the "Manage VM power states using the API" section




Delete a VM using the API

To delete a VM (or another entity), simply perform a DELETE request to the API link.

Note 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 as shown here, it will be removed from the platform (and if it exists on the hypervisor, it will be destroyed). And the IP address will return to the virtual datacenter.

curl -X DELETE https://linatest.bcn.abiquo.com:443/api/cloud/virtualdatacenters/42/virtualappliances/110/virtualmachines/1920 \
	-H 'Accept: text/json,application/json;' \
	-u user:password -k

Conclusion

Congratulations, you have now completed the Abiquo API tutorials. You can now continue to experiment using the API together with the UI. And you can find more examples in the API Howtos section. 

And of course don't forget to check out the Java and Python libraries. Enjoy!


Related links

  • No labels