Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Abiquo virtual machine metadata

...

Note: Do not use a conversion tool to convert between JSON and XML format because this may produce an incompatible data transfer object.

Excerpt

For the metadata attribute or object, Abiquo has the reserved keys that are described in the following table.

Metadata type

Reserved

...

keys

Description

Chef

  • chef

  • Users enter Chef recipe attributes as JSON in the UI, in the VM dialog on the Chef / Attributes tab 

  • Abiquo stores the recipe attributes that you enter in JSON format as an escaped string under the chef key

Bootstrap script

  • startup-script

  • Cloud-config for use by cloud-init

  • Users enter Startup script in the UI, on the VM dialog on the Bootstrap script tab

Metrics

  • monitoring-metrics

  • Names of the metrics available for the VM – useful for accessing metrics via API

Custom

...


  • Append custom metadata to the existing metadata

  • Do not use the Abiquo reserved metadata keys

VM metadata tutorial

This tutorial will show you how to retrieve and update metadata to add a startup script to your VM via API.

To work through this tutorial, you will need:

  • A VM that is not deployed (or a VM that is powered off)

    • This tutorial uses an example VM that is not deployed

  • User with privileges to work with VMs and Manage virtual machine backup configuration (VAPP_MANAGE_BACKUP) because backups previously used metadata

  • Optional: a monitoring server and a user with the privileges to Manage virtual machine metrics (USERS_ENABLE_DISABLE_VM_METRICS)

To get started, use a query to retrieve all of your VMs from the cloud and select the desired VM. Here we are filtering the VMs using the "vmlabel" parameter to select the one that has a text string (in this case "metadata") as part of the name, which is an easy way to find a VM that you have located in the UI.

...

...

GET all virtual machines in the cloud, filtering by name
Code Block
curl -X GET https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualmachines?vmlabel=metadata \
	-H "Accept: application/vnd.abiquo.virtualmachines+json; version=4.7" \ 
	-u user:password --verbose | pjson

Expand
titleClick here to show or hide the API response example

Success status code: 200

Response:

Code Block
{
    "totalSize": 1,
    "links": [
        {
            "rel": "first",
            "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualmachines?vmlabel=metadata&limit=25&by=name&asc=true"
        },
        {
            "rel": "last",
            "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualmachines?vmlabel=metadata&startwith=0&limit=25&by=name&asc=true"
        }
    ],
    "collection": [
        {
            "id": 3,
            "uuid": "d0876a63-4238-4182-9d10-5f4f363101b9",
            "description": "root : abiquo",
            "coresPerSocket": 1,
            "idState": 1,
            "idType": 0,
            "type": "MANAGED",
            "highDisponibility": 0,
            "monitored": false,
            "protected": false,
            "variables": {},
            "backuppolicies": [],
            "generateGuestInitialPassword": false,
            "natrules": [],
            "vdrpEnabled": true,
            "vdrpPort": 0,
            "password": "MLiRXdmv",
            "deallocated": false,
            "name": "ABQ_d0876a63-4238-4182-9d10-5f4f363101b9",
            "label": "metadatavm",
            "ram": 64,
            "cpu": 1,
            "state": "NOT_ALLOCATED",
            "creationTimestamp": 1583494480000,
            "iconUrl": "http://rs.bcn.abiquo.com:9000/public/icons/tinycore.png",
            "links": [
                {
                    "title": "Abiquo",
                    "rel": "enterprise",
                    "type": "application/vnd.abiquo.enterprise+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/1"
                },
                {
                    "title": "ABQ_d0876a63-4238-4182-9d10-5f4f363101b9",
                    "rel": "edit",
                    "type": "application/vnd.abiquo.virtualmachine+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3"
                },
                {
                    "title": "send mail",
                    "rel": "sendmail",
                    "type": "application/vnd.abiquo.mail+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/publiccloudregions/1/enterprises/1/virtualmachines/3/action/sendmail"
                },
                {
                    "title": "Cloud Administrator",
                    "rel": "user",
                    "type": "application/vnd.abiquo.user+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/1/users/1"
                },
                {
                    "title": "bcdc_vdc_01_01_01",
                    "rel": "virtualdatacenter",
                    "type": "application/vnd.abiquo.virtualdatacenter+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1"
                },
                {
                    "title": "bcdc_vapp_aa_aa_aa",
                    "rel": "virtualappliance",
                    "type": "application/vnd.abiquo.virtualappliance+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1"
                },
                {
                    "title": "metadata",
                    "rel": "metadata",
                    "type": "application/vnd.abiquo.metadata+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/metadata"
                },
                {
                    "title": "vlan network configurations",
                    "rel": "configurations",
                    "type": "application/vnd.abiquo.virtualmachinenetworkconfigurations+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/network/configurations"
                },
                {
                    "title": "nics",
                    "rel": "nics",
                    "type": "application/vnd.abiquo.nics+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/network/nics"
                },
                {
                    "title": "disks",
                    "rel": "harddisks",
                    "type": "application/vnd.abiquo.harddisks+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/storage/disks"
                },
                {
                    "title": "NOT_ALLOCATED",
                    "rel": "state",
                    "type": "application/vnd.abiquo.virtualmachinestate+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/state"
                },
                {
                    "title": "virtual machine undeploy",
                    "rel": "undeploy",
                    "type": "application/vnd.abiquo.acceptedrequest+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/action/undeploy"
                },
                {
                    "title": "virtual machine deploy",
                    "rel": "deploy",
                    "type": "application/vnd.abiquo.acceptedrequest+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/action/deploy"
                },
                {
                    "title": "virtual machine reset",
                    "rel": "reset",
                    "type": "application/vnd.abiquo.acceptedrequest+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/action/reset"
                },
                {
                    "title": "virtual machine snapshot",
                    "rel": "instance",
                    "type": "application/vnd.abiquo.acceptedrequest+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/action/instance"
                },
                {
                    "title": "remote access",
                    "rel": "rdpaccess",
                    "type": "application/vnd.abiquo.virtualmachineconsole+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/config/rdpaccess"
                },
                {
                    "title": "tasks",
                    "rel": "tasks",
                    "type": "application/vnd.abiquo.tasks+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/tasks"
                },
                {
                    "title": "firewalls",
                    "rel": "firewalls",
                    "type": "application/vnd.abiquo.links+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/firewalls"
                },
                {
                    "title": "load balancers",
                    "rel": "loadbalancers",
                    "type": "application/vnd.abiquo.loadbalancers+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/loadbalancers"
                },
                {
                    "title": "request on demand backup",
                    "rel": "requestbackup",
                    "type": "application/vnd.abiquo.ondemandbackup+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/backup/action/request"
                },
                {
                    "title": "request a restore of a backup",
                    "rel": "requestrestore",
                    "type": "application/vnd.abiquo.restore+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/backup/action/restore"
                },
                {
                    "title": "move VM to a virtual appliance",
                    "rel": "vappmove",
                    "type": "application/vnd.abiquo.links+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/action/vappmove"
                },
                {
                    "title": "move VM to another virtual datacenter",
                    "rel": "move",
                    "type": "application/vnd.abiquo.movevm+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/action/move"
                },
                {
                    "title": "volumes",
                    "rel": "volumes",
                    "type": "application/vnd.abiquo.volumes+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/storage/volumes"
                },
                {
                    "diskController": "lsilogic",
                    "diskControllerType": "SCSI",
                    "diskLabel": "Hd",
                    "length": "100",
                    "title": "f9693188-5e49-430c-bb38-fc70916dcfb4",
                    "rel": "disk0",
                    "type": "application/vnd.abiquo.harddisk+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/disks/5"
                },
                {
                    "title": "Default Tier",
                    "rel": "datastoretier0",
                    "type": "application/vnd.abiquo.datastoretier+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/locations/1/datastoretiers/1"
                },
                {
                    "diskController": "lsilogic",
                    "diskControllerType": "SCSI",
                    "diskLabel": "Hd",
                    "length": "100",
                    "title": "d5acae19-9202-4bec-a600-4ee66ef4d26b",
                    "rel": "disk1",
                    "type": "application/vnd.abiquo.harddisk+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/disks/6"
                },
                {
                    "title": "Default Tier",
                    "rel": "datastoretier1",
                    "type": "application/vnd.abiquo.datastoretier+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/locations/1/datastoretiers/1"
                },
                {
                    "title": "protect",
                    "rel": "protect",
                    "type": "text/plain",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/action/protect"
                },
                {
                    "title": "unprotect",
                    "rel": "unprotect",
                    "type": "text/plain",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/action/unprotect"
                },
                {
                    "title": "metricsmetadata",
                    "rel": "metricsmetadata",
                    "type": "application/vnd.abiquo.metricsmetadata+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/metrics"
                },
                {
                    "title": "enablemonitoring",
                    "rel": "enablemonitoring",
                    "type": "",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/enablemonitoring"
                },
                {
                    "title": "collectd",
                    "rel": "collectd",
                    "type": "application/json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/metrics/collectd"
                },
                {
                    "title": "alarmssearch",
                    "rel": "alarmssearch",
                    "type": "application/vnd.abiquo.alarms+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/alarms"
                },
                {
                    "title": "clone",
                    "rel": "clone",
                    "type": "application/vnd.abiquo.virtualmachinecloneoptions+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/cloud/virtualdatacenters/1/virtualappliances/1/virtualmachines/3/action/clone"
                },
                {
                    "title": "KVM",
                    "rel": "hypervisortype",
                    "type": "application/vnd.abiquo.hypervisortype+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/config/hypervisortypes/KVM"
                },
                {
                    "title": "core_duplicate",
                    "rel": "virtualmachinetemplate",
                    "type": "application/vnd.abiquo.virtualmachinetemplate+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/admin/enterprises/1/datacenterrepositories/1/virtualmachinetemplates/22"
                },
                {
                    "title": "Others",
                    "rel": "category",
                    "type": "application/vnd.abiquo.category+json",
                    "href": "https://mjsabiquo.bcn.abiquo.com:443/api/config/categories/1"
                }
            ],
            "usageStatistics": []
        }
    ],
    "duplicatedvms": []
} 


From the VM data object, the link to the VM metadata is the one with the "rel" value of metadata.

...

So for example, we have the following script for use with a cloud-init template on a Linux system.

(minus)(minus) Disclaimer: this is a sample script for illustrative purposes only. Please see cloud-init documentation to find out how this script works.

...

In this case, the requestpayload.json file should contain the JSON object from the previous step.

...

Metadata requestpayload.json object
Code Block
{
    "links": [],
    "metadata": {
        "monitoring-metrics": [
            {
                "name": "cpu_time"
            },
            {
                "name": "used_mem"
            }
        ],
        "startup-script": 
"#cloud-config\r\nusers:\r\n  - name: \"myuser\"\r\n  \t# mkpasswd --method=SHA-512 --rounds=4096 mypass\r\n    passwd: \"$6$rounds=4096$aD0didNw\/$Pau0z3YK2Ss5MWYoxScEedfMa.1N5qRqK0xYrgs79qdjHdoFUIRmVXpeEewDduSbImu7sqIjSRm40xO6PpJhk\/\" \r\n    groups:\r\n      - \"sudo\"\r\nssh_authorized_keys:\r\n  - \"ssh-rsa USER_ID_RSA.PUB\"" 
    }
} 

...

Code Block
{
    "metadata": {
        "monitoring-metrics": [
            {
                "name": "used_mem"
            },
            {
                "name": "cpu_time"
            }
        ],
        "startup-script": "#cloud-config\r\nusers:\r\n  - name: \"myuser\"\r\n  \t# mkpasswd --method=SHA-512 --rounds=4096 mypass\r\n    passwd: \"$6$rounds=4096$aD0didNw/$Pau0z3YK2Ss5MWYoxScEedfMa.1N5qRqK0xYrgs79qdjHdoFUIRmVXpeEewDduSbImu7sqIjSRm40xO6PpJhk/\" \r\n    groups:\r\n      - \"sudo\"\r\nssh_authorized_keys:\r\n  - \"ssh-rsa USER_ID_RSA.PUB\""
    },
    "links": []
}

And that's all! (big grin)(big grin)

Access metadata as part of the VM

...

Some API references about working with VM metadata: