# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import abc import os import re import six from karbor import exception from karbor.i18n import _ @six.add_metaclass(abc.ABCMeta) class LeasePlugin(object): @abc.abstractmethod def acquire_lease(self): pass @abc.abstractmethod def renew_lease(self): pass @abc.abstractmethod def check_lease_validity(self): pass @six.add_metaclass(abc.ABCMeta) class BankPlugin(object): def __init__(self, config=None): super(BankPlugin, self).__init__() self._config = config @abc.abstractmethod def update_object(self, key, value, context=None): return @abc.abstractmethod def get_object(self, key, context=None): return @abc.abstractmethod def list_objects(self, prefix=None, limit=None, marker=None, sort_dir=None, context=None): return @abc.abstractmethod def delete_object(self, key, context=None): return @abc.abstractmethod def get_owner_id(self, context=None): return def validate_key(key): pass def validate_dir(key): pass class Bank(object): _KEY_VALIDATION = re.compile('^[A-Za-z0-9/_.\-@]+(? self.obj_size: return '' return self.bank_section.get_object(self.sorted_objects[obj_index])