"Fossies" - the Fresh Open Source Software Archive

Member "neutron-14.0.3/neutron/neutron_plugin_base_v2.py" (22 Oct 2019, 17063 Bytes) of package /linux/misc/openstack/neutron-14.0.3.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 "neutron_plugin_base_v2.py" see the Fossies "Dox" file reference documentation.

    1 # Copyright 2011 VMware, Inc.
    2 # All Rights Reserved.
    3 #
    4 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    5 #    not use this file except in compliance with the License. You may obtain
    6 #    a copy of the License at
    7 #
    8 #         http://www.apache.org/licenses/LICENSE-2.0
    9 #
   10 #    Unless required by applicable law or agreed to in writing, software
   11 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   12 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   13 #    License for the specific language governing permissions and limitations
   14 #    under the License.
   15 
   16 """
   17 v2 Neutron Plug-in API specification.
   18 
   19 :class:`NeutronPluginBaseV2` provides the definition of minimum set of
   20 methods that needs to be implemented by a v2 Neutron Plug-in.
   21 """
   22 
   23 import abc
   24 
   25 from neutron_lib.services import base as base_services
   26 import six
   27 
   28 
   29 @six.add_metaclass(abc.ABCMeta)
   30 class NeutronPluginBaseV2(base_services.WorkerBase):
   31 
   32     @abc.abstractmethod
   33     def create_subnet(self, context, subnet):
   34         """Create a subnet.
   35 
   36         Create a subnet, which represents a range of IP addresses
   37         that can be allocated to devices
   38 
   39         :param context: neutron api request context
   40         :param subnet: dictionary describing the subnet, with keys
   41                        as listed in the  :obj:`RESOURCE_ATTRIBUTE_MAP` object
   42                        in :file:`neutron/api/v2/attributes.py`.  All keys will
   43                        be populated.
   44         """
   45         pass
   46 
   47     @abc.abstractmethod
   48     def update_subnet(self, context, id, subnet):
   49         """Update values of a subnet.
   50 
   51         :param context: neutron api request context
   52         :param id: UUID representing the subnet to update.
   53         :param subnet: dictionary with keys indicating fields to update.
   54                        valid keys are those that have a value of True for
   55                        'allow_put' as listed in the
   56                        :obj:`RESOURCE_ATTRIBUTE_MAP` object in
   57                        :file:`neutron/api/v2/attributes.py`.
   58         """
   59         pass
   60 
   61     @abc.abstractmethod
   62     def get_subnet(self, context, id, fields=None):
   63         """Retrieve a subnet.
   64 
   65         :param context: neutron api request context
   66         :param id: UUID representing the subnet to fetch.
   67         :param fields: a list of strings that are valid keys in a
   68                        subnet dictionary as listed in the
   69                        :obj:`RESOURCE_ATTRIBUTE_MAP` object in
   70                        :file:`neutron/api/v2/attributes.py`. Only these fields
   71                        will be returned.
   72         """
   73         pass
   74 
   75     @abc.abstractmethod
   76     def get_subnets(self, context, filters=None, fields=None,
   77                     sorts=None, limit=None, marker=None, page_reverse=False):
   78         """Retrieve a list of subnets.
   79 
   80         The contents of the list depends on
   81         the identity of the user making the request (as indicated by the
   82         context) as well as any filters.
   83 
   84         :param context: neutron api request context
   85         :param filters: a dictionary with keys that are valid keys for
   86                         a subnet as listed in the :obj:`RESOURCE_ATTRIBUTE_MAP`
   87                         object in :file:`neutron/api/v2/attributes.py`.
   88                         Values in this dictionary are an iterable containing
   89                         values that will be used for an exact match comparison
   90                         for that value.  Each result returned by this
   91                         function will have matched one of the values for each
   92                         key in filters.
   93         :param fields: a list of strings that are valid keys in a
   94                        subnet dictionary as listed in the
   95                        :obj:`RESOURCE_ATTRIBUTE_MAP` object in
   96                        :file:`neutron/api/v2/attributes.py`. Only these fields
   97                        will be returned.
   98         """
   99         pass
  100 
  101     def get_subnets_count(self, context, filters=None):
  102         """Return the number of subnets.
  103 
  104         The result depends on the identity of
  105         the user making the request (as indicated by the context) as well as
  106         any filters.
  107 
  108         :param context: neutron api request context
  109         :param filters: a dictionary with keys that are valid keys for
  110                         a network as listed in the
  111                         :obj:`RESOURCE_ATTRIBUTE_MAP` object in
  112                         :file:`neutron/api/v2/attributes.py`.  Values in this
  113                         dictionary are an iterable containing values that
  114                         will be used for an exact match comparison for that
  115                         value.  Each result returned by this function will
  116                         have matched one of the values for each key in filters.
  117 
  118         .. note:: this method is optional, as it was not part of the originally
  119                   defined plugin API.
  120         """
  121         raise NotImplementedError()
  122 
  123     @abc.abstractmethod
  124     def delete_subnet(self, context, id):
  125         """Delete a subnet.
  126 
  127         :param context: neutron api request context
  128         :param id: UUID representing the subnet to delete.
  129         """
  130         pass
  131 
  132     def create_subnetpool(self, context, subnetpool):
  133         """Create a subnet pool.
  134 
  135         :param context: neutron api request context
  136         :param subnetpool: Dictionary representing the subnetpool to create.
  137         """
  138         raise NotImplementedError()
  139 
  140     def update_subnetpool(self, context, id, subnetpool):
  141         """Update a subnet pool.
  142 
  143         :param context: neutron api request context
  144         :param subnetpool: Dictionary representing the subnetpool attributes
  145                            to update.
  146         """
  147         raise NotImplementedError()
  148 
  149     def get_subnetpool(self, context, id, fields=None):
  150         """Show a subnet pool.
  151 
  152         :param context: neutron api request context
  153         :param id: The UUID of the subnetpool to show.
  154         """
  155         raise NotImplementedError()
  156 
  157     def get_subnetpools(self, context, filters=None, fields=None,
  158                         sorts=None, limit=None, marker=None,
  159                         page_reverse=False):
  160         """Retrieve list of subnet pools."""
  161         raise NotImplementedError()
  162 
  163     def delete_subnetpool(self, context, id):
  164         """Delete a subnet pool.
  165 
  166         :param context: neutron api request context
  167         :param id: The UUID of the subnet pool to delete.
  168         """
  169         raise NotImplementedError()
  170 
  171     @abc.abstractmethod
  172     def create_network(self, context, network):
  173         """Create a network.
  174 
  175         Create a network, which represents an L2 network segment which
  176         can have a set of subnets and ports associated with it.
  177 
  178         :param context: neutron api request context
  179         :param network: dictionary describing the network, with keys
  180                         as listed in the  :obj:`RESOURCE_ATTRIBUTE_MAP` object
  181                         in :file:`neutron/api/v2/attributes.py`.  All keys will
  182                         be populated.
  183 
  184         """
  185         pass
  186 
  187     @abc.abstractmethod
  188     def update_network(self, context, id, network):
  189         """Update values of a network.
  190 
  191         :param context: neutron api request context
  192         :param id: UUID representing the network to update.
  193         :param network: dictionary with keys indicating fields to update.
  194                         valid keys are those that have a value of True for
  195                         'allow_put' as listed in the
  196                         :obj:`RESOURCE_ATTRIBUTE_MAP` object in
  197                         :file:`neutron/api/v2/attributes.py`.
  198         """
  199         pass
  200 
  201     @abc.abstractmethod
  202     def get_network(self, context, id, fields=None):
  203         """Retrieve a network.
  204 
  205         :param context: neutron api request context
  206         :param id: UUID representing the network to fetch.
  207         :param fields: a list of strings that are valid keys in a
  208                        network dictionary as listed in the
  209                        :obj:`RESOURCE_ATTRIBUTE_MAP` object in
  210                        :file:`neutron/api/v2/attributes.py`. Only these fields
  211                        will be returned.
  212         """
  213         pass
  214 
  215     @abc.abstractmethod
  216     def get_networks(self, context, filters=None, fields=None,
  217                      sorts=None, limit=None, marker=None, page_reverse=False):
  218         """Retrieve a list of networks.
  219 
  220         The contents of the list depends on
  221         the identity of the user making the request (as indicated by the
  222         context) as well as any filters.
  223 
  224         :param context: neutron api request context
  225         :param filters: a dictionary with keys that are valid keys for
  226                         a network as listed in the
  227                         :obj:`RESOURCE_ATTRIBUTE_MAP` object in
  228                         :file:`neutron/api/v2/attributes.py`.  Values in this
  229                         dictionary are an iterable containing values that will
  230                         be used for an exact match comparison for that value.
  231                         Each result returned by this function will have matched
  232                         one of the values for each key in filters.
  233         :param fields: a list of strings that are valid keys in a
  234                        network dictionary as listed in the
  235                        :obj:`RESOURCE_ATTRIBUTE_MAP` object in
  236                        :file:`neutron/api/v2/attributes.py`. Only these fields
  237                        will be returned.
  238         """
  239         pass
  240 
  241     def get_networks_count(self, context, filters=None):
  242         """Return the number of networks.
  243 
  244         The result depends on the identity
  245         of the user making the request (as indicated by the context) as well
  246         as any filters.
  247 
  248         :param context: neutron api request context
  249         :param filters: a dictionary with keys that are valid keys for
  250                         a network as listed in the
  251                         :obj:`RESOURCE_ATTRIBUTE_MAP` object
  252                         in :file:`neutron/api/v2/attributes.py`. Values in
  253                         this dictionary are an iterable containing values that
  254                         will be used for an exact match comparison for that
  255                         value.  Each result returned by this function will have
  256                         matched one of the values for each key in filters.
  257 
  258         NOTE: this method is optional, as it was not part of the originally
  259               defined plugin API.
  260         """
  261         raise NotImplementedError()
  262 
  263     @abc.abstractmethod
  264     def delete_network(self, context, id):
  265         """Delete a network.
  266 
  267         :param context: neutron api request context
  268         :param id: UUID representing the network to delete.
  269         """
  270         pass
  271 
  272     @abc.abstractmethod
  273     def create_port(self, context, port):
  274         """Create a port.
  275 
  276         Create a port, which is a connection point of a device (e.g., a VM
  277         NIC) to attach to a L2 neutron network.
  278 
  279         :param context: neutron api request context
  280         :param port: dictionary describing the port, with keys as listed in the
  281                      :obj:`RESOURCE_ATTRIBUTE_MAP` object in
  282                      :file:`neutron/api/v2/attributes.py`.  All keys will be
  283                      populated.
  284         """
  285         pass
  286 
  287     @abc.abstractmethod
  288     def update_port(self, context, id, port):
  289         """Update values of a port.
  290 
  291         :param context: neutron api request context
  292         :param id: UUID representing the port to update.
  293         :param port: dictionary with keys indicating fields to update.
  294                      valid keys are those that have a value of True for
  295                      'allow_put' as listed in the :obj:`RESOURCE_ATTRIBUTE_MAP`
  296                      object in :file:`neutron/api/v2/attributes.py`.
  297         """
  298         pass
  299 
  300     @abc.abstractmethod
  301     def get_port(self, context, id, fields=None):
  302         """Retrieve a port.
  303 
  304         :param context: neutron api request context
  305         :param id: UUID representing the port to fetch.
  306         :param fields: a list of strings that are valid keys in a port
  307                        dictionary as listed in the
  308                        :obj:`RESOURCE_ATTRIBUTE_MAP` object in
  309                        :file:`neutron/api/v2/attributes.py`. Only these fields
  310                        will be returned.
  311         """
  312         pass
  313 
  314     @abc.abstractmethod
  315     def get_ports(self, context, filters=None, fields=None,
  316                   sorts=None, limit=None, marker=None, page_reverse=False):
  317         """Retrieve a list of ports.
  318 
  319         The contents of the list depends on the identity of the user making
  320         the request (as indicated by the context) as well as any filters.
  321 
  322         :param context: neutron api request context
  323         :param filters: a dictionary with keys that are valid keys for
  324                         a port as listed in the  :obj:`RESOURCE_ATTRIBUTE_MAP`
  325                         object in :file:`neutron/api/v2/attributes.py`. Values
  326                         in this dictionary are an iterable containing values
  327                         that will be used for an exact match comparison for
  328                         that value.  Each result returned by this function will
  329                         have matched one of the values for each key in filters.
  330         :param fields: a list of strings that are valid keys in a
  331                        port dictionary as listed in the
  332                        :obj:`RESOURCE_ATTRIBUTE_MAP` object in
  333                        :file:`neutron/api/v2/attributes.py`. Only these fields
  334                        will be returned.
  335         """
  336         pass
  337 
  338     def get_ports_count(self, context, filters=None):
  339         """Return the number of ports.
  340 
  341         The result depends on the identity of the user making the request
  342         (as indicated by the context) as well as any filters.
  343 
  344         :param context: neutron api request context
  345         :param filters: a dictionary with keys that are valid keys for
  346                         a network as listed in the
  347                         :obj:`RESOURCE_ATTRIBUTE_MAP` object in
  348                         :file:`neutron/api/v2/attributes.py`.  Values in this
  349                         dictionary are an iterable containing values that will
  350                         be used for an exact match comparison for that value.
  351                         Each result returned by this function will have matched
  352                         one of the values for each key in filters.
  353 
  354         .. note:: this method is optional, as it was not part of the originally
  355                   defined plugin API.
  356         """
  357         raise NotImplementedError()
  358 
  359     @abc.abstractmethod
  360     def delete_port(self, context, id):
  361         """Delete a port.
  362 
  363         :param context: neutron api request context
  364         :param id: UUID representing the port to delete.
  365         """
  366         pass
  367 
  368     def start_rpc_listeners(self):
  369         """Start the RPC listeners.
  370 
  371         Most plugins start RPC listeners implicitly on initialization.  In
  372         order to support multiple process RPC, the plugin needs to expose
  373         control over when this is started.
  374 
  375         .. note:: this method is optional, as it was not part of the originally
  376                   defined plugin API.
  377         """
  378         raise NotImplementedError()
  379 
  380     def start_rpc_state_reports_listener(self):
  381         """Start the RPC listeners consuming state reports queue.
  382 
  383         This optional method creates rpc consumer for REPORTS queue only.
  384 
  385         .. note:: this method is optional, as it was not part of the originally
  386                   defined plugin API.
  387         """
  388         raise NotImplementedError()
  389 
  390     def rpc_workers_supported(self):
  391         """Return whether the plugin supports multiple RPC workers.
  392 
  393         A plugin that supports multiple RPC workers should override the
  394         start_rpc_listeners method to ensure that this method returns True and
  395         that start_rpc_listeners is called at the appropriate time.
  396         Alternately, a plugin can override this method to customize detection
  397         of support for multiple rpc workers
  398 
  399         .. note:: this method is optional, as it was not part of the originally
  400                   defined plugin API.
  401         """
  402         return (self.__class__.start_rpc_listeners !=
  403                 NeutronPluginBaseV2.start_rpc_listeners)
  404 
  405     def rpc_state_report_workers_supported(self):
  406         """Return whether the plugin supports state report RPC workers.
  407 
  408         .. note:: this method is optional, as it was not part of the originally
  409                   defined plugin API.
  410         """
  411         return (self.__class__.start_rpc_state_reports_listener !=
  412                 NeutronPluginBaseV2.start_rpc_state_reports_listener)
  413 
  414     def has_native_datastore(self):
  415         """Return True if the plugin uses Neutron's native datastore.
  416 
  417         .. note:: plugins like ML2 should override this method and return True.
  418         """
  419         return False