Setting Server Image Metadata Items

In the previous section you learned how to set multiple metadata items in one go. But what if you wanted to set them one at a time?

Once again, you need to use the PUT method and a URI that points to the metadata you wish to set, e.g. /images/id/metadata/key.

The id part is the numeric id of the server image. For example, if you wanted to set the owner metadata key of the server image whose id is 1, the path would be /images/1/metadata/owner.

The value of the key set has to be passed to the OpenStack Compute API server as a single-key metadata dictionary:

{
  "metadata": {
    "owner": "joe"
  }
}

If you were to use curl to set metadata keys, this is how you'd do it:

$ curl -X PUT -H "X-Auth-Token:999888777666" -H "Accept: application/json" -d '{"metadata":{"owner":"joe"}}' http://localhost:8774/v1.1/openstack/images/1/metadata/owner


loading table of contents...