Jump to: navigation, search

Difference between revisions of "Trove-Instance-Metadata"

(Update)
(API Response =)
Line 62: Line 62:
 
</pre>
 
</pre>
  
=== API Response ====
+
=== API Response ===
  
 
==== Response Codes ====
 
==== Response Codes ====

Revision as of 02:53, 31 March 2014

Introduction

This wiki page describes the design for adding user managed metadata to instances.

Blueprint

https://blueprints.launchpad.net/trove/+spec/trove-metadata

Goals

  1. Give trove users the ability to store key/value pairs that have significance to them but is not essential to trove's functionality
  2. Create a user accessible rest API to manage instance metadata
  3. Mimic the design/interface used by Nova for metadata
  4. Implement the model so that it acts like a dictionary to make hooking in metadata into the instance very easy and small

Description

Instance metadata is a feature that has been requested frequently by our users. They need a way to store critical information for their instances and have that be associated with the instance so that it is displayed whenever that instance is listed via the API. This also becomes very usable from a testing perspective when doing integration/ci. We can utilize the metadata to store things like what process created the instance, what the instance is being used for, etc... The design for this feature is modeled heavily on the Nova metadata API with a few tweaks in how it works internally.

With the likelihood of an Openstack official metadata service on the horizon I felt like we needed to keep the entry point of integration very small so that when that service becomes available there will be little code in the instance model to change to make that integration happen. To achieve this I made the model work using the dictionary interface and kept all the heavy lifting and fetching/saving operations are internal to the model and happen automatically when keys are modified.

API

The following section describes the API interface both what needs to be sent to the api and what the responses look like.

Create

API Call

API Path and Method

POST /instances/{id}/metadata

Body

{
    "metadata": {
        "value": {"one": {"two": [3, 4, 5]}}
    }
}

API Response

Response Codes

  • Positive: 200
  • Negative: 400

Response Body

{
    "metadata": {
        "newKey": {"one": {"two": [3, 4, 5]}}
    }
}

Update

Substitute a key and value in the database with a new key and value.

API Call

API Path and Method

PUT /instances/{id}/metadata/{key}

Body

{
    "metadata": {
        "key": "newKey2",
        "value": {"one": {"two": [3, 4, 5]}}
    }
}

API Response

Response Codes

  • Positive: 200
  • Negative: 404

Response Body

None

Replace

PATCH /instances/{id}/metadata/{key}

Body

{
    "metadata": {
        "value": {"one": {"two": [3, 4, 5], "key2": "the value of this key is a string"}}
    }
}

Response

Codes:

  • Positive: 200
  • Negative: 404

Empty body in response

Delete

Show

List

TroveClient

Create

Update

Replace

Delete

Show

List

Integration with Instance

Discussion