"Fossies" - the Fresh Open Source Software Archive

Member "manila-8.1.4/manila/share/drivers/netapp/dataontap/protocols/base.py" (19 Nov 2020, 2371 Bytes) of package /linux/misc/openstack/manila-8.1.4.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: 8.1.3_vs_8.1.4.

    1 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
    2 #    not use this file except in compliance with the License. You may obtain
    3 #    a copy of the License at
    4 #
    5 #         http://www.apache.org/licenses/LICENSE-2.0
    6 #
    7 #    Unless required by applicable law or agreed to in writing, software
    8 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    9 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   10 #    License for the specific language governing permissions and limitations
   11 #    under the License.
   12 """
   13 Abstract base class for NetApp NAS protocol helper classes.
   14 """
   15 
   16 import abc
   17 
   18 import six
   19 
   20 from manila.common import constants
   21 from manila import utils
   22 
   23 
   24 def access_rules_synchronized(f):
   25     """Decorator for synchronizing share access rule modification methods."""
   26 
   27     def wrapped_func(self, *args, **kwargs):
   28 
   29         # The first argument is always a share, which has an ID
   30         key = "share-access-%s" % args[0]['id']
   31 
   32         @utils.synchronized(key)
   33         def source_func(self, *args, **kwargs):
   34             return f(self, *args, **kwargs)
   35 
   36         return source_func(self, *args, **kwargs)
   37 
   38     return wrapped_func
   39 
   40 
   41 @six.add_metaclass(abc.ABCMeta)
   42 class NetAppBaseHelper(object):
   43     """Interface for protocol-specific NAS drivers."""
   44 
   45     def __init__(self):
   46         self._client = None
   47 
   48     def set_client(self, client):
   49         self._client = client
   50 
   51     def _is_readonly(self, access_level):
   52         """Returns whether an access rule specifies read-only access."""
   53         return access_level == constants.ACCESS_LEVEL_RO
   54 
   55     @abc.abstractmethod
   56     def create_share(self, share, share_name):
   57         """Creates NAS share."""
   58 
   59     @abc.abstractmethod
   60     def delete_share(self, share, share_name):
   61         """Deletes NAS share."""
   62 
   63     @abc.abstractmethod
   64     def update_access(self, share, share_name, rules):
   65         """Replaces the list of access rules known to the backend storage."""
   66 
   67     @abc.abstractmethod
   68     def get_target(self, share):
   69         """Returns host where the share located."""
   70 
   71     @abc.abstractmethod
   72     def get_share_name_for_share(self, share):
   73         """Returns the flexvol name that hosts a share."""
   74 
   75     @abc.abstractmethod
   76     def cleanup_demoted_replica(self, share, share_name):
   77         """Do some cleanup regarding the former active replica"""