From 63040c95d8b7c9bf15cf7a05b38360bc5dfc5181 Mon Sep 17 00:00:00 2001 From: "Jay Lau (Guangya Liu)" Date: Thu, 5 Feb 2015 12:42:36 +0800 Subject: [PATCH] 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 --- magnum/objects/container.py | 16 ---------------- magnum/objects/node.py | 16 ---------------- magnum/objects/pod.py | 16 ---------------- magnum/objects/replicationcontroller.py | 17 ----------------- magnum/objects/service.py | 16 ---------------- magnum/tests/objects/test_container.py | 10 +++------- magnum/tests/objects/test_node.py | 9 ++------- magnum/tests/objects/test_pod.py | 9 ++------- .../tests/objects/test_replicationcontroller.py | 12 ++++-------- magnum/tests/objects/test_service.py | 9 ++------- 10 files changed, 13 insertions(+), 117 deletions(-) diff --git a/magnum/objects/container.py b/magnum/objects/container.py index 9e1648a1e2..02760d50b4 100644 --- a/magnum/objects/container.py +++ b/magnum/objects/container.py @@ -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. diff --git a/magnum/objects/node.py b/magnum/objects/node.py index 6029f0dd72..aeb6bd9d98 100644 --- a/magnum/objects/node.py +++ b/magnum/objects/node.py @@ -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. diff --git a/magnum/objects/pod.py b/magnum/objects/pod.py index b26be71057..f8d412b7dd 100644 --- a/magnum/objects/pod.py +++ b/magnum/objects/pod.py @@ -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. diff --git a/magnum/objects/replicationcontroller.py b/magnum/objects/replicationcontroller.py index d97e0c79b1..09946496c8 100644 --- a/magnum/objects/replicationcontroller.py +++ b/magnum/objects/replicationcontroller.py @@ -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 diff --git a/magnum/objects/service.py b/magnum/objects/service.py index bc03fa0f99..0ef53e9a62 100644 --- a/magnum/objects/service.py +++ b/magnum/objects/service.py @@ -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. diff --git a/magnum/tests/objects/test_container.py b/magnum/tests/objects/test_container.py index 27bafbaa07..2b932d9a00 100644 --- a/magnum/tests/objects/test_container.py +++ b/magnum/tests/objects/test_container.py @@ -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: diff --git a/magnum/tests/objects/test_node.py b/magnum/tests/objects/test_node.py index 5946c77d77..9a387c2736 100644 --- a/magnum/tests/objects/test_node.py +++ b/magnum/tests/objects/test_node.py @@ -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: diff --git a/magnum/tests/objects/test_pod.py b/magnum/tests/objects/test_pod.py index 39ca196b0f..8b8395d507 100644 --- a/magnum/tests/objects/test_pod.py +++ b/magnum/tests/objects/test_pod.py @@ -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: diff --git a/magnum/tests/objects/test_replicationcontroller.py b/magnum/tests/objects/test_replicationcontroller.py index 471aeead29..3b53315556 100644 --- a/magnum/tests/objects/test_replicationcontroller.py +++ b/magnum/tests/objects/test_replicationcontroller.py @@ -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: diff --git a/magnum/tests/objects/test_service.py b/magnum/tests/objects/test_service.py index a54d5fc543..62d7a74b1a 100644 --- a/magnum/tests/objects/test_service.py +++ b/magnum/tests/objects/test_service.py @@ -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: