Make ManagerWithFind abstract and fix its descendants
ManagerWithFind requires list() method in its descendants. Make it abstract and fix its improper descendants that do not implement list() (QuotaSetManager and others). Change-Id: I691ca389b5fea4c1bb36499a264b578fa825bbbf Fixes: bug #1180393
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
"""
|
||||
Base utilities to build API operation managers and objects on top of.
|
||||
"""
|
||||
|
||||
import abc
|
||||
import contextlib
|
||||
import hashlib
|
||||
import os
|
||||
@@ -167,6 +167,12 @@ class ManagerWithFind(Manager):
|
||||
"""
|
||||
Like a `Manager`, but with additional `find()`/`findall()` methods.
|
||||
"""
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def list(self):
|
||||
pass
|
||||
|
||||
def find(self, **kwargs):
|
||||
"""
|
||||
Find a single item with attributes matching ``**kwargs``.
|
||||
@@ -204,9 +210,6 @@ class ManagerWithFind(Manager):
|
||||
|
||||
return found
|
||||
|
||||
def list(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class Resource(object):
|
||||
"""
|
||||
|
@@ -28,7 +28,7 @@ class QuotaClassSet(base.Resource):
|
||||
self.manager.update(self.class_name, *args, **kwargs)
|
||||
|
||||
|
||||
class QuotaClassSetManager(base.ManagerWithFind):
|
||||
class QuotaClassSetManager(base.Manager):
|
||||
resource_class = QuotaClassSet
|
||||
|
||||
def get(self, class_name):
|
||||
|
@@ -28,7 +28,7 @@ class QuotaSet(base.Resource):
|
||||
self.manager.update(self.tenant_id, *args, **kwargs)
|
||||
|
||||
|
||||
class QuotaSetManager(base.ManagerWithFind):
|
||||
class QuotaSetManager(base.Manager):
|
||||
resource_class = QuotaSet
|
||||
|
||||
def get(self, tenant_id):
|
||||
|
@@ -27,7 +27,7 @@ class VolumeBackupsRestore(base.Resource):
|
||||
return "<VolumeBackupsRestore: %s>" % self.id
|
||||
|
||||
|
||||
class VolumeBackupRestoreManager(base.ManagerWithFind):
|
||||
class VolumeBackupRestoreManager(base.Manager):
|
||||
"""Manage :class:`VolumeBackupsRestore` resources."""
|
||||
resource_class = VolumeBackupsRestore
|
||||
|
||||
|
@@ -27,7 +27,7 @@ class QuotaClassSet(base.Resource):
|
||||
self.manager.update(self.class_name, *args, **kwargs)
|
||||
|
||||
|
||||
class QuotaClassSetManager(base.ManagerWithFind):
|
||||
class QuotaClassSetManager(base.Manager):
|
||||
resource_class = QuotaClassSet
|
||||
|
||||
def get(self, class_name):
|
||||
|
@@ -27,7 +27,7 @@ class QuotaSet(base.Resource):
|
||||
self.manager.update(self.tenant_id, *args, **kwargs)
|
||||
|
||||
|
||||
class QuotaSetManager(base.ManagerWithFind):
|
||||
class QuotaSetManager(base.Manager):
|
||||
resource_class = QuotaSet
|
||||
|
||||
def get(self, tenant_id):
|
||||
|
@@ -27,7 +27,7 @@ class VolumeBackupsRestore(base.Resource):
|
||||
return "<VolumeBackupsRestore: %s>" % self.id
|
||||
|
||||
|
||||
class VolumeBackupRestoreManager(base.ManagerWithFind):
|
||||
class VolumeBackupRestoreManager(base.Manager):
|
||||
"""Manage :class:`VolumeBackupsRestore` resources."""
|
||||
resource_class = VolumeBackupsRestore
|
||||
|
||||
|
Reference in New Issue
Block a user