OpenStack Cinder API version

130 Views Asked by At

We are using Java library openstack4j version 3.6 to interact with OpenStack

The OpenStack lab supports both Cinder v2 and v3 endpoints (some parts removed here).

~$ openstack endpoint list | grep cinder | 0bff444d3bcf4179bea245d9c7af319c | RegionOne | cinder | volume | True | public | http://x.x.x.x:8776/v1/%(tenant_id)s | | 14079c14970f4e21b37ba659e6054ecf | RegionOne | cinderv2 | volumev2 | True | admin | http://x.x.x.x:8776/v2/%(tenant_id)s | | 1a2d43fde400446eaca463b6b408a513 | RegionOne | cinderv3 | volumev3 | True | internal | http://y.y.y.y:8776/v3/%(project_id)s |

From openstack4j, we are using Identity API v3 for authentication and then trying to do cinder operations. All cinder operations are done via Cinder API v2. Any idea on how to force openstack4j to use v3 for Cinder APIs?

Expecting openstack4j to use Cinder v3 if it is available in OpenStack

1

There are 1 best solutions below

0
Stephen C On

I don't use openstack4j, so this answer is based on reading examples and the javadocs.

There is an interface called ServiceVersionResolver (javadoc) which has methods for "resolving" a specific service version from a set provided by the Keystone service catalog. There are standard resolver implementations called LatestServiceVersionResolver and StableServiceVersionResolver that implement policies as per their names. If these policies don't do what you want, you can write a custom resolver to implement your own resolution policy; e.g. to use Cinder V3 if it is available.

From what I can tell, a ServiceVersionResolver is configured in the Config object that you can provide when you build your application's OSClient object. Note that the resolver you configure will apply to all services that you access via the client object.

For more information, refer to the javadocs.