<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">On 18/10/16 03:36, Dean Troyer wrote:<br>
</div>
<blockquote
cite="mid:CAOJFoEuWmJeOL0y_zG3=AnT9w=NLNET3LGfiuWi3C+oaha9ypQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Sun, Oct 16, 2016 at 9:11 PM,
Adrian Turjak <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:adriant@catalyst.net.nz" target="_blank">adriant@catalyst.net.nz</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">The problem I'm running
into is for some of our custom plugins we<br>
require the commands to run in all regions. We do this by
getting the<br>
region list from keystone, and then doing the command in
each region.<br>
</blockquote>
<div>... </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
Is there a way to explicitly reinitialise the
client_manager?<br>
'client_mananger.reinitialise(<wbr>)' or something as
easy? Maybe even a<br>
clear cache command?<br>
</blockquote>
<div><br>
</div>
<div>There is not a way to re-init the ClientManager, and
really, you don't want to do that, but you do want a new
compute client for each region. OSC sets up the
ClientManager client attributes with descriptors in
common/clientmanager.py get_plugin_modules(). At this
point we do not have any region information, so to do that
you would have to do it later, but it is simple enough to
return whatever you want from your plugin's
make_client(). Normally that will be a client object for
the desired API, for your plugin it could be a dict of
client objects keyed off region_name. Then your consuming
code would need to deref those with:</div>
<div><br>
</div>
<div><span style="font-size:12.8px"> for region in regions:</span><br
style="font-size:12.8px">
<span style="font-size:12.8px"> nova_client =
self.app.client_manager.</span><wbr
style="font-size:12.8px"><span style="font-size:12.8px">compute[region]</span><br
style="font-size:12.8px">
<span style="font-size:12.8px">
do_something(nova_client)</span><br
style="font-size:12.8px">
</div>
<div> </div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
While explicitly initialising clients isn't exactly
difficult, it is<br>
something that would make more sense to simply work in the
base<br>
openstackclient code as multi-region commands can and will
be useful for<br>
a lot of people.<br>
</blockquote>
<div><br>
</div>
<div>Generalizing this to all of the existing plugins would
be an enormous change, but doable. We would need to think
hard about how many of these things we need to handle, not
just region, but cell or whatever else may be out there
that a command would want to iterate on.</div>
</div>
</div>
</div>
</blockquote>
I don't think it is worth doing such a change exactly because it
would be a huge amount of work. Thats why I was hoping to have the
value returned be partly keyed off 'client_manager.region_name'. The
clients do get built off that value already, and I've tested
altering that value before the first client is built and even if my
authed region was RegionOne, if I manually set it to RegionTwo, the
client will be built for region two. The problem is that once
cached, the client will always be RegionTwo.<br>
<br>
What I'm wondering is can the current client cache be changed to be
keyed off the client_manager.region_name? That way the change is
only in how the clients are built and the code elsewhere doesn't
change unless it actually does something by manually changing
region_name. This would then be a change that would go unnoticed
outside of the clientmanger and simply add a new feature.<br>
<br>
Actually, I got distracted while writing this email and wrote a
patch:<br>
<a class="moz-txt-link-freetext" href="https://review.openstack.org/#/c/387696">https://review.openstack.org/#/c/387696</a><br>
<br>
Using the test command in my first email, this works. It should
simply work with all existing cases, but the test suite should
confirm that first of course.<br>
<br>
With that change anyone can easily work exactly as before
(region_name will be set to your default region), and new features
that are multi-region can be introduced without any pain provided
they know to update client_manager.region_name.<br>
<br>
<br>
<blockquote
cite="mid:CAOJFoEuWmJeOL0y_zG3=AnT9w=NLNET3LGfiuWi3C+oaha9ypQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<div> Note that we currently can not reliably hook existing
commands to extend them, for example to support a 'server
create' that uses --ram, --vcpu and --disk in place of
--flavor. That will be discussed next week in BCN.</div>
</div>
</div>
</div>
</blockquote>
I have been following this a little and it does sound interesting.
Am curious what solution is found for this. Can plugins overwrite
existing commands? That way if someone wanted a server create with
their own features they just make a plugin that replaces the
standard command. While a bit of a blunt solution, it does seem like
the simplest, although people need to be aware when installing
plugins that they can replace/overwrite default commands and be
careful to install only trusted plugins.<br>
<br>
</body>
</html>