Versions Compared

Key

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

...

After you escape the special characters to add it to the JSON object, it will look like this:

Code Block
#cloud-config\r\nhostname: \"userdatahostname\"\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\"

...

Add the startup script to the metadata object with the "startup-script" key. Don't forget to put add a comma before itafter the previous objectSo After you add the startup script, the metadata object with the startup script added should look something like this:

...

Get metadata as part of the VM

Here we have made a GET request to obtain the VM object and removed the links to make it smaller. The metadata object is shown as part of the VM.

Code Block
        {
            "id": 24,
            "uuid": "2fade39a-fe59-44b4-be3f-b96b63b48153",
            "name": "ABQ_2fade39a-fe59-44b4-be3f-b96b63b48153",
            "label": "VM_metadata",
            "description": "A virtual machine",
            "cpu": 1,
            "ram": 48,
            "vdrpEnabled": true,
            "vdrpPort": 0,
            "idState": 1,
            "state": "NOT_ALLOCATED",
            "idType": 0,
            "type": "MANAGED",
            "highDisponibility": 0,
            "password": "uMvMpfyD",
            "metadata": {
                "monitoring-metrics": [
                    {
                        "name": "cpu_time"
                    },
                    {
                        "name": "used_mem"
                    }
                ],
                "startup-script": "#cloud-config\r\nhostname: \"userdatahostname\"\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\""
            },
            "monitored": true,
            "protected": false,
            "variables": {},
            "creationTimestamp": 1520865331000,
            "backuppolicies": [],
            "generateGuestInitialPassword": false,
            "natrules": [],

  ....
        }

The However, the appropriate and most convenient way to work with metadata is using the metadata link!

...