2.8.3. Set Metadata

Verb URI Description
PUT /servers/id/metadata Sets metadata for the specified server.
PUT /images/id/metadata Sets metadata for the specified image.

Normal Response Code: 200

Error Response Codes: computeFault (400, 500, …), badRequest (400), unauthorized (401), forbidden (403), itemNotFound (404), Method Not Allowed (405), buildInProgress (409), overLimit (413), badMediaType (415), serviceUnavailable (503)

Sets metadata for the specified server or image.

Specify the server or image ID as id in the URI.

In the request body, specify the metadata element followed by attributes.

The following table describes the attributes that you can set in the request body:

Table 2.12. Set Metadata Request Attributes
Attribute Description Required
metadata

Key and value pairs for metadata.

Yes

Existing metadata items are replaced with the ones provided in the request regardless of the names of the original metadata items.

If you exceed the maximum number of metadata items, the call throws an overLimit (413) fault.

You can query the maximum number of key-value pairs that can be supplied for each server through the maxServerMeta absolute limit. You can query the maximum number of key-value pairs for an image through the maxImageMeta absolute limit. See Section 1.9.3, “Get Limits”.

 

Example 2.88. Set Metadata: JSON Request

{
    "metadata": {
        "Label" : "Web",
        "Version" : "2.1"
    }
}

 

Example 2.89. Set Metadata: JSON Response

{
    "metadata": {
        "Label" : "Web",
        "Version" : "2.1"
    }
}

 

Example 2.90. Set Metadata: XML Request

<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://docs.openstack.org/compute/api/v1.1">
    <meta key="Label">Web</meta>
    <meta key="Version">2.1</meta>
</metadata>

 

Example 2.91. Set Metadata: XML Response

<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://docs.openstack.org/compute/api/v1.1">
    <meta key="Label">Web</meta>
    <meta key="Version">2.1</meta>
</metadata>



loading table of contents...