Hello OpenStack Dev,

I'm doing some work with custom plugins for openstackclient, and mostly
things are going well, but I've run into an annoying little bug/design
flaw around how per region clients are handled.

The openstackclient has a built in way for getting access to the various
openstack clients as such:
nova_client = self.app.client_manager.compute

The problem I'm running into is for some of our custom plugins we
require the commands to run in all regions. We do this by getting the
region list from keystone, and then doing the command in each region.

The expected workflow would be as such:

keystone = self.app.client_manager.identity
regions = [region.id for region in keystone.regions.list()]

for region in regions:
    self.app.client_manager.region_name = region
    nova_client = self.app.client_manager.compute

This will work for the first region, with the region_name value being
used to initialise the client the first time, but once a nova client is
created, that client is cached and isn't cached per region. When the
region_name is changed the client cache should be re-intialised or it
should cache per region per service rather than just per service.

Is there a way to explicitly reinitialise the client_manager?
'client_mananger.reinitialise()' or something as easy? Maybe even a
clear cache command?

Here is a very basic example command I've made to show exactly why this
doesn't work:

If run in a deployment with more than one region, you will see that the
inbuilt client will list the same instances in all regions while the
explicitly created one will correctly list instances per region.

While explicitly initialising clients isn't exactly difficult, it is
something that would make more sense to simply work in the base
openstackclient code as multi-region commands can and will be useful for
a lot of people.

Not to mention adding multi-region support to some commands so you don't
have to change OS_REGION_NAME or your region in clouds.yaml could be
very useful. A command to list your instances across all regions could
be quite useful and easy to do.

Any thoughts? Suggestions?

Adrian Turjak

OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe

Reply via email to