To create a client:
from keystoneauth1 import loading
from keystoneauth1 import session
from glanceclient import Client
loader = loading.get_plugin_loader('password')
auth = loader.load_from_options(
auth_url=AUTH_URL,
username=USERNAME,
password=PASSWORD,
project_id=PROJECT_ID)
session = session.Session(auth=auth)
glance = Client('2', session=session)
Create a new image:
image = glance.images.create(name="myNewImage")
glance.images.upload(image.id, open('/tmp/myimage.iso', 'rb'))
Update a specific image:
# update with a list of image attribute names and their new values
glance.images.update(image.id, name="myNewImageName")
Set a custom property on an image:
# set an arbitrary property on an image
glance.images.update(image.id, my_custom_property='value')
Remove a custom property from an image:
# remove the custom property 'my_custom_property'
glance.images.update(image.id, remove_props=['my_custom_property'])
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.