"Fossies" - the Fresh Open Source Software Archive

Member "keystone-17.0.0/keystone/catalog/backends/base.py" (13 May 2020, 16696 Bytes) of package /linux/misc/openstack/keystone-17.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "base.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 16.0.1_vs_17.0.0.

    1 # Copyright 2012 OpenStack Foundation
    2 #
    3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
    4 # not use this file except in compliance with the License. You may obtain
    5 # a copy of the License at
    6 #
    7 #      http://www.apache.org/licenses/LICENSE-2.0
    8 #
    9 # Unless required by applicable law or agreed to in writing, software
   10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   12 # License for the specific language governing permissions and limitations
   13 # under the License.
   14 
   15 import abc
   16 
   17 from keystone.common import provider_api
   18 import keystone.conf
   19 from keystone import exception
   20 
   21 
   22 CONF = keystone.conf.CONF
   23 
   24 
   25 class CatalogDriverBase(provider_api.ProviderAPIMixin, object,
   26                         metaclass=abc.ABCMeta):
   27     """Interface description for the Catalog driver."""
   28 
   29     def _get_list_limit(self):
   30         return CONF.catalog.list_limit or CONF.list_limit
   31 
   32     def _ensure_no_circle_in_hierarchical_regions(self, region_ref):
   33         if region_ref.get('parent_region_id') is None:
   34             return
   35 
   36         root_region_id = region_ref['id']
   37         parent_region_id = region_ref['parent_region_id']
   38 
   39         while parent_region_id:
   40             # NOTE(wanghong): check before getting parent region can ensure no
   41             # self circle
   42             if parent_region_id == root_region_id:
   43                 raise exception.CircularRegionHierarchyError(
   44                     parent_region_id=parent_region_id)
   45             parent_region = self.get_region(parent_region_id)
   46             parent_region_id = parent_region.get('parent_region_id')
   47 
   48     @abc.abstractmethod
   49     def create_region(self, region_ref):
   50         """Create a new region.
   51 
   52         :raises keystone.exception.Conflict: If the region already exists.
   53         :raises keystone.exception.RegionNotFound: If the parent region
   54             is invalid.
   55 
   56         """
   57         raise exception.NotImplemented()  # pragma: no cover
   58 
   59     @abc.abstractmethod
   60     def list_regions(self, hints):
   61         """List all regions.
   62 
   63         :param hints: contains the list of filters yet to be satisfied.
   64                       Any filters satisfied here will be removed so that
   65                       the caller will know if any filters remain.
   66 
   67         :returns: list of region_refs or an empty list.
   68 
   69         """
   70         raise exception.NotImplemented()  # pragma: no cover
   71 
   72     @abc.abstractmethod
   73     def get_region(self, region_id):
   74         """Get region by id.
   75 
   76         :returns: region_ref dict
   77         :raises keystone.exception.RegionNotFound: If the region doesn't exist.
   78 
   79         """
   80         raise exception.NotImplemented()  # pragma: no cover
   81 
   82     @abc.abstractmethod
   83     def update_region(self, region_id, region_ref):
   84         """Update region by id.
   85 
   86         :returns: region_ref dict
   87         :raises keystone.exception.RegionNotFound: If the region doesn't exist.
   88 
   89         """
   90         raise exception.NotImplemented()  # pragma: no cover
   91 
   92     @abc.abstractmethod
   93     def delete_region(self, region_id):
   94         """Delete an existing region.
   95 
   96         :raises keystone.exception.RegionNotFound: If the region doesn't exist.
   97 
   98         """
   99         raise exception.NotImplemented()  # pragma: no cover
  100 
  101     @abc.abstractmethod
  102     def create_service(self, service_id, service_ref):
  103         """Create a new service.
  104 
  105         :raises keystone.exception.Conflict: If a duplicate service exists.
  106 
  107         """
  108         raise exception.NotImplemented()  # pragma: no cover
  109 
  110     @abc.abstractmethod
  111     def list_services(self, hints):
  112         """List all services.
  113 
  114         :param hints: contains the list of filters yet to be satisfied.
  115                       Any filters satisfied here will be removed so that
  116                       the caller will know if any filters remain.
  117 
  118         :returns: list of service_refs or an empty list.
  119 
  120         """
  121         raise exception.NotImplemented()  # pragma: no cover
  122 
  123     @abc.abstractmethod
  124     def get_service(self, service_id):
  125         """Get service by id.
  126 
  127         :returns: service_ref dict
  128         :raises keystone.exception.ServiceNotFound: If the service doesn't
  129             exist.
  130 
  131         """
  132         raise exception.NotImplemented()  # pragma: no cover
  133 
  134     @abc.abstractmethod
  135     def update_service(self, service_id, service_ref):
  136         """Update service by id.
  137 
  138         :returns: service_ref dict
  139         :raises keystone.exception.ServiceNotFound: If the service doesn't
  140             exist.
  141 
  142         """
  143         raise exception.NotImplemented()  # pragma: no cover
  144 
  145     @abc.abstractmethod
  146     def delete_service(self, service_id):
  147         """Delete an existing service.
  148 
  149         :raises keystone.exception.ServiceNotFound: If the service doesn't
  150             exist.
  151 
  152         """
  153         raise exception.NotImplemented()  # pragma: no cover
  154 
  155     @abc.abstractmethod
  156     def create_endpoint(self, endpoint_id, endpoint_ref):
  157         """Create a new endpoint for a service.
  158 
  159         :raises keystone.exception.Conflict: If a duplicate endpoint exists.
  160         :raises keystone.exception.ServiceNotFound: If the service doesn't
  161             exist.
  162 
  163         """
  164         raise exception.NotImplemented()  # pragma: no cover
  165 
  166     @abc.abstractmethod
  167     def get_endpoint(self, endpoint_id):
  168         """Get endpoint by id.
  169 
  170         :returns: endpoint_ref dict
  171         :raises keystone.exception.EndpointNotFound: If the endpoint doesn't
  172             exist.
  173 
  174         """
  175         raise exception.NotImplemented()  # pragma: no cover
  176 
  177     @abc.abstractmethod
  178     def list_endpoints(self, hints):
  179         """List all endpoints.
  180 
  181         :param hints: contains the list of filters yet to be satisfied.
  182                       Any filters satisfied here will be removed so that
  183                       the caller will know if any filters remain.
  184 
  185         :returns: list of endpoint_refs or an empty list.
  186 
  187         """
  188         raise exception.NotImplemented()  # pragma: no cover
  189 
  190     @abc.abstractmethod
  191     def update_endpoint(self, endpoint_id, endpoint_ref):
  192         """Get endpoint by id.
  193 
  194         :returns: endpoint_ref dict
  195         :raises keystone.exception.EndpointNotFound: If the endpoint doesn't
  196             exist.
  197         :raises keystone.exception.ServiceNotFound: If the service doesn't
  198             exist.
  199 
  200         """
  201         raise exception.NotImplemented()  # pragma: no cover
  202 
  203     @abc.abstractmethod
  204     def delete_endpoint(self, endpoint_id):
  205         """Delete an endpoint for a service.
  206 
  207         :raises keystone.exception.EndpointNotFound: If the endpoint doesn't
  208             exist.
  209 
  210         """
  211         raise exception.NotImplemented()  # pragma: no cover
  212 
  213     @abc.abstractmethod
  214     def get_catalog(self, user_id, project_id):
  215         """Retrieve and format the current service catalog.
  216 
  217         Example::
  218 
  219             { 'RegionOne':
  220                 {'compute': {
  221                     'adminURL': u'http://host:8774/v1.1/project_id',
  222                     'internalURL': u'http://host:8774/v1.1/project_id',
  223                     'name': 'Compute Service',
  224                     'publicURL': u'http://host:8774/v1.1/project_id'},
  225                  'ec2': {
  226                     'adminURL': 'http://host:8773/services/Admin',
  227                     'internalURL': 'http://host:8773/services/Cloud',
  228                     'name': 'EC2 Service',
  229                     'publicURL': 'http://host:8773/services/Cloud'}}
  230 
  231         :returns: A nested dict representing the service catalog or an
  232                   empty dict.
  233         :raises keystone.exception.NotFound: If the endpoint doesn't exist.
  234 
  235         """
  236         raise exception.NotImplemented()  # pragma: no cover
  237 
  238     def get_v3_catalog(self, user_id, project_id):
  239         """Retrieve and format the current V3 service catalog.
  240 
  241         Example::
  242 
  243             [
  244                 {
  245                     "endpoints": [
  246                     {
  247                         "interface": "public",
  248                         "id": "--endpoint-id--",
  249                         "region": "RegionOne",
  250                         "url": "http://external:8776/v1/--project-id--"
  251                     },
  252                     {
  253                         "interface": "internal",
  254                         "id": "--endpoint-id--",
  255                         "region": "RegionOne",
  256                         "url": "http://internal:8776/v1/--project-id--"
  257                     }],
  258                 "id": "--service-id--",
  259                 "type": "volume"
  260             }]
  261 
  262         :returns: A list representing the service catalog or an empty list
  263         :raises keystone.exception.NotFound: If the endpoint doesn't exist.
  264 
  265         """
  266         raise exception.NotImplemented()  # pragma: no cover
  267 
  268     @abc.abstractmethod
  269     def add_endpoint_to_project(self, endpoint_id, project_id):
  270         """Create an endpoint to project association.
  271 
  272         :param endpoint_id: identity of endpoint to associate
  273         :type endpoint_id: string
  274         :param project_id: identity of the project to be associated with
  275         :type project_id: string
  276         :raises: keystone.exception.Conflict: If the endpoint was already
  277             added to project.
  278         :returns: None.
  279 
  280         """
  281         raise exception.NotImplemented()  # pragma: no cover
  282 
  283     @abc.abstractmethod
  284     def remove_endpoint_from_project(self, endpoint_id, project_id):
  285         """Remove an endpoint to project association.
  286 
  287         :param endpoint_id: identity of endpoint to remove
  288         :type endpoint_id: string
  289         :param project_id: identity of the project associated with
  290         :type project_id: string
  291         :raises keystone.exception.NotFound: If the endpoint was not found
  292             in the project.
  293         :returns: None.
  294 
  295         """
  296         raise exception.NotImplemented()  # pragma: no cover
  297 
  298     @abc.abstractmethod
  299     def check_endpoint_in_project(self, endpoint_id, project_id):
  300         """Check if an endpoint is associated with a project.
  301 
  302         :param endpoint_id: identity of endpoint to check
  303         :type endpoint_id: string
  304         :param project_id: identity of the project associated with
  305         :type project_id: string
  306         :raises keystone.exception.NotFound: If the endpoint was not found
  307             in the project.
  308         :returns: None.
  309 
  310         """
  311         raise exception.NotImplemented()  # pragma: no cover
  312 
  313     @abc.abstractmethod
  314     def list_endpoints_for_project(self, project_id):
  315         """List all endpoints associated with a project.
  316 
  317         :param project_id: identity of the project to check
  318         :type project_id: string
  319         :returns: a list of identity endpoint ids or an empty list.
  320 
  321         """
  322         raise exception.NotImplemented()  # pragma: no cover
  323 
  324     @abc.abstractmethod
  325     def list_projects_for_endpoint(self, endpoint_id):
  326         """List all projects associated with an endpoint.
  327 
  328         :param endpoint_id: identity of endpoint to check
  329         :type endpoint_id: string
  330         :returns: a list of projects or an empty list.
  331 
  332         """
  333         raise exception.NotImplemented()  # pragma: no cover
  334 
  335     @abc.abstractmethod
  336     def delete_association_by_endpoint(self, endpoint_id):
  337         """Remove all the endpoints to project association with endpoint.
  338 
  339         :param endpoint_id: identity of endpoint to check
  340         :type endpoint_id: string
  341         :returns: None
  342 
  343         """
  344         raise exception.NotImplemented()
  345 
  346     @abc.abstractmethod
  347     def delete_association_by_project(self, project_id):
  348         """Remove all the endpoints to project association with project.
  349 
  350         :param project_id: identity of the project to check
  351         :type project_id: string
  352         :returns: None
  353 
  354         """
  355         raise exception.NotImplemented()
  356 
  357     @abc.abstractmethod
  358     def create_endpoint_group(self, endpoint_group):
  359         """Create an endpoint group.
  360 
  361         :param endpoint_group: endpoint group to create
  362         :type endpoint_group: dictionary
  363         :raises: keystone.exception.Conflict: If a duplicate endpoint group
  364             already exists.
  365         :returns: an endpoint group representation.
  366 
  367         """
  368         raise exception.NotImplemented()  # pragma: no cover
  369 
  370     @abc.abstractmethod
  371     def get_endpoint_group(self, endpoint_group_id):
  372         """Get an endpoint group.
  373 
  374         :param endpoint_group_id: identity of endpoint group to retrieve
  375         :type endpoint_group_id: string
  376         :raises keystone.exception.NotFound: If the endpoint group was not
  377             found.
  378         :returns: an endpoint group representation.
  379 
  380         """
  381         raise exception.NotImplemented()  # pragma: no cover
  382 
  383     @abc.abstractmethod
  384     def update_endpoint_group(self, endpoint_group_id, endpoint_group):
  385         """Update an endpoint group.
  386 
  387         :param endpoint_group_id: identity of endpoint group to retrieve
  388         :type endpoint_group_id: string
  389         :param endpoint_group: A full or partial endpoint_group
  390         :type endpoint_group: dictionary
  391         :raises keystone.exception.NotFound: If the endpoint group was not
  392             found.
  393         :returns: an endpoint group representation.
  394 
  395         """
  396         raise exception.NotImplemented()  # pragma: no cover
  397 
  398     @abc.abstractmethod
  399     def delete_endpoint_group(self, endpoint_group_id):
  400         """Delete an endpoint group.
  401 
  402         :param endpoint_group_id: identity of endpoint group to delete
  403         :type endpoint_group_id: string
  404         :raises keystone.exception.NotFound: If the endpoint group was not
  405             found.
  406         :returns: None.
  407 
  408         """
  409         raise exception.NotImplemented()  # pragma: no cover
  410 
  411     @abc.abstractmethod
  412     def add_endpoint_group_to_project(self, endpoint_group_id, project_id):
  413         """Add an endpoint group to project association.
  414 
  415         :param endpoint_group_id: identity of endpoint to associate
  416         :type endpoint_group_id: string
  417         :param project_id: identity of project to associate
  418         :type project_id: string
  419         :raises keystone.exception.Conflict: If the endpoint group was already
  420             added to the project.
  421         :returns: None.
  422 
  423         """
  424         raise exception.NotImplemented()  # pragma: no cover
  425 
  426     @abc.abstractmethod
  427     def get_endpoint_group_in_project(self, endpoint_group_id, project_id):
  428         """Get endpoint group to project association.
  429 
  430         :param endpoint_group_id: identity of endpoint group to retrieve
  431         :type endpoint_group_id: string
  432         :param project_id: identity of project to associate
  433         :type project_id: string
  434         :raises keystone.exception.NotFound: If the endpoint group to the
  435             project association was not found.
  436         :returns: a project endpoint group representation.
  437 
  438         """
  439         raise exception.NotImplemented()  # pragma: no cover
  440 
  441     @abc.abstractmethod
  442     def list_endpoint_groups(self, hints):
  443         """List all endpoint groups.
  444 
  445         :returns: None.
  446 
  447         """
  448         raise exception.NotImplemented()  # pragma: no cover
  449 
  450     @abc.abstractmethod
  451     def list_endpoint_groups_for_project(self, project_id):
  452         """List all endpoint group to project associations for a project.
  453 
  454         :param project_id: identity of project to associate
  455         :type project_id: string
  456         :returns: None.
  457 
  458         """
  459         raise exception.NotImplemented()  # pragma: no cover
  460 
  461     @abc.abstractmethod
  462     def list_projects_associated_with_endpoint_group(self, endpoint_group_id):
  463         """List all projects associated with endpoint group.
  464 
  465         :param endpoint_group_id: identity of endpoint to associate
  466         :type endpoint_group_id: string
  467         :returns: None.
  468 
  469         """
  470         raise exception.NotImplemented()  # pragma: no cover
  471 
  472     @abc.abstractmethod
  473     def remove_endpoint_group_from_project(self, endpoint_group_id,
  474                                            project_id):
  475         """Remove an endpoint to project association.
  476 
  477         :param endpoint_group_id: identity of endpoint to associate
  478         :type endpoint_group_id: string
  479         :param project_id: identity of project to associate
  480         :type project_id: string
  481         :raises keystone.exception.NotFound: If endpoint group project
  482             association was not found.
  483         :returns: None.
  484 
  485         """
  486         raise exception.NotImplemented()  # pragma: no cover
  487 
  488     @abc.abstractmethod
  489     def delete_endpoint_group_association_by_project(self, project_id):
  490         """Remove endpoint group to project associations.
  491 
  492         :param project_id: identity of the project to check
  493         :type project_id: string
  494         :returns: None
  495 
  496         """
  497         raise exception.NotImplemented()  # pragma: no cover