Remove API get() for some magnum objects

The get() API was not used by the following objects, just remove it.

1) node
2) pod
3) replication controller
4) service
5) container

Change-Id: I2f578f8d072d772bf34e676b115eccf6c08bac8a
This commit is contained in:
Jay Lau (Guangya Liu) 2015-02-05 12:42:36 +08:00
parent ce0ef7c421
commit 63040c95d8
10 changed files with 13 additions and 117 deletions

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from magnum.common import exception
from magnum.common import utils
from magnum.db import api as dbapi
from magnum.objects import base
from magnum.objects import utils as obj_utils
@ -50,20 +48,6 @@ class Container(base.MagnumObject):
return [Container._from_db_object(cls(context), obj)
for obj in db_objects]
@base.remotable_classmethod
def get(cls, context, container_id):
"""Find a container based on its id or uuid and return a Container object.
:param container_id: the id *or* uuid of a container.
:returns: a :class:`Container` object.
"""
if utils.is_int_like(container_id):
return cls.get_by_id(context, container_id)
elif utils.is_uuid_like(container_id):
return cls.get_by_uuid(context, container_id)
else:
raise exception.InvalidIdentity(identity=container_id)
@base.remotable_classmethod
def get_by_id(cls, context, container_id):
"""Find a container based on its integer id and return a Container object.

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from magnum.common import exception
from magnum.common import utils
from magnum.db import api as dbapi
from magnum.objects import base
from magnum.objects import utils as obj_utils
@ -50,20 +48,6 @@ class Node(base.MagnumObject):
"""Converts a list of database entities to a list of formal objects."""
return [Node._from_db_object(cls(context), obj) for obj in db_objects]
@base.remotable_classmethod
def get(cls, context, node_id):
"""Find a node based on its id or uuid and return a Node object.
:param node_id: the id *or* uuid of a node.
:returns: a :class:`Node` object.
"""
if utils.is_int_like(node_id):
return cls.get_by_id(context, node_id)
elif utils.is_uuid_like(node_id):
return cls.get_by_uuid(context, node_id)
else:
raise exception.InvalidIdentity(identity=node_id)
@base.remotable_classmethod
def get_by_id(cls, context, node_id):
"""Find a node based on its integer id and return a Node object.

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from magnum.common import exception
from magnum.common import utils
from magnum.db import api as dbapi
from magnum.objects import base
from magnum.objects import utils as obj_utils
@ -60,20 +58,6 @@ class Pod(base.MagnumObject):
"""Converts a list of database entities to a list of formal objects."""
return [Pod._from_db_object(cls(context), obj) for obj in db_objects]
@base.remotable_classmethod
def get(cls, context, pod_id):
"""Find a pod based on its id or uuid and return a Pod object.
:param pod_id: the id *or* uuid of a pod.
:returns: a :class:`Pod` object.
"""
if utils.is_int_like(pod_id):
return cls.get_by_id(context, pod_id)
elif utils.is_uuid_like(pod_id):
return cls.get_by_uuid(context, pod_id)
else:
raise exception.InvalidIdentity(identity=pod_id)
@base.remotable_classmethod
def get_by_id(cls, context, pod_id):
"""Find a pod based on its integer id and return a Pod object.

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from magnum.common import exception
from magnum.common import utils
from magnum.db import api as dbapi
from magnum.objects import base
from magnum.objects import utils as obj_utils
@ -60,21 +58,6 @@ class ReplicationController(base.MagnumObject):
return [ReplicationController._from_db_object(cls(context),
obj) for obj in db_objects]
@base.remotable_classmethod
def get(cls, context, rc_id):
"""Find a ReplicationController based on its id or uuid and return a
replication controller object.
:param rc_id: the id *or* uuid of a ReplicationController.
:returns: a :class:`ReplicationController` object.
"""
if utils.is_int_like(rc_id):
return cls.get_by_id(context, rc_id)
elif utils.is_uuid_like(rc_id):
return cls.get_by_uuid(context, rc_id)
else:
raise exception.InvalidIdentity(identity=rc_id)
@base.remotable_classmethod
def get_by_id(cls, context, rc_id):
"""Find a ReplicationController based on its integer id and return a

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from magnum.common import exception
from magnum.common import utils
from magnum.db import api as dbapi
from magnum.objects import base
from magnum.objects import utils as obj_utils
@ -61,20 +59,6 @@ class Service(base.MagnumObject):
return [Service._from_db_object(cls(context), obj)
for obj in db_objects]
@base.remotable_classmethod
def get(cls, context, service_id):
"""Find a service based on its id or uuid and return a Service object.
:param service_id: the id *or* uuid of a service.
:returns: a :class:`Service` object.
"""
if utils.is_int_like(service_id):
return cls.get_by_id(context, service_id)
elif utils.is_uuid_like(service_id):
return cls.get_by_uuid(context, service_id)
else:
raise exception.InvalidIdentity(identity=service_id)
@base.remotable_classmethod
def get_by_id(cls, context, service_id):
"""Find a service based on its integer id and return a Service object.

View File

@ -16,7 +16,6 @@
import mock
from testtools.matchers import HasLength
from magnum.common import exception
from magnum.common import utils as magnum_utils
from magnum import objects
from magnum.tests.db import base
@ -34,7 +33,8 @@ class TestContainerObject(base.DbTestCase):
with mock.patch.object(self.dbapi, 'get_container_by_id',
autospec=True) as mock_get_container:
mock_get_container.return_value = self.fake_container
container = objects.Container.get(self.context, container_id)
container = objects.Container.get_by_id(self.context,
container_id)
mock_get_container.assert_called_once_with(self.context,
container_id)
self.assertEqual(self.context, container._context)
@ -44,14 +44,10 @@ class TestContainerObject(base.DbTestCase):
with mock.patch.object(self.dbapi, 'get_container_by_uuid',
autospec=True) as mock_get_container:
mock_get_container.return_value = self.fake_container
container = objects.Container.get(self.context, uuid)
container = objects.Container.get_by_uuid(self.context, uuid)
mock_get_container.assert_called_once_with(self.context, uuid)
self.assertEqual(self.context, container._context)
def test_get_bad_id_and_uuid(self):
self.assertRaises(exception.InvalidIdentity,
objects.Container.get, self.context, 'not-a-uuid')
def test_list(self):
with mock.patch.object(self.dbapi, 'get_container_list',
autospec=True) as mock_get_list:

View File

@ -16,7 +16,6 @@
import mock
from testtools.matchers import HasLength
from magnum.common import exception
from magnum.common import utils as magnum_utils
from magnum import objects
from magnum.tests.db import base
@ -34,7 +33,7 @@ class TestNodeObject(base.DbTestCase):
with mock.patch.object(self.dbapi, 'get_node_by_id',
autospec=True) as mock_get_node:
mock_get_node.return_value = self.fake_node
node = objects.Node.get(self.context, node_id)
node = objects.Node.get_by_id(self.context, node_id)
mock_get_node.assert_called_once_with(self.context, node_id)
self.assertEqual(self.context, node._context)
@ -43,14 +42,10 @@ class TestNodeObject(base.DbTestCase):
with mock.patch.object(self.dbapi, 'get_node_by_uuid',
autospec=True) as mock_get_node:
mock_get_node.return_value = self.fake_node
node = objects.Node.get(self.context, uuid)
node = objects.Node.get_by_uuid(self.context, uuid)
mock_get_node.assert_called_once_with(self.context, uuid)
self.assertEqual(self.context, node._context)
def test_get_bad_id_and_uuid(self):
self.assertRaises(exception.InvalidIdentity,
objects.Node.get, self.context, 'not-a-uuid')
def test_list(self):
with mock.patch.object(self.dbapi, 'get_node_list',
autospec=True) as mock_get_list:

View File

@ -16,7 +16,6 @@
import mock
from testtools.matchers import HasLength
from magnum.common import exception
from magnum.common import utils as magnum_utils
from magnum import objects
from magnum.tests.db import base
@ -34,7 +33,7 @@ class TestPodObject(base.DbTestCase):
with mock.patch.object(self.dbapi, 'get_pod_by_id',
autospec=True) as mock_get_pod:
mock_get_pod.return_value = self.fake_pod
pod = objects.Pod.get(self.context, pod_id)
pod = objects.Pod.get_by_id(self.context, pod_id)
mock_get_pod.assert_called_once_with(self.context, pod_id)
self.assertEqual(self.context, pod._context)
@ -43,14 +42,10 @@ class TestPodObject(base.DbTestCase):
with mock.patch.object(self.dbapi, 'get_pod_by_uuid',
autospec=True) as mock_get_pod:
mock_get_pod.return_value = self.fake_pod
pod = objects.Pod.get(self.context, uuid)
pod = objects.Pod.get_by_uuid(self.context, uuid)
mock_get_pod.assert_called_once_with(self.context, uuid)
self.assertEqual(self.context, pod._context)
def test_get_bad_id_and_uuid(self):
self.assertRaises(exception.InvalidIdentity,
objects.Pod.get, self.context, 'not-a-uuid')
def test_list(self):
with mock.patch.object(self.dbapi, 'get_pod_list',
autospec=True) as mock_get_list:

View File

@ -16,7 +16,6 @@
import mock
from testtools.matchers import HasLength
from magnum.common import exception
from magnum.common import utils as magnum_utils
from magnum import objects
from magnum.tests.db import base
@ -34,7 +33,8 @@ class TestReplicationControllerObject(base.DbTestCase):
with mock.patch.object(self.dbapi, 'get_rc_by_id',
autospec=True) as mock_get_rc:
mock_get_rc.return_value = self.fake_rc
rc = objects.ReplicationController.get(self.context, rc_id)
rc = objects.ReplicationController.get_by_id(self.context,
rc_id)
mock_get_rc.assert_called_once_with(self.context, rc_id)
self.assertEqual(self.context, rc._context)
@ -43,15 +43,11 @@ class TestReplicationControllerObject(base.DbTestCase):
with mock.patch.object(self.dbapi, 'get_rc_by_uuid',
autospec=True) as mock_get_rc:
mock_get_rc.return_value = self.fake_rc
rc = objects.ReplicationController.get(self.context, uuid)
rc = objects.ReplicationController.get_by_uuid(self.context,
uuid)
mock_get_rc.assert_called_once_with(self.context, uuid)
self.assertEqual(self.context, rc._context)
def test_get_bad_id_and_uuid(self):
self.assertRaises(exception.InvalidIdentity,
objects.ReplicationController.get,
self.context, 'not-a-uuid')
def test_list(self):
with mock.patch.object(self.dbapi, 'get_rc_list',
autospec=True) as mock_get_list:

View File

@ -16,7 +16,6 @@
import mock
from testtools.matchers import HasLength
from magnum.common import exception
from magnum.common import utils as magnum_utils
from magnum import objects
from magnum.tests.db import base
@ -34,7 +33,7 @@ class TestServiceObject(base.DbTestCase):
with mock.patch.object(self.dbapi, 'get_service_by_id',
autospec=True) as mock_get_service:
mock_get_service.return_value = self.fake_service
service = objects.Service.get(self.context, service_id)
service = objects.Service.get_by_id(self.context, service_id)
mock_get_service.assert_called_once_with(self.context, service_id)
self.assertEqual(self.context, service._context)
@ -43,14 +42,10 @@ class TestServiceObject(base.DbTestCase):
with mock.patch.object(self.dbapi, 'get_service_by_uuid',
autospec=True) as mock_get_service:
mock_get_service.return_value = self.fake_service
service = objects.Service.get(self.context, uuid)
service = objects.Service.get_by_uuid(self.context, uuid)
mock_get_service.assert_called_once_with(self.context, uuid)
self.assertEqual(self.context, service._context)
def test_get_bad_id_and_uuid(self):
self.assertRaises(exception.InvalidIdentity,
objects.Service.get, self.context, 'not-a-uuid')
def test_list(self):
with mock.patch.object(self.dbapi, 'get_service_list',
autospec=True) as mock_get_list: