Merge "Specify region by name."
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 534f3d9..f9fc1d5 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -22,6 +22,8 @@
# Should typically be left as keystone unless you have a non-Keystone
# authentication API service
strategy = keystone
+# The identity region
+region = RegionOne
[compute]
# This section contains configuration options used when executing tests
@@ -54,6 +56,9 @@
# The above non-administrative user's tenant name
alt_tenant_name = alt_demo
+# The compute region
+region = RegionOne
+
# Reference data for tests. The ref and ref_alt should be
# distinct images/flavors.
image_ref = {$IMAGE_ID}
@@ -261,6 +266,10 @@
# this value as "object-store"
catalog_type = object-store
+# The object-store region
+region = RegionOne
+
+
[boto]
# This section contains configuration options used when executing tests
# with boto.
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index cb18a9c..884d147 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -44,7 +44,7 @@
self.token = None
self.base_url = None
self.config = config
- self.region = 0
+ self.region = {'compute': self.config.compute.region}
self.endpoint_url = 'publicURL'
self.strategy = self.config.identity.strategy
self.headers = {'Content-Type': 'application/%s' % self.TYPE,
@@ -142,7 +142,12 @@
mgmt_url = None
for ep in auth_data['serviceCatalog']:
if ep["type"] == service:
- mgmt_url = ep['endpoints'][self.region][self.endpoint_url]
+ for _ep in ep['endpoints']:
+ if service in self.region and \
+ _ep['region'] == self.region[service]:
+ mgmt_url = _ep[self.endpoint_url]
+ if not mgmt_url:
+ mgmt_url = ep['endpoints'][0][self.endpoint_url]
tenant_id = auth_data['token']['tenant']['id']
break
diff --git a/tempest/config.py b/tempest/config.py
index 1d1aa49..fc1bd74 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -96,6 +96,11 @@
"""Which auth method does the environment use? (basic|keystone)"""
return self.get("strategy", 'keystone')
+ @property
+ def region(self):
+ """The identity region name to use."""
+ return self.get("region")
+
class IdentityAdminConfig(BaseConfig):
@@ -173,6 +178,11 @@
return self.get("alt_password")
@property
+ def region(self):
+ """The compute region name to use."""
+ return self.get("region")
+
+ @property
def image_ref(self):
"""Valid primary image to use in tests."""
return self.get("image_ref", "{$IMAGE_ID}")
@@ -473,6 +483,11 @@
"""Catalog type of the Object-Storage service."""
return self.get("catalog_type", 'object-store')
+ @property
+ def region(self):
+ """The object-store region name to use."""
+ return self.get("region")
+
class BotoConfig(BaseConfig):
"""Provides configuration information for connecting to EC2/S3."""