def get_catalog(self, user_id, tenant_id, metadata=None): substitutions = dict(six.iteritems(CONF)) substitutions.update({'tenant_id': tenant_id, 'user_id': user_id}) session = sql.get_session() t = True # variable for singleton for PEP8, E712. endpoints = (session.query(Endpoint).options( sql.joinedload( Endpoint.service)).filter(Endpoint.enabled == t).all()) catalog = {} for endpoint in endpoints: if not endpoint.service['enabled']: continue try: url = core.format_url(endpoint['url'], substitutions) except exception.MalformedEndpoint: continue # this failure is already logged in format_url() region = endpoint['region'] service_type = endpoint.service['type'] default_service = { 'id': endpoint['id'], 'name': endpoint.service['name'], 'publicURL': '' } catalog.setdefault(region, {}) catalog[region].setdefault(service_type, default_service) interface_url = '%sURL' % endpoint['interface'] catalog[region][service_type][interface_url] = url return catalog
def get_catalog(self, user_id, tenant_id, metadata=None): d = dict(six.iteritems(CONF)) d.update({'tenant_id': tenant_id, 'user_id': user_id}) session = sql.get_session() t = True # variable for singleton for PEP8, E712. endpoints = (session.query(Endpoint). options(sql.joinedload(Endpoint.service)). filter(Endpoint.enabled == t).all()) catalog = {} for endpoint in endpoints: if not endpoint.service['enabled']: continue region = endpoint['region'] service_type = endpoint.service['type'] default_service = { 'id': endpoint['id'], 'name': endpoint.service['name'], 'publicURL': '' } catalog.setdefault(region, {}) catalog[region].setdefault(service_type, default_service) url = core.format_url(endpoint['url'], d) interface_url = '%sURL' % endpoint['interface'] catalog[region][service_type][interface_url] = url return catalog
def get_catalog(self, user_id, tenant_id, metadata=None): substitutions = dict(six.iteritems(CONF)) substitutions.update({"tenant_id": tenant_id, "user_id": user_id}) session = sql.get_session() t = True # variable for singleton for PEP8, E712. endpoints = ( session.query(Endpoint).options(sql.joinedload(Endpoint.service)).filter(Endpoint.enabled == t).all() ) catalog = {} for endpoint in endpoints: if not endpoint.service["enabled"]: continue try: url = core.format_url(endpoint["url"], substitutions) except exception.MalformedEndpoint: continue # this failure is already logged in format_url() region = endpoint["region"] service_type = endpoint.service["type"] default_service = {"id": endpoint["id"], "name": endpoint.service["name"], "publicURL": ""} catalog.setdefault(region, {}) catalog[region].setdefault(service_type, default_service) interface_url = "%sURL" % endpoint["interface"] catalog[region][service_type][interface_url] = url return catalog
def get_catalog(self, user_id, tenant_id, metadata=None): d = dict(six.iteritems(CONF)) d.update({'tenant_id': tenant_id, 'user_id': user_id}) session = db_session.get_session() endpoints = (session.query(Endpoint).options( sql.joinedload(Endpoint.service)).all()) catalog = {} for endpoint in endpoints: region = endpoint['region'] service_type = endpoint.service['type'] default_service = { 'id': endpoint['id'], 'name': endpoint.service['name'], 'publicURL': '' } catalog.setdefault(region, {}) catalog[region].setdefault(service_type, default_service) url = core.format_url(endpoint['url'], d) interface_url = '%sURL' % endpoint['interface'] catalog[region][service_type][interface_url] = url return catalog
def get_catalog(self, user_id, tenant_id, metadata=None): d = dict(CONF.iteritems()) d.update({'tenant_id': tenant_id, 'user_id': user_id}) catalog = {} services = {} for endpoint in self.list_endpoints(): # look up the service services.setdefault( endpoint['service_id'], self.get_service(endpoint['service_id'])) service = services[endpoint['service_id']] # add the endpoint to the catalog if it's not already there catalog.setdefault(endpoint['region'], {}) catalog[endpoint['region']].setdefault( service['type'], { 'id': endpoint['id'], 'name': service['name'], 'publicURL': '', # this may be overridden, but must exist }) # add the interface's url url = core.format_url(endpoint.get('url'), d) interface_url = '%sURL' % endpoint['interface'] catalog[endpoint['region']][service['type']][interface_url] = url return catalog
def get_catalog(self, user_id, tenant_id, metadata=None): d = dict(CONF.iteritems()) d.update({'tenant_id': tenant_id, 'user_id': user_id}) session = self.get_session() endpoints = (session.query(Endpoint). options(sql.joinedload(Endpoint.service)). all()) catalog = {} for endpoint in endpoints: region = endpoint['region'] service_type = endpoint.service['type'] default_service = { 'id': endpoint['id'], 'name': endpoint.service['name'], 'publicURL': '' } catalog.setdefault(region, {}) catalog[region].setdefault(service_type, default_service) url = core.format_url(endpoint['url'], d) interface_url = '%sURL' % endpoint['interface'] catalog[region][service_type][interface_url] = url return catalog
def get_catalog(self, user_id, tenant_id, metadata=None): substitutions = dict(six.iteritems(CONF)) substitutions.update({'tenant_id': tenant_id, 'user_id': user_id}) session = sql.get_session() endpoints = (session.query(Endpoint). options(sql.joinedload(Endpoint.service)). filter(Endpoint.enabled == true()).all()) catalog = {} for endpoint in endpoints: if not endpoint.service['enabled']: continue try: url = core.format_url(endpoint['url'], substitutions) except exception.MalformedEndpoint: continue # this failure is already logged in format_url() region = endpoint['region_id'] service_type = endpoint.service['type'] default_service = { 'id': endpoint['id'], 'name': endpoint.service.extra.get('name', ''), 'publicURL': '' } catalog.setdefault(region, {}) catalog[region].setdefault(service_type, default_service) interface_url = '%sURL' % endpoint['interface'] catalog[region][service_type][interface_url] = url return catalog
def get_catalog(self, user_id, tenant_id, metadata=None): d = dict(CONF.iteritems()) d.update({'tenant_id': tenant_id, 'user_id': user_id}) catalog = {} services = {} for endpoint in self.list_endpoints(): # look up the service services.setdefault(endpoint['service_id'], self.get_service(endpoint['service_id'])) service = services[endpoint['service_id']] # add the endpoint to the catalog if it's not already there catalog.setdefault(endpoint['region'], {}) catalog[endpoint['region']].setdefault( service['type'], { 'id': endpoint['id'], 'name': service['name'], 'publicURL': '', # this may be overridden, but must exist }) # add the interface's url url = core.format_url(endpoint.get('url'), d) interface_url = '%sURL' % endpoint['interface'] catalog[endpoint['region']][service['type']][interface_url] = url return catalog
def get_catalog(self, user_id, tenant_id): """Retrieve and format the V2 service catalog. :param user_id: The id of the user who has been authenticated for creating service catalog. :param tenant_id: The id of the project. 'tenant_id' will be None in the case this being called to create a catalog to go in a domain scoped token. In this case, any endpoint that requires a tenant_id as part of their URL will be skipped (as would a whole service if, as a consequence, it has no valid endpoints). :returns: A nested dict representing the service catalog or an empty dict. """ substitutions = dict( itertools.chain(six.iteritems(CONF), six.iteritems(CONF.eventlet_server))) substitutions.update({'user_id': user_id}) silent_keyerror_failures = [] if tenant_id: substitutions.update({'tenant_id': tenant_id}) else: silent_keyerror_failures = ['tenant_id'] session = sql.get_session() endpoints = (session.query(Endpoint). options(sql.joinedload(Endpoint.service)). filter(Endpoint.enabled == true()).all()) catalog = {} for endpoint in endpoints: if not endpoint.service['enabled']: continue try: formatted_url = core.format_url( endpoint['url'], substitutions, silent_keyerror_failures=silent_keyerror_failures) if formatted_url is not None: url = formatted_url else: continue except exception.MalformedEndpoint: continue # this failure is already logged in format_url() region = endpoint['region_id'] service_type = endpoint.service['type'] default_service = { 'id': endpoint['id'], 'name': endpoint.service.extra.get('name', ''), 'publicURL': '' } catalog.setdefault(region, {}) catalog[region].setdefault(service_type, default_service) interface_url = '%sURL' % endpoint['interface'] catalog[region][service_type][interface_url] = url return catalog
def get_catalog(self, user_id, tenant_id): """Retrieve and format the V2 service catalog. :param user_id: The id of the user who has been authenticated for creating service catalog. :param tenant_id: The id of the project. 'tenant_id' will be None in the case this being called to create a catalog to go in a domain scoped token. In this case, any endpoint that requires a tenant_id as part of their URL will be skipped (as would a whole service if, as a consequence, it has no valid endpoints). :returns: A nested dict representing the service catalog or an empty dict. """ substitutions = dict( itertools.chain(CONF.items(), CONF.eventlet_server.items())) substitutions.update({'user_id': user_id}) silent_keyerror_failures = [] if tenant_id: substitutions.update({'tenant_id': tenant_id}) else: silent_keyerror_failures = ['tenant_id'] session = sql.get_session() endpoints = (session.query(Endpoint). options(sql.joinedload(Endpoint.service)). filter(Endpoint.enabled == true()).all()) catalog = {} for endpoint in endpoints: if not endpoint.service['enabled']: continue try: formatted_url = core.format_url( endpoint['url'], substitutions, silent_keyerror_failures=silent_keyerror_failures) if formatted_url is not None: url = formatted_url else: continue except exception.MalformedEndpoint: continue # this failure is already logged in format_url() region = endpoint['region_id'] service_type = endpoint.service['type'] default_service = { 'id': endpoint['id'], 'name': endpoint.service.extra.get('name', ''), 'publicURL': '' } catalog.setdefault(region, {}) catalog[region].setdefault(service_type, default_service) interface_url = '%sURL' % endpoint['interface'] catalog[region][service_type][interface_url] = url return catalog