How to use cmd glance md-object-create

Asked by Wenjun Wang

i can't give a right argument of schema,i made a file called schema.json with the json of these:
{
  "name": "Image",
  "description": "Image description",
  "required": [],
  "properties": {
  }
}
then excute: glance md-object-create --name test --schema schema.json test_namespace
responsed with "Schema is not a valid JSON object."
it's must my fault,but what's right?,thanks to help.

Question information

Language:
English Edit question
Status:
Solved
For:
Glance Edit question
Assignee:
No assignee Edit question
Solved by:
Nikhil Komawar
Solved:
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Nikhil Komawar (nikhil-komawar) said :
#2

Re-opening

Revision history for this message
Travis Tripp (travis-tripp) said :
#3

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

Revision history for this message
Best Nikhil Komawar (nikhil-komawar) said :
#4

nikhil komawar suggests this article as an answer to your question:
FAQ #2777: “How to use cmd glance md-object-create”.

Revision history for this message
Wenjun Wang (wangwenjun) said :
#5

very nice.thank you very much.