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.
|
...
|
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)
Get the VM and the metadata link
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 | ||
---|---|---|
| ||
Success status code: 200 Response:
|
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.
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!
Access metadata as part of the VM
...
Some API references about working with VM metadata: