How to set image metadata with python API 0.11.0 in openstack grizzly? -
i work devstack-grizzly installation. add image metadata [see code] using openstack python api.
i use glance.images.create , provide metadata properties argument. unfortunately, created image has no metadata (properties). image.get prints none.
import keystoneclient.v2_0.client ksclient import glanceclient keystone = ksclient.client(auth_url=credentials['auth-url'], username=credentials['username'], password=credentials['password'], tenant_name=credentials['tenant']) glance_endpoint = keystone.service_catalog.url_for(service_type='image', endpoint_type='publicurl') glance = glanceclient.client('1',glance_endpoint, token=keystone.auth_token) image_name="test-cirros" image_file="cirros.img" open( image_file ) fimage: image = glance.images.create(name=image_name, is_public=true, disk_format="qcow2", container_format="bare", data=fimage, properties = {"aaaa": "13", "'bbbbbb": "12"} ) print image.get() // prints none
is there other way of setting image metadata?
custom properties != metadata, horizon not display them , image.get returns empty hash.
to grab metadata, need use nova client (api version 1.1 --- nova.images.get(image.id).metadata):
# ... novaclient import client novaclient # ... nova = novaclient.client("1.1", auth_url=credentials['auth-url'], username=credentials['username'], api_key=credentials['password'], project_id=credentials['tenant']) # ... open( image_file ) fimage: image = glance.images.create(name=image_name, is_public=true, disk_format="qcow2", container_format="bare", data=fimage, properties = {"aaaa": "13", "'bbbbbb": "12"} ) print nova.images.get(image.id).metadata # prints correct metadata
Comments
Post a Comment