Versions Compared

Key

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

Table of Contents

Introduction

This tutorial continues on from Get Started with the Abiquo API!

This tutorial requires two VMs that are undeployed without any network interfaces.

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.

...

To add a NIC to the VM, we are going to first perform the steps using the UI, in order to obtain information about the data object. 

...


Configure the VM to add a NIC

...

using the UI

Now we 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 at to the Network tab and record actions
  2. Edit the VM , go and go to Network Private → select network → drag and drop an IP address into the NICs panel, and Save the VM 
  3. Examine the PUT request and look for the link to the NIC and expand it. It will probably be at the end of the links section.

...

Tip
titleDeployed VMs

If your VM is 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.

At the top of the Request Payload section, click "view source".  Copy the source, format it, and select the link to the NIC and copy it. After formatting, it will look something like this.

Code Block
{
     {  
         ""title":"privateip",
    
    "rel":"nic0",
     
   "type":"application/vnd.abiquo.privateip+json",

        "href":"https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/privatenetworks/53490/ips/16"
     18020"
}, 

We will use this type of NIC link in the next step.

...


Add a NIC to the VM

...

using the API

Now we are going to add a NIC to the second VM. To do this, we need to identify the second private IP that we created for this tutorial.

...

We will use the part of the URL that refers to the IPs of the private network, which just means removing the identifier the IP link without the id of the IP from the IP linkas shown here.

Code Block
https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/privatenetworks/53490/ips

You could perform a curl request from the command line, for example.

Code Block
curl --verbose 'https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/privatenetworks/53490/ips' \
     -H 'Accept: application/vnd.abiquo.privateips+json; version=45.60' \
	 -u adminuser:xabiquopassword -k | jq . 

In our response body, there are 3 IP addresses: the gateway and two IP addresses we created specifically for this exercise.

Expand


Code Block
user@user:~ $ curl --verbose 'https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/privatenetworks/53490/ips' \
     -H 'Accept: application/vnd.abiquo.privateips+json; version=45.60' \
     -u adminuser:xabiquopassword -k | jq .

* Connected to mjsabiquonardo40.bcn.abiquo.com (10.60.1311.1809) port 443 (#0)
* Server auth using Basic with user 'adminuser'
> GET /api/cloud/virtualdatacenters/22486/privatenetworks/53490/ips HTTP/1.1
> Host: nardo40.bcn.abiquo.com
> Authorization: Basic YWRtaW46eGFiaXF1bw==blahblahblah
> User-Agent: curl/7.3564.01
> Host: mjsabiquo.bcn.abiquo.com
> Accept: application/vnd.abiquo.privateips+json; version=45.60
> 
< HTTP/1.1 200 200
< Date: Wed, 1929 JunJul 20192020 1315:11:5346 GMT
*
Server Apache is not blacklisted
< Server: Apache
< Set-Cookie: ABQSESSIONID=50597469844407754552853985954862764381; Max-Age=1800; Expires=Wed, 1929-JunJul-20192020 1315:41:5347 GMT; Path=/; Secure; HttpOnly; <SameSite=strict
< X-Abiquo-TokenTracerContext: 2772ef503a95419ab7066ee6771751e6546ca200feb764385226ae9047a8f03e211b2da1-897b-4cf3-a8c2-828a400ff388
< ContentX-Abiquo-TypeToken: application/vnd.abiquo.privateips+json; version=4.6
a2e19816735381c1d074441cbd002aa01fff4b1659f8c90ac4235e1318874499cf18ee6a802e0b9484df51ffa5c9fcb9ff18fc48dd1a90c7dafdb2e557d0293e
< TransferCache-EncodingControl: chunked
< 
* Connection #0 to host mjsabiquo.bcn.abiquo.com left intact
{
  "collection": [
    {
   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.0
< Transfer-Encoding: chunked
< 

{
  "totalSize": 3,
  "links": [
    {
   {   "rel": "first",
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/privatenetworks/5",3490/ips?limit=25&by=ip&asc=true"
    },
     "type": "application/vnd.abiquo.vlan+json",{
          "rel": "privatenetworklast",
  
       "title": "private_network_cloudland_01"
        },
        {
          "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/privatenetworks/53490/ips/15",?startwith=0&limit=25&by=ip&asc=true"
    }
  ],
  "typecollection": "application/vnd.abiquo.privateip+json", [
    {
      "relid": "self",
   18014,
      "titleip": "privateip"192.168.0.1",
        }"mac": "00:50:56:1D:5E:DE",
        {
   "name": "0050561D5EDE_host",
      "hrefnetworkName": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2",default_private_network",
      "ipv6": false,
      "typequarantine": "application/vnd.abiquo.virtualdatacenter+json"false,
      "available": true,
      "rellinks": "virtualdatacenter", [
        {
          "title": "bcdcdefault_vdcprivate_cloudland_01network",
        }  "rel": "privatenetwork",
   ],       "idtype": 15,"application/vnd.abiquo.vlan+json",
          "iphref": "192.168.201.1",https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/privatenetworks/3490"
       "mac": "52:54:00:CD:25:F8" },
      "name": "525400CD25F8_host",  {
          "networkNametitle": "private_network_cloudland_01privateip",
          "ipv6rel": false"self",
      "quarantine": false,         "availabletype": true
    },
    {
      "links": [
"application/vnd.abiquo.privateip+json",
       {           "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/privatenetworks/53490/ips/18014",
          "type": "application/vnd.abiquo.vlan+json"},
          "rel": "privatenetwork",{
          "title": "privatevdc_networkapi_cloudland_01"tutorial",
          },"rel": "virtualdatacenter",
           {"type": "application/vnd.abiquo.virtualdatacenter+json",
          "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/privatenetworks/5/ips/16",2486"
        }
 "type": "application/vnd.abiquo.privateip+json",    ]
    },
 "rel": "self",    {
      "titleid": "privateip"18020,
        }"ip": "192.168.0.2",
        {
          "href"mac": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2",
 00:50:56:19:71:96",
        "typename": "application/vnd.abiquo.virtualdatacenter+json",
   005056197196_host",
      "relnetworkName": "virtualdatacenterdefault_private_network",
   
      "titleipv6": "bcdc_vdc_cloudland_01"false,
      "usedBy":  },"ABQ_e73648be-81bc-49ba-b78f-041072bc74c8",
      "quarantine": false,
   {   "available": true,
      "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/2",links": [
        {
          "typetitle": "application/vnd.abiquo.virtualappliance+jsondefault_private_network",
          "rel": "virtualapplianceprivatenetwork",
          "titletype": "bcdc_vdc_cloudland_01_vapp_01"
        },
 application/vnd.abiquo.vlan+json",
      {           "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/2/virtualmachines/6",privatenetworks/3490"
        },
       "type": "application/vnd.abiquo.virtualmachine+json", {
          "reltitle": "virtualmachineprivateip",
          "titlerel": "ABQ_331a9b47-5cf6-4166-bb02-021d5e8905df"self",
        }  "type": "application/vnd.abiquo.privateip+json",
   ],       "available": true,href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/privatenetworks/3490/ips/18020"
       "id": 16},
      "ip": "192.168.201.2",
 {
     "mac": "52:54:00:5F:7D:68",
      "nametitle": "5254005F7D68vdc_api_hosttutorial",
          "networkNamerel": "private_network_cloudland_01virtualdatacenter",
          "ipv6type": false"application/vnd.abiquo.virtualdatacenter+json",
          "usedByhref": "ABQ_331a9b47-5cf6-4166-bb02-021d5e8905df",https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486"
      "quarantine": false },
   },     {
      "links": [   "title": "vap_api_tutorial",
    {           "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/privatenetworks/5"rel": "virtualappliance",
          "type": "application/vnd.abiquo.vlanvirtualappliance+json",
          "relhref": "privatenetwork",
          "title": "private_network_cloudland_01https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990"
        },
        {
          "hreftitle": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/privatenetworks/5/ips/17ABQ_e73648be-81bc-49ba-b78f-041072bc74c8",
          "typerel": "application/vnd.abiquo.privateip+jsonvirtualmachine",
          "reltype": "selfapplication/vnd.abiquo.virtualmachine+json",
          "titlehref": "privateiphttps://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19453"
        },
      ]
    },
{    {
      "hrefid": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2",
   18027,
      "typeip": "application/vnd.abiquo.virtualdatacenter+json",
  192.168.0.3",
       "relmac": "virtualdatacenter00:50:56:31:8A:DD",

         "titlename": "bcdc_vdc_cloudland_01"005056318ADD_host",
      "networkName":  }"default_private_network",
      "ipv6": ]false,
      "idquarantine": 17false,
      "ipavailable": "192.168.201.3"true,
      "maclinks": "52:54:00:DC:31:12",[
        {
  "name": "525400DC3112_host",       "networkNametitle": "default_private_network_cloudland_01",
      "ipv6": false,
      "quarantinerel": false,
      "availableprivatenetwork": true,
    }   ],   "linkstype": ["application/vnd.abiquo.vlan+json",
    {       "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/privatenetworks/5/ips?limit=25&by=ip&asc=true",3490"
      "rel": "first" },
   },     {
          "hreftitle": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/privatenetworks/5/ips?startwith=0&limit=25&by=ip&asc=true",privateip",
          "rel": "lastself",
    }   ],   "totalSizetype": 3
}

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

Hint: to only retrieve IPs that are available for use, you can use the request parameter "free=true", as follows.

Code Block
Code Block
https://mjsabiquo
"application/vnd.abiquo.privateip+json",
          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/
26
2486/privatenetworks/
34
3490/ips
?free=true

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

And the link we need from this IP object is the link with a "rel" value of "self".

Code Block
/18027"
        },
        {
          "
href
title": "
https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/privatenetworks/5/ips/17
vdc_api_tutorial",
          "
type
rel": "
application/vnd.abiquo.privateip+json
virtualdatacenter",
          "
rel
type": "
self
application/vnd.abiquo.virtualdatacenter+json",
          "
title
href": "
privateip
https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486"
        }
,

To add it to the VM, we just need to change "self" to "nicX", where "X" represents the number of the new NIC in the VM. So if there are no NICs on the machine, we will add "nic0" as shown here.


      ]
{
    }
  ]
"href": "
} 


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

Hint: to only retrieve IPs that are available for use, you can use the query parameter "free=true", as follows.

Code Block
https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/privatenetworks/53490/ips/17",
          "type": "application/vnd.abiquo.privateip+json?free=true

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

And the link we need from this IP object is the link with a "rel" value of "self".

Code Block
        {
          "title": "privateip",
          "rel": "nic0self",
          "titletype": "application/vnd.abiquo.privateip+json",
          },

Remember that when you add this NIC to the end of the links section, you must add a comma first, after the previous item. And as this will be the last link, remember to remove the comma after it.

So here is an example of the request body that would be used to update our second VM, with the nic0 link at the end of the links section.

{ "links": [
 "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/privatenetworks/3490/ips/18027"
     
{
   
"href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2",
}, 
Expand
Code Block

To add it to the VM, we just need to change "self" to "nicX", where "X" represents the number of the new NIC in the VM. So if there are no NICs on the machine, we will add "nic0" as shown here.

Code Block
        {
"type":
 
"application/vnd.abiquo.enterprise+json",
       
"rel
  "title": "
enterprise
privateip",
          "
title
rel": "
Cloudland"
nic0",
          
}
"type": "application/vnd.abiquo.privateip+json",
   
{
       "href": "https://
mjsabiquo
nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/
2
2486/
virtualappliances
privatenetworks/
2
3490/
virtualmachines
ips/
8
18027"
,

      
"type":
 
"application/vnd.abiquo.virtualmachine+json", "rel": "edit", "title": "ABQ_06cfadf0-db57-48c5-8f4c-f9fe2ca76c46" }, { "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/publiccloudregions/1/enterprises/2/virtualmachines/8/action/sendmail", "type": "application/vnd.abiquo.mail+json", "rel": "sendmail", "title": "send mail" }, { "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/2/users/1", "type": "application/vnd.abiquo.user+json", "rel": "user", "title": "Cloud Administrator" }, { "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2", "type": "application/vnd.abiquo.virtualdatacenter+json", "rel": "virtualdatacenter", "title": "bcdc_vdc_cloudland_01" },
 }, 

Remember that when you add this NIC to the end of the links section, you must add a comma first, after the previous item. And as this will be the last link, remember to remove the comma after it.

So here is an example of the request body that would be used to update our second VM, with the nic0 link at the end of the links section.

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": [
    {
      "hreftitle": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/25.1.0_Snapshot Enterprise testing",
      "typerel": "application/vnd.abiquo.virtualappliance+jsonenterprise",
      "reltype": "virtualapplianceapplication/vnd.abiquo.enterprise+json",
      "titlehref": "bcdc_vdc_cloudland_01_vapp_01https://nardo40.bcn.abiquo.com:443/api/admin/enterprises/336"
    },
    {
      "hreftitle": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/2/virtualmachines/8/metadataABQ_2fb11009-8157-4d61-915d-40fa45f440ac",
      "typerel": "application/vnd.abiquo.metadata+jsonedit",
      "reltype": "metadataapplication/vnd.abiquo.virtualmachine+json",
      "titlehref": "metadata"
    },
    {
      "href": "https://mjsabiquo.https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/8/network/configurations",19454"
    },
   "type": "application/vnd.abiquo.virtualmachinenetworkconfigurations+json", {
      "rel": "configurationsasynctasks",
      "titletype": "vlan network configurations"
    },
    {application/vnd.abiquo.asynctasks+json",
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/819454/network/nics",asynctasks"
    },
    {
      "typetitle": "application/vnd.abiquo.nics+jsonsend mail",
      "rel": "nicssendmail",
      "titletype": "nics"
    }application/vnd.abiquo.mail+json",
    {
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloudadmin/virtualdatacenterspubliccloudregions/21/virtualappliancesenterprises/2336/virtualmachines/819454/storageaction/diskssendmail",
    },
   "type": "application/vnd.abiquo.harddisks+json", {
      "reltitle": "harddiskscloudadmin cloudadmin",
      "titlerel": "disksuser",
    },     {"type": "application/vnd.abiquo.user+json",
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloudadmin/virtualdatacentersenterprises/2336/virtualappliances/2/virtualmachines/8/state"users/10"
    },
    {
      "typetitle": "application/vnd.abiquo.virtualmachinestate+jsonvdc_api_tutorial",
      "rel": "statevirtualdatacenter",
      "titletype": "NOT_ALLOCATED"
application/vnd.abiquo.virtualdatacenter+json",
   },     {
      "href": ""href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/2/virtualmachines/8/action/undeploy"2486"
    },
    {
      "typetitle": "application/vnd.abiquo.acceptedrequest+jsonvap_api_tutorial",
      "rel": "undeployvirtualappliance",
      "titletype": "virtual machine undeploy"
    },
    {application/vnd.abiquo.virtualappliance+json",
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/2/virtualmachines/8/action/deploy"2990"
    },
    {
      "typetitle": "application/vnd.abiquo.acceptedrequest+jsonmetadata",
      "rel": "deploymetadata",
      "titletype": "virtual machine deploy"
    }application/vnd.abiquo.metadata+json",
    {       "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/819454/action/reset",metadata"
    },
    {
      "typetitle": "application/vnd.abiquo.acceptedrequest+jsonvlan network configurations",
      "rel": "resetconfigurations",
      "titletype": "virtual machine reset"
    },
    {application/vnd.abiquo.virtualmachinenetworkconfigurations+json",
       "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/819454/actionnetwork/instance"configurations"
    },
    {
      "typetitle": "application/vnd.abiquo.acceptedrequest+jsonnics",
      "rel": "instancenics",
      "titletype": "virtual machine snapshot"
    },
    {application/vnd.abiquo.nics+json",
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/819454/confignetwork/rdpaccess",nics"
    },
    {
      "typetitle": "application/vnd.abiquo.virtualmachineconsole+jsondisks",
      "rel": "rdpaccessharddisks",
      "titletype": "remote access"
    }application/vnd.abiquo.harddisks+json",
    {       "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/19454/8storage/tasks",disks"
    },
    {
      "typetitle": "application/vnd.abiquo.tasks+jsonNOT_ALLOCATED",
      "rel": "tasksstate",
      "titletype": "tasks"
    },
    {application/vnd.abiquo.virtualmachinestate+json",
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/819454/firewalls",state"
    },
    {
      "typetitle": "application/vnd.abiquo.links+jsonvirtual machine undeploy",
      "rel": "firewallsundeploy",
      "titletype": "firewalls"
    },
    {application/vnd.abiquo.acceptedrequest+json",
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/819454/loadbalancers",action/undeploy"
    },
    {
      "typetitle": "application/vnd.abiquo.loadbalancers+jsonvirtual machine deploy",
      "rel": "loadbalancersdeploy",
      "titletype": "load balancers"
    }application/vnd.abiquo.acceptedrequest+json",
    {       "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/8/backup19454/action/request",deploy"
    },
    {
      "typetitle": "application/vnd.abiquo.ondemandbackup+jsonvirtual machine reset",
      "rel": "requestbackupreset",
      "titletype": "request on demand backup"
    },
 application/vnd.abiquo.acceptedrequest+json",
  {       "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/8/backup19454/action/restore"reset"
    },
    {
      "typetitle": "application/vnd.abiquo.restore+jsonvirtual machine snapshot",
      "rel": "requestrestoreinstance",
      "titletype": "request a restore of a backup"
    },
    {
      "href": "application/vnd.abiquo.acceptedrequest+json",
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/819454/action/vappmove"instance"
    },
    {
      "typetitle": "application/vnd.abiquo.links+jsonremote access",
      "rel": "vappmoverdpaccess",
      "titletype": "move VM to a virtual appliance"
    },
    {application/vnd.abiquo.virtualmachineconsole+json",
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/819454/actionconfig/move"rdpaccess"
    },
    {
      "typetitle": "application/vnd.abiquo.movevm+jsontasks",
      "rel": "movetasks",
      "titletype": "move VM to another virtual datacenter"
    },
application/vnd.abiquo.tasks+json",
   {       "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/819454/storage/volumestasks",
    },
  "type": "application/vnd.abiquo.volumes+json",
 {
      "reltitle": "volumesfirewalls",
      "titlerel": "volumesfirewalls",
    },  "type": "application/vnd.abiquo.links+json",
 {       "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/disks/31",/2486/virtualappliances/2990/virtualmachines/19454/firewalls"
    },
   "type": "application/vnd.abiquo.harddisk+json", {
      "reltitle": "disk0load balancers",
      "titlerel": "9c83fcc3-e9cb-44bf-88d0-f8a98248fa69loadbalancers",
      "lengthtype": "64application/vnd.abiquo.loadbalancers+json",
      "diskLabelhref": "Hard disk 1",https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/loadbalancers"
    },
   "diskControllerType": "IDE" {
    },  "title": "request on {demand backup",
      "hrefrel": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/locations/1/datastoretiers/1requestbackup",
      "type": "application/vnd.abiquo.datastoretierondemandbackup+json",
      "relhref": "datastoretier0",
      "title": "Default Tier"
    },
    {
      "href": "https://mjsabiquohttps://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/819454/backup/action/protect",request"
    },
    {
      "typetitle": "text/plainrequest a restore of a backup",
      "rel": "protectrequestrestore",
      "titletype": "protect"
    },
application/vnd.abiquo.restore+json",
   {       "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/19454/8backup/action/unprotect",restore"
    },
    {
      "typetitle": "text/plainmove VM to a virtual appliance",
      "rel": "unprotectvappmove",
      "titletype": "unprotect"
    },
    {application/vnd.abiquo.links+json",
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/19454/8action/metricsvappmove",
    },
  "type": "application/vnd.abiquo.metricsmetadata+json",  {
      "reltitle": "metricsmetadatamove VM to another virtual datacenter",
      "titlerel": "metricsmetadatamove",
    },  "type": "application/vnd.abiquo.movevm+json",
 {       "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/819454/action/enablemonitoring"move"
    },
    {
      "typetitle": "volumes",
      "rel": "enablemonitoringvolumes",
      "titletype": "enablemonitoring"application/vnd.abiquo.volumes+json",
    },
    {
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/819454/metricsstorage/collectdvolumes",
    },
  "type": "application/json",  {
      "reldiskAllocation": "collectdTHIN",
      "titlediskControllerType": "collectdIDE",
    },  "diskLabel": "Hard disk {1",
      "hreflength": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/2/virtualmachines/8/alarms64",
      "typetitle": "application/vnd.abiquo.alarms+json4ffdcc26-6b30-47db-99b7-20bccbe285ea",
      "rel": "alarmssearchdisk0",
      "titletype": "alarmssearch"
    }application/vnd.abiquo.harddisk+json",
    {
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/2/virtualmachines/8/action/clone",disks/18018"
    },
    {
      "typetitle": "application/vnd.abiquo.virtualmachinecloneoptions+jsondatastoretierESXI6.0_2.29",
      "rel": "clonedatastoretier0",
      "titletype": "clone"
    },
 application/vnd.abiquo.datastoretier+json",
  {       "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/locations/config1/hypervisortypesdatastoretiers/KVM",58"
    },
    {
      "typetitle": "application/vnd.abiquo.hypervisortype+jsonprotect",
      "rel": "hypervisortypeprotect",
      "titletype": "KVM"
    },
    {text/plain",
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/admin/enterprises/2/datacenterrepositories/1/virtualmachinetemplates/86"cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/action/protect"
    },
    {
 "type     "title": "application/vnd.abiquo.virtualmachinetemplate+jsonunprotect",
      "rel": "virtualmachinetemplateunprotect",
      "titletype": "yvm2"
    }text/plain",
    {
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/config/categories/1",/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454/action/unprotect"
    },
    {
      "typetitle": "application/vnd.abiquo.category+jsonmetricsmetadata",
      "rel": "categorymetricsmetadata",
      "titletype": "Others"application/vnd.abiquo.metricsmetadata+json",
    },     {
      "href": "https://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/privatenetworks2990/5virtualmachines/ips19454/17metrics",
    },
  "type": "application/vnd.abiquo.privateip+json",  {
      "reltitle": "nic0enablemonitoring",
      "titlerel": "privateipenablemonitoring",
    }   ],
  "natrules"type": [],
  "generateGuestInitialPassword": false,
  "backuppolicies": [],   "creationTimestamphref": 1560939950000,
  "variables": {},
  "protected": false,
  "monitored": false,
  "ram": 48,
  "coresPerSocket": 1,
  "cpu": 1,
  "description": "A virtual machine",
  "label": "yVM_New",
  "name": "ABQ_06cfadf0-db57-48c5-8f4c-f9fe2ca76c46",
  "uuid": "06cfadf0-db57-48c5-8f4c-f9fe2ca76c46",
  "id": 8,
  "vdrpEnabled": true,
  "vdrpPort": 0,
  "idState": 1,
  "state": "NOT_ALLOCATED",
  "idType": 0,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": "MANAGEDapplication/vnd.abiquo.alarms+json",
  "highDisponibility": 0,     "passwordhref": "VUFvbvoa"
}

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.

Code Block
Expand
curl --verbose -X PUT '
https://
mjsabiquo
nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/
2
2486/virtualappliances/
2
2990/virtualmachines
/8' \ -H 'Content-Type: application/vnd.abiquo.virtualmachine+json; version=4.6' \
/19454/alarms"
    },
    {
      "title": "clone",
      "rel": "clone",
     
-H 'Accept
 "type": "application/vnd.abiquo.
acceptedrequest
virtualmachinecloneoptions+json
; version=4.6' \ -u admin:xabiquo \ -d @VMnic.json -k

The full text of the response object is shown in the expanding section below.

If the request is successful, the response status and message will be "204  No content".

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

Image Removed

This expanding section contains the full request with the VM object embedded in it.

Code Block
user@user:~/Documents/tutorials $ curl --verbose -X PUT 'https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2/virtualappliances/2/virtualmachines/8'  -H '",
      "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": []
} 


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.

Code Block
curl --verbose -X PUT 'https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454' \
   -H 'Content-Type: application/vnd.abiquo.virtualmachine+json; version=5.0' \
   -H 'Accept: application/vnd.abiquo.acceptedrequest+json; version=5.0' \
   -u user:password \
   -d @VMnic.json -k 

The full text of the response object is shown in the expanding section below.

If the request is successful, the response status and message will be "204  No content".

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

Image Added

The example request is given here.

Expand


Code Block
user@user $ curl --verbose -X PUT 'https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454' \
   -H 'Content-Type: application/vnd.abiquo.virtualmachine+json; version=5.0' \
   -H 'Accept: application/vnd.abiquo.acceptedrequest+json; version=5.0' \
   -u user:password \
   -d @VMnic.json -k

* Connected to nardo40.bcn.abiquo.com (10.60.11.9) port 443 (#0)
* Server auth using Basic with user 'user'
> PUT /api/cloud/virtualdatacenters/2486/virtualappliances/2990/virtualmachines/19454 HTTP/1.1
> Host: nardo40.bcn.abiquo.com
> Authorization: Basic XYZABC123456XYZABC123456
> User-Agent: curl/7.64.1
> Content-Type: application/vnd.abiquo.virtualmachine+json; version=4.6'      -H '5.0
> Accept: application/vnd.abiquo.acceptedrequest+json; version=45.6'0
> Content-u adminLength:xabiquo 10505
> -d @VMnic.json -k
* Connected to mjsabiquo.bcn.abiquo.com (10.60.13.180) port 443 (#0)
* Server auth using Basic with user 'admin'
> PUT /api/cloud/virtualdatacenters/2/virtualappliances/2/virtualmachines/8Expect: 100-continue
> 
< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 > Authorization: Basic YWRtaW46eGFiaXF1bw==
> User-Agent: curl/7.35.0
> Host: mjsabiquo.bcn.abiquo.com
> Content-Type: application/vnd.abiquo.virtualmachine+json; version=4.6
> Accept: application/vnd.abiquo.acceptedrequest+json; version=4.6
> Content-Length: 9805
> Expect: 100-continue
> 
< HTTP/1.1 100 Continue
< HTTP/1.1 204 204
< Date: Wed, 19 Jun 2019 13:30:55 GMT
< Server: Apache
< Set-Cookie: ABQSESSIONID=4974951206556392645; Max-Age=1800; Expires=Wed, 19-Jun-2019 14:00:55 GMT; Path=/; Secure; HttpOnly
< X-Abiquo-Token: 2772ef503a95419ab7066ee6771751e622f4fd0743fe006121a77f6b3213506b
< 204 204
< Date: Wed, 29 Jul 2020 15:45:22 GMT
< Server: Apache
< Set-Cookie: ABQSESSIONID=1638929587679935046; Max-Age=1800; Expires=Wed, 29-Jul-2020 16:15:22 GMT; Path=/; Secure; HttpOnly; SameSite=strict
< X-Abiquo-TracerContext: 5cf12345-72bf-449d-8dee-b9e2cefb5026
< X-Abiquo-Token: a2e19816735381c1d074441cbd002aa05c1d486bb93581cab46a78a3a2ec7e739506cc8a51c09fddd8eb25620540bfd1a82f31c2d9402c7e1079bfbd2d88f3c2
< 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
<  



...


Power actions on a VM

Before you begin this section, deploy a VM through the user interface. using the UI or the API.

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://mjsabiquonardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/22486/virtualappliances/22990/virtualmachines/819454 \
     -H 'Accept: text/json,application/json;' \ 
	 -u user:password -k


...


...