Support Proxy-specific region_name

Proxy (a subclass of keystoneauth1 Adapter) is set up to know about
region_name. This is done so that consumers of cloud_region.from_conf
will have their [$project]region_name setting honored rather than
ignored.

Previously, CloudRegion was set up to deal with a single region, masking
(or rather overriding) each Proxy's notion of what its region_name
should be.

With this change, (service-specific) region_nameZ are honored by the
CloudRegion constructor, as follows:

- A service-specific region_name in the ``config`` dict (e.g.
  'compute_region_name': 'SnowflakeComputeRegion') takes first
  precedence for that service.
- If no service-specific region_name is present in the ``config`` dict,
  the value of the region_name kwarg to the CloudRegion constructor is
  used. (This kwarg should really go away, but is preserved for backward
  compatibility.)
- If neither of the above is given, the value of the (unprefixed)
  'region_name' key in the ``config`` dict is used. (This should really
  take precedence over the kwarg, but it's done this way for backward
  compatibility.)
- If none of the above exist, None is used (the previous behavior,
  whatever that may mean).

This change should hopefully be transparent to any existing usages of
the CloudRegion constructor, as ${service}_region_name would have been
ignored if present. However, if any existing usages had such a config
setting present, it will no longer be ignored, resulting in potential
RBB [1].

[1] That's "Revoked Bug Benefit"

Change-Id: Ie253823a753d09d52e45df9d515fd22870c2d4c5
This commit is contained in:
Eric Fried
2019-06-03 16:31:36 -05:00
committed by Monty Taylor
parent 86ad9debd1
commit 5f0401a206
10 changed files with 132 additions and 45 deletions

View File

@@ -340,7 +340,9 @@ def _get_interface_ip(cloud, server):
def get_groups_from_server(cloud, server, server_vars):
groups = []
region = cloud.config.region_name
# NOTE(efried): This is hardcoded to 'compute' because this method is only
# used from ComputeCloudMixin.
region = cloud.config.get_region_name('compute')
cloud_name = cloud.name
# Create a group for the cloud