def getRegions(self, username, api_key, project_id, auth_url): """Get a list of available regions, given a keystone endpoint and credentials.""" client = APIClient( username=username, password=api_key, project_id=project_id, auth_url=auth_url, ) serviceCatalog = yield client.serviceCatalog() ep = [] [ep.extend(x['endpoints']) for x in serviceCatalog] regions = set([x['region'] for x in ep]) returnValue([{'key': c, 'label': c} for c in sorted(regions)])
def getCeilometerUrl(self, username, api_key, project_id, auth_url, region_name): """Return the first defined ceilometer URL, given a keystone endpoint, credentials, and a region. May return an empty string if none is found.""" client = APIClient( username=username, password=api_key, project_id=project_id, auth_url=auth_url, ) serviceCatalog = yield client.serviceCatalog() for sc in serviceCatalog: if sc['type'] == 'metering': for endpoint in sc['endpoints']: if endpoint['region'] == region_name: returnValue(str(endpoint['publicURL'])) return # never found one. returnValue("")