"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cloudkitty/rating/hash/db/api.py" between
cloudkitty-12.1.0.tar.gz and cloudkitty-13.0.0.tar.gz

About: OpenStack CloudKitty provides Rating-as-a-Service for OpenStack.
The "Victoria" series (latest release).

api.py  (cloudkitty-12.1.0):api.py  (cloudkitty-13.0.0)
skipping to change at line 22 skipping to change at line 22
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
# #
import abc import abc
from oslo_config import cfg from oslo_config import cfg
from oslo_db import api as db_api from oslo_db import api as db_api
import six import six
from cloudkitty.i18n import _
_BACKEND_MAPPING = {'sqlalchemy': 'cloudkitty.rating.hash.db.sqlalchemy.api'} _BACKEND_MAPPING = {'sqlalchemy': 'cloudkitty.rating.hash.db.sqlalchemy.api'}
IMPL = db_api.DBAPI.from_config(cfg.CONF, IMPL = db_api.DBAPI.from_config(cfg.CONF,
backend_mapping=_BACKEND_MAPPING, backend_mapping=_BACKEND_MAPPING,
lazy=True) lazy=True)
def get_instance(): def get_instance():
"""Return a DB API instance.""" """Return a DB API instance."""
return IMPL return IMPL
class BaseHashMapError(Exception): class BaseHashMapError(Exception):
"""Base class for HashMap errors.""" """Base class for HashMap errors."""
class ClientHashMapError(BaseHashMapError): class ClientHashMapError(BaseHashMapError):
"""Base class for client side errors.""" """Base class for client side errors."""
class NoSuchService(ClientHashMapError): class NoSuchService(ClientHashMapError):
"""Raised when the service doesn't exist.""" """Raised when the service doesn't exist."""
def __init__(self, name=None, uuid=None): def __init__(self, name=None, uuid=None):
super(NoSuchService, self).__init__( super(NoSuchService, self).__init__(
"No such service: %s (UUID: %s)" % (name, uuid)) _("No such service: %(name)s (UUID: %(uuid)s)") % {'name': name,
'uuid': uuid})
self.name = name self.name = name
self.uuid = uuid self.uuid = uuid
class NoSuchField(ClientHashMapError): class NoSuchField(ClientHashMapError):
"""Raised when the field doesn't exist for the service.""" """Raised when the field doesn't exist for the service."""
def __init__(self, uuid): def __init__(self, uuid):
super(NoSuchField, self).__init__( super(NoSuchField, self).__init__(
"No such field: %s" % uuid) _("No such field: %s") % uuid)
self.uuid = uuid self.uuid = uuid
class NoSuchGroup(ClientHashMapError): class NoSuchGroup(ClientHashMapError):
"""Raised when the group doesn't exist.""" """Raised when the group doesn't exist."""
def __init__(self, name=None, uuid=None): def __init__(self, name=None, uuid=None):
super(NoSuchGroup, self).__init__( super(NoSuchGroup, self).__init__(
"No such group: %s (UUID: %s)" % (name, uuid)) _("No such group: %(name)s (UUID: %(uuid)s)") %
{'name': name, 'uuid': uuid})
self.name = name self.name = name
self.uuid = uuid self.uuid = uuid
class NoSuchMapping(ClientHashMapError): class NoSuchMapping(ClientHashMapError):
"""Raised when the mapping doesn't exist.""" """Raised when the mapping doesn't exist."""
def __init__(self, uuid): def __init__(self, uuid):
msg = ("No such mapping: %s" % uuid) msg = (_("No such mapping: %s") % uuid)
super(NoSuchMapping, self).__init__(msg) super(NoSuchMapping, self).__init__(msg)
self.uuid = uuid self.uuid = uuid
class NoSuchThreshold(ClientHashMapError): class NoSuchThreshold(ClientHashMapError):
"""Raised when the threshold doesn't exist.""" """Raised when the threshold doesn't exist."""
def __init__(self, uuid): def __init__(self, uuid):
msg = ("No such threshold: %s" % uuid) msg = (_("No such threshold: %s") % uuid)
super(NoSuchThreshold, self).__init__(msg) super(NoSuchThreshold, self).__init__(msg)
self.uuid = uuid self.uuid = uuid
class NoSuchType(ClientHashMapError): class NoSuchType(ClientHashMapError):
"""Raised when a mapping type is not handled.""" """Raised when a mapping type is not handled."""
def __init__(self, map_type): def __init__(self, map_type):
msg = ("No mapping type: %s" msg = (_("No mapping type: %s") % map_type)
% (map_type))
super(NoSuchType, self).__init__(msg) super(NoSuchType, self).__init__(msg)
self.map_type = map_type self.map_type = map_type
class ServiceAlreadyExists(ClientHashMapError): class ServiceAlreadyExists(ClientHashMapError):
"""Raised when the service already exists.""" """Raised when the service already exists."""
def __init__(self, name, uuid): def __init__(self, name, uuid):
super(ServiceAlreadyExists, self).__init__( super(ServiceAlreadyExists, self).__init__(
"Service %s already exists (UUID: %s)" % (name, uuid)) _("Service %(name)s already exists (UUID: %(uuid)s)") %
{'name': name, 'uuid': uuid})
self.name = name self.name = name
self.uuid = uuid self.uuid = uuid
class FieldAlreadyExists(ClientHashMapError): class FieldAlreadyExists(ClientHashMapError):
"""Raised when the field already exists.""" """Raised when the field already exists."""
def __init__(self, field, uuid): def __init__(self, field, uuid):
super(FieldAlreadyExists, self).__init__( super(FieldAlreadyExists, self).__init__(
"Field %s already exists (UUID: %s)" % (field, uuid)) _("Field %(field)s already exists (UUID: %(uuid)s)") %
{'field': field, 'uuid': uuid})
self.field = field self.field = field
self.uuid = uuid self.uuid = uuid
class GroupAlreadyExists(ClientHashMapError): class GroupAlreadyExists(ClientHashMapError):
"""Raised when the group already exists.""" """Raised when the group already exists."""
def __init__(self, name, uuid): def __init__(self, name, uuid):
super(GroupAlreadyExists, self).__init__( super(GroupAlreadyExists, self).__init__(
"Group %s already exists (UUID: %s)" % (name, uuid)) _("Group %(name)s already exists (UUID: %(uuid)s)") %
{'name': name, 'uuid': uuid})
self.name = name self.name = name
self.uuid = uuid self.uuid = uuid
class MappingAlreadyExists(ClientHashMapError): class MappingAlreadyExists(ClientHashMapError):
"""Raised when the mapping already exists.""" """Raised when the mapping already exists."""
def __init__(self, def __init__(self,
mapping, mapping,
parent_id=None, parent_id=None,
parent_type=None, parent_type=None,
uuid=None, uuid=None,
tenant_id=None): tenant_id=None):
# TODO(sheeprine): UUID is deprecated # TODO(sheeprine): UUID is deprecated
parent_id = parent_id if parent_id else uuid parent_id = parent_id if parent_id else uuid
super(MappingAlreadyExists, self).__init__( super(MappingAlreadyExists, self).__init__(
"Mapping '%s' already exists for %s '%s', tenant: '%s'" _("Mapping '%(mapping)s' already exists for %(p_type)s '%(p_id)s',"
% (mapping, parent_type, parent_id, tenant_id)) " tenant: '%(t_id)s'") %
{'mapping': mapping, 'p_type': parent_type,
'p_id': parent_id, 't_id': tenant_id})
self.mapping = mapping self.mapping = mapping
self.uuid = parent_id self.uuid = parent_id
self.parent_id = parent_id self.parent_id = parent_id
self.parent_type = parent_type self.parent_type = parent_type
self.tenant_id = tenant_id self.tenant_id = tenant_id
class ThresholdAlreadyExists(ClientHashMapError): class ThresholdAlreadyExists(ClientHashMapError):
"""Raised when the threshold already exists.""" """Raised when the threshold already exists."""
def __init__(self, def __init__(self,
threshold, threshold,
parent_id=None, parent_id=None,
parent_type=None, parent_type=None,
uuid=None, uuid=None,
tenant_id=None): tenant_id=None):
# TODO(sheeprine): UUID is deprecated # TODO(sheeprine): UUID is deprecated
parent_id = parent_id if parent_id else uuid parent_id = parent_id if parent_id else uuid
super(ThresholdAlreadyExists, self).__init__( super(ThresholdAlreadyExists, self).__init__(
"Threshold '%s' already exists for %s '%s', tenant: '%s'" _("Threshold '%(threshold)s' already exists for %(p_type)s "
% (threshold, parent_type, parent_id, tenant_id)) "'%(p_id)s', tenant: '%(t_id)s'") %
{'threshold': threshold, 'p_type': parent_type,
'p_id': parent_id, 't_id': tenant_id})
self.threshold = threshold self.threshold = threshold
self.uuid = parent_id self.uuid = parent_id
self.parent_id = parent_id self.parent_id = parent_id
self.parent_type = parent_type self.parent_type = parent_type
self.tenant_id = tenant_id self.tenant_id = tenant_id
class MappingHasNoGroup(ClientHashMapError): class MappingHasNoGroup(ClientHashMapError):
"""Raised when the mapping is not attached to a group.""" """Raised when the mapping is not attached to a group."""
def __init__(self, uuid): def __init__(self, uuid):
super(MappingHasNoGroup, self).__init__( super(MappingHasNoGroup, self).__init__(
"Mapping has no group (UUID: %s)" % uuid) _("Mapping has no group (UUID: %s)") % uuid)
self.uuid = uuid self.uuid = uuid
class ThresholdHasNoGroup(ClientHashMapError): class ThresholdHasNoGroup(ClientHashMapError):
"""Raised when the threshold is not attached to a group.""" """Raised when the threshold is not attached to a group."""
def __init__(self, uuid): def __init__(self, uuid):
super(ThresholdHasNoGroup, self).__init__( super(ThresholdHasNoGroup, self).__init__(
"Threshold has no group (UUID: %s)" % uuid) _("Threshold has no group (UUID: %s)") % uuid)
self.uuid = uuid self.uuid = uuid
@six.add_metaclass(abc.ABCMeta) @six.add_metaclass(abc.ABCMeta)
class HashMap(object): class HashMap(object):
"""Base class for hashmap configuration.""" """Base class for hashmap configuration."""
@abc.abstractmethod @abc.abstractmethod
def get_migration(self): def get_migration(self):
"""Return a migrate manager. """Return a migrate manager.
 End of changes. 14 change blocks. 
16 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)