How to use cmd glance md-object-create

Created by Nikhil Komawar on on 2016-05-14
Keywords:
metadefs
Last updated by:
Nikhil Komawar on on 2016-05-14

Author of this content is Travis Tripp ( https://launchpad.net/~travis-tripp ):

FAQ answer:

It is possible that you hit a bug which has been fixed, but may not be released yet: https://bugs.launchpad.net/python-glanceclient/+bug/1536430

Besides that, the Glance API docs for metadefs contain many excellent examples:

http://developer.openstack.org/api-ref-image-v2.html#metadefs-namespaces-objects-v2

For example, click on POST --> Detail and you'll see several examples. The example provided in the link for POST namespace can be easily expanded with other optional data(properties, etc).

There are many concrete complete namespace examples using any json file in
 - https://github.com/openstack/glance/tree/master/etc/metadefs

Right now much of the content out of the box is OpenStack specific content. However, it definitely is intended for the broad usage that you mentioned so that you can create your own content specific to you cloud. For example, you may create some custom metadata definitions that you use to help manage associations between host aggregates, flavors, and images (when used with the host aggregates filter).

Have you had a chance to read this, yet? If not, I think it’ll answer a lot of questions.
 - http://docs.openstack.org/developer/glance/metadefs-concepts.html

My typical workflow is to basically create a json namespace file. In the file put in properties using simple json schema syntax (no nested properties). Then upload via CLI or horizon.

If you are on the glance host, you can also use the upgrade commands in glance-manage in conjunction with the json:
 - glance-manage db load_metadefs [path] [merge] [prefer_new]

Please note that glance-manage expects to connect directly into the DB and is typically used at deployment time.

Otherwise, you can use the CLI or direclty use the API. As FYI, here is the API overview:
 - http://docs.openstack.org/developer/glance/glancemetadefcatalogapi.html

Here are a number of links to different APIs:

 - http://developer.openstack.org/api-ref-image-v2.html#metadefs-namespaces-v2
 - http://developer.openstack.org/api-ref-image-v2.html#os-metadef-resourcetype-v2
 - http://developer.openstack.org/api-ref-image-v2.html#metadefs-namespaces-properties-v2
 - http://developer.openstack.org/api-ref-image-v2.html#metadefs-namespaces-objects-v2
 - http://developer.openstack.org/api-ref-image-v2.html#metadefs-namespaces-tags-v2
 - http://developer.openstack.org/api-ref-image-v2.html#schemas-metadefs-v2