python-glanceclient is a client library for OpenStack Glance, the Image service, built on the Glance API. It provides a Python API for interacting with Glance and a command-line tool (`glance`). The current stable version is 4.11.0, and it follows the OpenStack release cadence, typically releasing new versions every six months to align with OpenStack's development cycle.
pip install python-glanceclientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to authenticate with OpenStack Keystone using environment variables and then initialize the Glance client to list available images. It uses API version 2, which is the default for recent Glance client versions. Make sure your OpenStack environment variables (e.g., `OS_AUTH_URL`, `OS_USERNAME`, `OS_PASSWORD`, `OS_PROJECT_NAME`) are set.
Explicitly pass the desired API version as the first argument, e.g., `glance_client.Client('1', session=sess)` for v1, or `glance_client.Client('2', session=sess)` for v2. It's recommended to upgrade to v2 where possible.Explore `openstacksdk`'s documentation for its Glance module. For existing `glanceclient` code, continue using this library, as it remains a valid and supported option.
Always construct a `keystoneauth1.session.Session` object with an appropriate `keystoneauth1.identity` plugin (e.g., `v3.Password`, `v3.Token`) and pass this session to the `glanceclient.client.Client()` constructor via the `session` keyword argument.
Install the library using pip: `pip install python-glanceclient`
Ensure 'python-glanceclient' is installed in your active Python environment and that your system's PATH includes the directory where pip installs scripts (e.g., `~/.local/bin` or your virtual environment's `bin` folder).
Verify and set the correct OpenStack environment variables, or pass the correct authentication parameters when initializing the client. For CLI, source your `openrc` file.
Ensure all required attributes are included in the dictionary passed to the `glance_client.images.create()` method. For example: `glance_client.images.create(name='my-image', disk_format='qcow2', container_format='bare')`