Merge "tempest: support keystone v3 for autoscaling"
diff --git a/ceilometer/tests/tempest/scenario/test_autoscaling.py b/ceilometer/tests/tempest/scenario/test_autoscaling.py
index f609363..3b0217b 100644
--- a/ceilometer/tests/tempest/scenario/test_autoscaling.py
+++ b/ceilometer/tests/tempest/scenario/test_autoscaling.py
@@ -92,15 +92,35 @@
def _get_endpoint_for(auth, service):
opt_section = getattr(config.CONF, service)
endpoint_type = opt_section.endpoint_type
- if not endpoint_type.endswith("URL"):
- endpoint_type += "URL"
+ is_keystone_v3 = 'catalog' in auth[1]
- endpoints = [e for e in auth[1]['serviceCatalog']
- if e['type'] == opt_section.catalog_type]
- if not endpoints:
- raise Exception("%s endpoint not found" %
- config.CONF.metric.catalog_type)
- return endpoints[0]['endpoints'][0][endpoint_type]
+ if is_keystone_v3:
+ if endpoint_type.endswith("URL"):
+ endpoint_type = endpoint_type[:-3]
+ catalog = auth[1]['catalog']
+ endpoints = [e['endpoints'] for e in catalog
+ if e['type'] == opt_section.catalog_type]
+ if not endpoints:
+ raise Exception("%s endpoint not found" %
+ config.CONF.metric.catalog_type)
+ endpoints = [e['url'] for e in endpoints[0]
+ if e['interface'] == endpoint_type]
+ if not endpoints:
+ raise Exception("%s interface not found for endpoint %s" %
+ (endpoint_type,
+ config.CONF.metric.catalog_type))
+ return endpoints[0]
+
+ else:
+ if not endpoint_type.endswith("URL"):
+ endpoint_type += "URL"
+ catalog = auth[1]['serviceCatalog']
+ endpoints = [e for e in catalog
+ if e['type'] == opt_section.catalog_type]
+ if not endpoints:
+ raise Exception("%s endpoint not found" %
+ config.CONF.metric.catalog_type)
+ return endpoints[0]['endpoints'][0][endpoint_type]
@staticmethod
def test_fake():