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 12 Next »

This page describes how to add a hard disk to a VM.

You will need the following resources.

  • A VM in a VDC that supports hard disks (private cloud or vCloud Director). 
    • If deployed without hot-reconfigure, you will need to power off the VM (you can do this with the API) 

Potential data loss

  • Abiquo destroys hard disks when you detach them from the VM or when you undeploy or delete the VM
  • Always be careful when working with VM objects and put requests. If you accidentally remove a link, this could delete a disk or network interface card, for example


Your user role must have at least the following privileges:

  • ROLE_VDC_MANAGE_STORAGE
  • ROLE_VDC_MANAGE_STORAGE_CONTROLLER
  • ROLE_MANAGE_HARD_DISKS

Feature description and UI documentation:


To add a hard disk to a VM through the API, the main steps are as follows.

  1. Create a hard disk in the virtual datacenter
  2. Update the VM to add the hard disk link in the disk sequence 

This may appear to be different to how you add a hard disk through the UI, where you work directly in the VM. But behind the scenes, the UI uses the API to create the hard disk in the virtual datacenter and then adds it to the VM.


Summary diagram

The steps in this diagram link to the pages of the API reference guide for resources and data entities.



Detailed steps

  1. Get VM from the cloud and separate the VM entity
    1. Filter the VMs by vmlabel, for example
    2. Reference: https://wiki.abiquo.com/api/latest/AllVirtualMachinesResource.html#list-virtual-machines-of-the-user
    3. cURL

      curl -X GET "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualmachines?vmlabel=yVM_hd" \
      	-H "Accept: application/vnd.abiquo.virtualmachines+json;version=4.7" \
      	-u user:password | jq .
    4. Sample response. Success status code: 200
      Note that this request returns a collection of VMs, you will need to get the VM from within the collection. You can also use the edit link to obtain the VM only

       Click here to expand...
      {
          "totalSize": 1,
          "links": [
              {
                  "rel": "first",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualmachines?vmlabel=yVM_hd&limit=25&by=name&asc=true"
              },
              {
                  "rel": "last",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualmachines?vmlabel=yVM_hd&startwith=0&limit=25&by=name&asc=true"
              }
          ],
          "collection": [
              {
                  "id": 16493,
                  "uuid": "9fde7006-8420-4c82-96b8-cf61157eb66e",
                  "description": "A virtual machine",
                  "coresPerSocket": 1,
                  "idState": 1,
                  "idType": 0,
                  "type": "MANAGED",
                  "highDisponibility": 0,
                  "metadata": {
                      "monitoring-metrics": [
                          {
                              "name": "CPU-Mz"
                          },
                          {
                              "name": "Memory-host"
                          },
                          {
                              "name": "CPU"
                          },
                          {
                              "name": "Memory"
                          },
                          {
                              "name": "Memory-vmmemctl"
                          },
                          {
                              "name": "Memory-swap2"
                          },
                          {
                              "name": "abq-ram_usage"
                          },
                          {
                              "name": "Disk-latency"
                          },
                          {
                              "name": "Memory-swap"
                          },
                          {
                              "name": "abq-cpu_usage"
                          },
                          {
                              "name": "Uptime"
                          },
                          {
                              "name": "CPU-time"
                          },
                          {
                              "name": "Memory-physical"
                          }
                      ]
                  },
                  "monitored": true,
                  "protected": false,
                  "variables": {},
                  "backuppolicies": [],
                  "generateGuestInitialPassword": false,
                  "natrules": [],
                  "vdrpEnabled": true,
                  "vdrpPort": 0,
                  "password": "KnZSQW07",
                  "name": "ABQ_9fde7006-8420-4c82-96b8-cf61157eb66e",
                  "label": "yVM_hd",
                  "ram": 64,
                  "cpu": 1,
                  "state": "NOT_ALLOCATED",
                  "creationTimestamp": 1576236231000,
                  "links": [
                      {
                          "title": "4.7.0_Snapshot Enterprise testing",
                          "rel": "enterprise",
                          "type": "application/vnd.abiquo.enterprise+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/admin/enterprises/261"
                      },
                      {
                          "title": "ABQ_9fde7006-8420-4c82-96b8-cf61157eb66e",
                          "rel": "edit",
                          "type": "application/vnd.abiquo.virtualmachine+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493"
                      },
                      {
                          "title": "send mail",
                          "rel": "sendmail",
                          "type": "application/vnd.abiquo.mail+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/admin/publiccloudregions/1/enterprises/261/virtualmachines/16493/action/sendmail"
                      },
                      {
                          "title": "cloudadmin cloudadmin",
                          "rel": "user",
                          "type": "application/vnd.abiquo.user+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/admin/enterprises/261/users/10"
                      },
                      {
                          "title": "vdc_ESXI_vCenter",
                          "rel": "virtualdatacenter",
                          "type": "application/vnd.abiquo.virtualdatacenter+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896"
                      },
                      {
                          "title": "vappESXI470",
                          "rel": "virtualappliance",
                          "type": "application/vnd.abiquo.virtualappliance+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377"
                      },
                      {
                          "title": "metadata",
                          "rel": "metadata",
                          "type": "application/vnd.abiquo.metadata+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/metadata"
                      },
                      {
                          "title": "vlan network configurations",
                          "rel": "configurations",
                          "type": "application/vnd.abiquo.virtualmachinenetworkconfigurations+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/network/configurations"
                      },
                      {
                          "title": "nics",
                          "rel": "nics",
                          "type": "application/vnd.abiquo.nics+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/network/nics"
                      },
                      {
                          "title": "disks",
                          "rel": "harddisks",
                          "type": "application/vnd.abiquo.harddisks+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/storage/disks"
                      },
                      {
                          "title": "NOT_ALLOCATED",
                          "rel": "state",
                          "type": "application/vnd.abiquo.virtualmachinestate+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/state"
                      },
                      {
                          "title": "virtual machine undeploy",
                          "rel": "undeploy",
                          "type": "application/vnd.abiquo.acceptedrequest+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/action/undeploy"
                      },
                      {
                          "title": "virtual machine deploy",
                          "rel": "deploy",
                          "type": "application/vnd.abiquo.acceptedrequest+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/action/deploy"
                      },
                      {
                          "title": "virtual machine reset",
                          "rel": "reset",
                          "type": "application/vnd.abiquo.acceptedrequest+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/action/reset"
                      },
                      {
                          "title": "virtual machine snapshot",
                          "rel": "instance",
                          "type": "application/vnd.abiquo.acceptedrequest+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/action/instance"
                      },
                      {
                          "title": "remote access",
                          "rel": "rdpaccess",
                          "type": "application/vnd.abiquo.virtualmachineconsole+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/config/rdpaccess"
                      },
                      {
                          "title": "tasks",
                          "rel": "tasks",
                          "type": "application/vnd.abiquo.tasks+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/tasks"
                      },
                      {
                          "title": "firewalls",
                          "rel": "firewalls",
                          "type": "application/vnd.abiquo.links+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/firewalls"
                      },
                      {
                          "title": "load balancers",
                          "rel": "loadbalancers",
                          "type": "application/vnd.abiquo.loadbalancers+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/loadbalancers"
                      },
                      {
                          "title": "request on demand backup",
                          "rel": "requestbackup",
                          "type": "application/vnd.abiquo.ondemandbackup+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/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/1896/virtualappliances/2377/virtualmachines/16493/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/1896/virtualappliances/2377/virtualmachines/16493/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/1896/virtualappliances/2377/virtualmachines/16493/action/move"
                      },
                      {
                          "title": "volumes",
                          "rel": "volumes",
                          "type": "application/vnd.abiquo.volumes+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/storage/volumes"
                      },
                      {
                          "title": "ABQ_HP_1_64_08c1daf8",
                          "rel": "hardwareprofile",
                          "type": "application/vnd.abiquo.hardwareprofile+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/locations/1/hardwareprofiles/41457"
                      },
                      {
                          "diskControllerType": "SCSI",
                          "length": "10",
                          "title": "01volume470",
                          "rel": "disk1",
                          "type": "application/vnd.abiquo.volume+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/locations/1/volumes/14993"
                      },
                      {
                          "diskControllerType": "IDE",
                          "diskLabel": "Hard disk 1",
                          "length": "64",
                          "title": "91feae48-4134-484a-9487-473f577856e1",
                          "rel": "disk0",
                          "type": "application/vnd.abiquo.harddisk+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/disks/15000"
                      },
                      {
                          "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/1896/virtualappliances/2377/virtualmachines/16493/action/protect"
                      },
                      {
                          "title": "unprotect",
                          "rel": "unprotect",
                          "type": "text/plain",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/action/unprotect"
                      },
                      {
                          "title": "metricsmetadata",
                          "rel": "metricsmetadata",
                          "type": "application/vnd.abiquo.metricsmetadata+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/metrics"
                      },
                      {
                          "title": "disablemonitoring",
                          "rel": "disablemonitoring",
                          "type": "",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/disablemonitoring"
                      },
                      {
                          "title": "collectd",
                          "rel": "collectd",
                          "type": "application/json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/metrics/collectd"
                      },
                      {
                          "title": "alarmssearch",
                          "rel": "alarmssearch",
                          "type": "application/vnd.abiquo.alarms+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/alarms"
                      },
                      {
                          "title": "clone",
                          "rel": "clone",
                          "type": "application/vnd.abiquo.virtualmachinecloneoptions+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/action/clone"
                      },
                      {
                          "title": "VMware vCenter",
                          "rel": "hypervisortype",
                          "type": "application/vnd.abiquo.hypervisortype+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/config/hypervisortypes/VMX_04"
                      },
                      {
                          "title": "yVM_Abiquo_enterprise",
                          "rel": "virtualmachinetemplate",
                          "type": "application/vnd.abiquo.virtualmachinetemplate+json",
                          "href": "https://nardo40.bcn.abiquo.com:443/api/admin/enterprises/261/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"
                      }
                  ],
                  "usageStatistics": []
              }
          ],
          "duplicatedvms": []
      }
    5.  Keep the VM entity to update it. You will need the harddisks, datastore tiers, diskX, and virtualdatacenter links

       Click here to expand...
      1. harddisks

                        {
                            "title": "disks",
                            "rel": "harddisks",
                            "type": "application/vnd.abiquo.harddisks+json",
                            "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493/storage/disks"
                        },
      2. diskX links for all hard disks and volumes that are already attached to the VM. In this case, there is one HD in position 0 of the boot order and one volume in position 1. Add the new disk in the next position.

                        {
                            "diskControllerType": "IDE",
                            "diskLabel": "Hard disk 1",
                            "length": "64",
                            "title": "91feae48-4134-484a-9487-473f577856e1",
                            "rel": "disk0",
                            "type": "application/vnd.abiquo.harddisk+json",
                            "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/disks/15000"
                        },
                        {
                            "diskControllerType": "SCSI",
                            "length": "10",
                            "title": "01volume470",
                            "rel": "disk1",
                            "type": "application/vnd.abiquo.volume+json",
                            "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/locations/1/volumes/14993"
                        },
      3. datastoretierX

                        {
                            "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"
                        },
      4. virtualdatacenter

                        {
                            "title": "vdc_ESXI_vCenter",
                            "rel": "virtualdatacenter",
                            "type": "application/vnd.abiquo.virtualdatacenter+json",
                            "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896"
                        },
  2. Use the VDC link from the VM to get the VDC

    1. Reference: https://wiki.abiquo.com/api/latest/VirtualDatacentersResource.html#get-a-virtual-datacenter

    2. cURL

      curl -X GET "https://abiquoapi.bcn.abiquo.com/api/cloud/virtualdatacenters/1896" \
          -H 'Accept: application/vnd.abiquo.virtualdatacenter+json;version=4.7' \
          -u user:password --verbose
    3. Sample response. Success status code: 200

       Click here to expand...
      {
          "id": 1896,
          "hypervisorType": "VMX_04",
          "name": "vdc_ESXI_vCenter",
          "network": {
              "id": 2496,
              "name": "default_private_network",
              "address": "192.168.0.0",
              "mask": 24,
              "gateway": "192.168.0.1",
              "primaryDNS": "10.60.1.4",
              "secondaryDNS": "8.8.8.8",
              "sufixDNS": "",
              "tag": 9,
              "defaultNetwork": false,
              "type": "INTERNAL",
              "dhcpOptions": {
                  "links": [],
                  "collection": []
              },
              "ipv6": false,
              "strict": false,
              "restricted": false,
              "internetGatewayRole": false,
              "ipRanges": [],
              "excludedFromFirewall": false,
              "notUsableLoadBalancers": false,
              "notUsableVirtualMachines": false,
              "links": [
                  {
                      "title": "vdc_ESXI_vCenter",
                      "rel": "virtualdatacenter",
                      "type": "application/vnd.abiquo.virtualdatacenter+json",
                      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896"
                  },
                  {
                      "title": "default_private_network",
                      "rel": "edit",
                      "type": "application/vnd.abiquo.vlan+json",
                      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/privatenetworks/2496"
                  },
                  {
                      "title": "ips",
                      "rel": "ips",
                      "type": "application/vnd.abiquo.privateips+json",
                      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/privatenetworks/2496/ips"
                  },
                  {
                      "title": "Service Network dvSwitch",
                      "rel": "networkservicetype",
                      "type": "application/vnd.abiquo.networkservicetype+json",
                      "href": "https://nardo40.bcn.abiquo.com:443/api/admin/datacenters/1/networkservicetypes/1"
                  },
                  {
                      "title": "load balancers",
                      "rel": "loadbalancers",
                      "type": "application/vnd.abiquo.loadbalancers+json",
                      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/privatenetworks/2496/loadbalancers"
                  },
                  {
                      "title": "configuration",
                      "rel": "configuration",
                      "type": "application/vnd.abiquo.networkconfiguration+json",
                      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/privatenetworks/2496/configuration"
                  },
                  {
                      "title": "192.168.0.0/24",
                      "rel": "network_configuration",
                      "type": "application/vnd.abiquo.networkconfiguration+json",
                      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/privatenetworks/2496/configuration/2496"
                  },
                  {
                      "title": "reserve a set of ips",
                      "rel": "reserveips",
                      "type": "application/vnd.abiquo.ipliterals+json",
                      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/privatenetworks/2496/ips/action/reserve"
                  },
                  {
                      "title": "release a set of ips",
                      "rel": "releaseips",
                      "type": "application/vnd.abiquo.ipliterals+json",
                      "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/privatenetworks/2496/ips/action/release"
                  }
              ]
          },
          "syncState": "NONE",
          "usersRole": [],
          "diskSoftLimitInMb": 0,
          "diskHardLimitInMb": 0,
          "storageSoftInMb": 0,
          "storageHardInMb": 0,
          "vmsSoft": 0,
          "vmsHard": 0,
          "vlansSoft": 0,
          "vlansHard": 0,
          "publicIpsSoft": 0,
          "publicIpsHard": 0,
          "links": [
              {
                  "title": "vdc_ESXI_vCenter",
                  "rel": "edit",
                  "type": "application/vnd.abiquo.virtualdatacenter+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896"
              },
              {
                  "title": "private networks",
                  "rel": "privatenetworks",
                  "type": "application/vnd.abiquo.vlans+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/privatenetworks"
              },
              {
                  "title": "public networks",
                  "rel": "network",
                  "type": "application/vnd.abiquo.vlans+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/admin/datacenters/1/network"
              },
              {
                  "rel": "asynctasks",
                  "type": "application/vnd.abiquo.asynctasks+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/asynctasks"
              },
              {
                  "title": "default_private_network",
                  "rel": "defaultvlan",
                  "type": "application/vnd.abiquo.vlan+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/privatenetworks/2496"
              },
              {
                  "title": "4.7.0_Snapshot Enterprise testing",
                  "rel": "enterprise",
                  "type": "application/vnd.abiquo.enterprise+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/admin/enterprises/261"
              },
              {
                  "title": "virtual appliances",
                  "rel": "virtualappliances",
                  "type": "application/vnd.abiquo.virtualappliances+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances"
              },
              {
                  "title": "private ips",
                  "rel": "privateips",
                  "type": "application/vnd.abiquo.privateips+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/action/privateips"
              },
              {
                  "title": "external ips",
                  "rel": "externalips",
                  "type": "application/vnd.abiquo.externalips+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/action/externalips"
              },
              {
                  "title": "unmanaged ips",
                  "rel": "unmanagedips",
                  "type": "application/vnd.abiquo.unmanagedips+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/action/unmanagedips"
              },
              {
                  "title": "default vlan",
                  "rel": "defaultvlan",
                  "type": "application/vnd.abiquo.vlan+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/action/defaultvlan"
              },
              {
                  "title": "disks",
                  "rel": "disks",
                  "type": "application/vnd.abiquo.harddisks+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/disks"
              },
              {
                  "title": "ips to purchase",
                  "rel": "topurchase",
                  "type": "application/vnd.abiquo.publicips+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/publicips/topurchase"
              },
              {
                  "title": "ips purchased",
                  "rel": "purchased",
                  "type": "application/vnd.abiquo.publicips+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/publicips/purchased"
              },
              {
                  "title": "volumes",
                  "rel": "volumes",
                  "type": "application/vnd.abiquo.volumes+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/volumes"
              },
              {
                  "title": "tiers",
                  "rel": "tiers",
                  "type": "application/vnd.abiquo.tiers+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/locations/1/tiers"
              },
              {
                  "title": "stateful volumes",
                  "rel": "statefulcandidates",
                  "type": "application/vnd.abiquo.volumes+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/volumes/action/statefulcandidates"
              },
              {
                  "title": "available templates",
                  "rel": "templates",
                  "type": "application/vnd.abiquo.virtualmachinetemplates+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/action/templates"
              },
              {
                  "title": "all virtual machines",
                  "rel": "virtualmachines",
                  "type": "application/vnd.abiquo.virtualmachines+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/action/virtualmachines"
              },
              {
                  "title": "datastoretierESXI6.0_2.29",
                  "rel": "defaultdatastoretier",
                  "type": "application/vnd.abiquo.datastoretier+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/locations/1/datastoretiers/58"
              },
              {
                  "title": "Abiquo-DC",
                  "rel": "location",
                  "type": "application/vnd.abiquo.datacenter+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/locations/1"
              },
              {
                  "title": "tasks",
                  "rel": "tasks",
                  "type": "application/vnd.abiquo.tasks+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/tasks"
              },
              {
                  "title": "location limit",
                  "rel": "limit",
                  "type": "application/vnd.abiquo.limit+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/admin/enterprises/261/limits/991"
              },
              {
                  "title": "externalnetworks",
                  "rel": "externalnetworks",
                  "type": "application/vnd.abiquo.vlans+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/admin/enterprises/261/limits/991/externalnetworks"
              },
              {
                  "title": "virtual appliances specs",
                  "rel": "vappspecs",
                  "type": "application/vnd.abiquo.virtualappliancespecs+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/vappspecs"
              },
              {
                  "title": "Euro - €",
                  "rel": "currency",
                  "type": "application/vnd.abiquo.currency+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/config/currencies/2"
              },
              {
                  "title": "alarmssearch",
                  "rel": "alarmssearch",
                  "type": "application/vnd.abiquo.alarms+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/alarms"
              }
          ],
          "ramSoft": 0,
          "ramHard": 0,
          "cpuSoft": 0,
          "cpuHard": 0
      }
    4. From the virtual datacenter save the link with a rel value of "disks"

              {
                  "title": "disks",
                  "rel": "disks",
                  "type": "application/vnd.abiquo.harddisks+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/disks"
              },
  3. Create a data object for the hard disk

    • Reference: https://wiki.abiquo.com/api/latest/harddisk.html
    • Sample hard disk entity

      {
         "links":[],
         "sizeInMb":20,
         "sequence":2,
         "allocation":"THIN",
         "diskControllerType":"SCSI",
         "label":"test disk 04",
         "diskController":"lsilogic"
      }
    • Optionally specify a datastore tier with a link

  4. Create the hard disk in the VDC

    1. Send a POST request to the virtual datacenter disks link with the disk data object.

      curl --verbose -X POST "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/disks" \
      	-H "Accept: application/vnd.abiquo.harddisk+json;version=4.7" \
      	-H "Content-Type: application/vnd.abiquo.harddisk+json;version=4.7" \
      	-u user:password -k \
      	-d '{
         "links":[ ],
         "sizeInMb":20,
         "sequence":2,
         "allocation":"THIN",
         "diskControllerType":"SCSI",
         "label":"test disk 04",
         "diskController":"lsilogic"
      }' | jq .
    2. Sample response. Success status code: 201

       Click here to expand...
      {
          "id": 15010,
          "label": "test disk 04",
          "sequence": 0,
          "sizeInMb": 20,
          "diskFormatType": "RAW",
          "diskFileSize": 0,
          "diskControllerType": "SCSI",
          "diskController": "lsilogic",
          "bootable": false,
          "uuid": "8b2ea7af-1a71-48fe-aa51-79102a8873e2",
          "allocation": "THIN",
          "links": [
              {
                  "title": "vdc_ESXI_vCenter",
                  "rel": "virtualdatacenter",
                  "type": "application/vnd.abiquo.virtualdatacenter+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896"
              },
              {
                  "diskAllocation": "THIN",
                  "diskController": "lsilogic",
                  "diskControllerType": "SCSI",
                  "diskLabel": "test disk 04",
                  "rel": "edit",
                  "type": "application/vnd.abiquo.harddisk+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/disks/15010"
              }
          ]
      }
    3. Keep the edit link to use to assign the hard disk to the VM

              {
                  "diskAllocation": "THIN",
                  "diskController": "lsilogic",
                  "diskControllerType": "SCSI",
                  "diskLabel": "test disk 04",
                  "rel": "edit",
                  "type": "application/vnd.abiquo.harddisk+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/disks/15010"
              }
  5. Create disk link and to add to the VM entity

    1. Change the edit link to diskX with the next number in the disk sequence. In this case, for the third disk, we will use "disk2"

              {
                  "diskAllocation": "THIN",
                  "diskController": "lsilogic",
                  "diskControllerType": "SCSI",
                  "diskLabel": "test disk 04",
                  "rel": "disk2",
                  "type": "application/vnd.abiquo.harddisk+json",
                  "href": "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/disks/15010"
              }
  6. Power off the VM if it is deployed without hot reconfigure

    1. Send a PUT request to the VM state link. 
    2. To power off, set the state attribute to "OFF". To shut down the VM, add the "gracefulShutdown" attribute and set it to "true". Note that the graceful shutdown may require VM tools.
    3. cURL

      curl --verbose -X PUT "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182/state" \
      	-H "Content-Type: application/vnd.abiquo.virtualmachinestate+json;version=4.2" \
      	-d '{"state": "OFF", "gracefulShutdown": true}' \
      	-u user:password -k 
    4. If the request returns a status code of 202, that means it was accepted. However, you should always check that the VM is really powered off.
  7. Get the VM again using the VM edit link. This step is just included in the walkthrough to ensure that your VM object is up to date! 

    curl -X GET "https://nardo40.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1896/virtualappliances/2377/virtualmachines/16493" \
    	-H "Accept: application/vnd.abiquo.virtualmachine+json;version=4.7" \
    	-u user:password | jq .
  8. Update the VM with a VM entity containing the new disk link


 Click here to expand...

 

Modify the link to the hard disk to add it in the boot sequence of the VM

To add the hard disk to the VM, we will modify the VM entity and add a link to the hard disk. So the first step is to create a link to the hard disk.

First check if there are already any existing disks in the VM to determine the boot sequence. The disk "rel" (relation) link values are in the format "diskX", where "X" is the sequence number starting with 0 for the boot disk.

This is the boot disk of the VM taken from the VM object.

And this is the edit link of our hard disk.

So we should modify the edit link from the hard disk and change the "rel" link to specify that it should be included in the VM boot sequence as "disk3". So the link to send in the VM put request would look like this:

Next we will add this link to the VM.

Edit the VM data object to add the link to the hard disk

Add the link at the end of the links section. Don't forget to add a comma before the new link!

 Click here to expand...

 

Modify the VM to add the hard disk

Now we need to send a PUT request to the VM to modify it and add the hard disk. The VM data object is enormous, so we saved it to a file and used the @ notation to specify the file. If the request is successful, for a VM that is not deployed, the status code returned will be a 204, with no content. If the VM is deployed, a successful request will return a status of 202 Accepted and an accepted request object, with a link to the reconfigure task.

curl --verbose -X PUT "https://example.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182" \
	-H "Content-Type: application/vnd.abiquo.virtualmachine+json;version=4.2" \
	-d @vmwithhd.json \
	-u user:password -k | jq .

 

Check the result in your VM

Get the VM to check that the disk has been added.

curl --verbose -X GET "https://example.com:443/api/cloud/virtualdatacenters/3/virtualappliances/4/virtualmachines/182" \
	-H "Accept: application/vnd.abiquo.virtualmachine+json;version=4.2" \
	-u user:password -k | jq .

The disk was added successfully because this disk3 link can be found in the following VM object.

        {
            "diskAllocation": "THIN",
            "diskController": "lsilogic",
            "diskControllerType": "SCSI",
            "diskLabel": "test disk 04",
            "rel": "disk3",
            "type": "application/vnd.abiquo.harddisk+json",
            "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/3/disks/13"
        },


 Click here to expand...

 

  • No labels