diff options
author | Kaifeng Wang <kaifeng.w@gmail.com> | 2019-11-18 14:37:49 +0800 |
---|---|---|
committer | Kaifeng Wang <kaifeng.w@gmail.com> | 2019-11-18 14:37:49 +0800 |
commit | 9541179025cbb2bd5b62b3d5e667bc8de6499b45 (patch) | |
tree | 067fbfe803f0a7eb084eb6bfee947bd2c6d4afa9 | |
parent | f8c4f7b1e4b8c7c177ccb45f4f0d8acba1821279 (diff) | |
download | ironic-9541179025cbb2bd5b62b3d5e667bc8de6499b45.tar.gz |
Remove old online migration codes
The vif migration for port and portgroup has been removed in [1],
this follow up removes unused code in objects.
[1] https://review.opendev.org/#/c/685091
Change-Id: I4ff7d6ce6535be0cb2b2959c8539a6850e189647
-rw-r--r-- | ironic/objects/port.py | 30 | ||||
-rw-r--r-- | ironic/objects/portgroup.py | 31 | ||||
-rw-r--r-- | ironic/tests/unit/objects/test_port.py | 30 | ||||
-rw-r--r-- | ironic/tests/unit/objects/test_portgroup.py | 30 |
4 files changed, 0 insertions, 121 deletions
diff --git a/ironic/objects/port.py b/ironic/objects/port.py index 5c5067859..7bc829dfa 100644 --- a/ironic/objects/port.py +++ b/ironic/objects/port.py @@ -26,36 +26,6 @@ from ironic.objects import fields as object_fields from ironic.objects import notification -def migrate_vif_port_id(context, max_count): - """Copy port's VIF info from extra to internal_info. - - :param context: The context. - :param max_count: The maximum number of objects to migrate. Must be - >= 0. If zero, all the objects will be migrated. - :returns: A 2-tuple -- the total number of objects that need to be - migrated (at the beginning of this call) and the number - of migrated objects. - """ - # TODO(rloo): remove this method in Stein, when we remove from dbsync.py - - # NOTE(rloo): if we introduce newer port versions in the same cycle, - # we could add those versions along with 1.8. This is only so we don't - # duplicate work; it isn't necessary. - db_ports = Port.dbapi.get_not_versions('Port', ['1.8', '1.9']) - total = len(db_ports) - max_count = max_count or total - done = 0 - for db_port in db_ports: - # NOTE(rloo): this will indirectly invoke Port._convert_to_version() - # which does all the real work - port = Port._from_db_object(context, Port(), db_port) - port.save() - done += 1 - if done == max_count: - break - return total, done - - @base.IronicObjectRegistry.register class Port(base.IronicObject, object_base.VersionedObjectDictCompat): # Version 1.0: Initial version diff --git a/ironic/objects/portgroup.py b/ironic/objects/portgroup.py index add50ce25..4c6a763a2 100644 --- a/ironic/objects/portgroup.py +++ b/ironic/objects/portgroup.py @@ -27,37 +27,6 @@ from ironic.objects import fields as object_fields from ironic.objects import notification -def migrate_vif_port_id(context, max_count): - """Copy portgroup's VIF info from extra to internal_info. - - :param context: The context. - :param max_count: The maximum number of objects to migrate. Must be - >= 0. If zero, all the objects will be migrated. - :returns: A 2-tuple -- the total number of objects that need to be - migrated (at the beginning of this call) and the number - of migrated objects. - """ - # TODO(rloo): remove this method in Stein, when we remove from dbsync.py - - # NOTE(rloo): if we introduce newer portgroup versions in the same cycle, - # we could add those versions along with 1.4. This is only so we don't - # duplicate work; it isn't necessary. - db_objs = Portgroup.dbapi.get_not_versions('Portgroup', ['1.4']) - total = len(db_objs) - max_count = max_count or total - done = 0 - for db_obj in db_objs: - # NOTE(rloo): this will indirectly invoke - # Portgroup._convert_to_version() which does all the real - # work - portgroup = Portgroup._from_db_object(context, Portgroup(), db_obj) - portgroup.save() - done += 1 - if done == max_count: - break - return total, done - - @base.IronicObjectRegistry.register class Portgroup(base.IronicObject, object_base.VersionedObjectDictCompat): # Version 1.0: Initial version diff --git a/ironic/tests/unit/objects/test_port.py b/ironic/tests/unit/objects/test_port.py index 2e6948773..5c1d4b205 100644 --- a/ironic/tests/unit/objects/test_port.py +++ b/ironic/tests/unit/objects/test_port.py @@ -349,33 +349,3 @@ class TestMigrateVifPortId(db_base.DbTestCase): address='52:54:00:cf:2d:3%s' % i, extra=extra, version='1.7') self.db_ports.append(port) - - @mock.patch.object(objects.Port, '_convert_to_version', autospec=True) - def test_migrate_vif_port_id_all(self, mock_convert): - with mock.patch.object(self.dbapi, 'get_not_versions', - autospec=True) as mock_get_not_versions: - mock_get_not_versions.return_value = self.db_ports - total, done = objects.port.migrate_vif_port_id(self.context, 0) - self.assertEqual(3, total) - self.assertEqual(3, done) - mock_get_not_versions.assert_called_once_with('Port', ['1.8', - '1.9']) - calls = 3 * [ - mock.call(mock.ANY, '1.9', remove_unavailable_fields=False), - ] - self.assertEqual(calls, mock_convert.call_args_list) - - @mock.patch.object(objects.Port, '_convert_to_version', autospec=True) - def test_migrate_vif_port_id_one(self, mock_convert): - with mock.patch.object(self.dbapi, 'get_not_versions', - autospec=True) as mock_get_not_versions: - mock_get_not_versions.return_value = self.db_ports - total, done = objects.port.migrate_vif_port_id(self.context, 1) - self.assertEqual(3, total) - self.assertEqual(1, done) - mock_get_not_versions.assert_called_once_with('Port', ['1.8', - '1.9']) - calls = [ - mock.call(mock.ANY, '1.9', remove_unavailable_fields=False), - ] - self.assertEqual(calls, mock_convert.call_args_list) diff --git a/ironic/tests/unit/objects/test_portgroup.py b/ironic/tests/unit/objects/test_portgroup.py index ec67695c6..6759ce728 100644 --- a/ironic/tests/unit/objects/test_portgroup.py +++ b/ironic/tests/unit/objects/test_portgroup.py @@ -218,33 +218,3 @@ class TestMigrateVifPortId(db_base.DbTestCase): address='52:54:00:cf:2d:3%s' % i, extra=extra, version='1.3') self.db_portgroups.append(portgroup) - - @mock.patch.object(objects.Portgroup, '_convert_to_version', autospec=True) - def test_migrate_vif_port_id_all(self, mock_convert): - with mock.patch.object(self.dbapi, 'get_not_versions', - autospec=True) as mock_get_not_versions: - mock_get_not_versions.return_value = self.db_portgroups - total, done = objects.portgroup.migrate_vif_port_id( - self.context, 0) - self.assertEqual(3, total) - self.assertEqual(3, done) - mock_get_not_versions.assert_called_once_with('Portgroup', ['1.4']) - calls = 3 * [ - mock.call(mock.ANY, '1.4', remove_unavailable_fields=False), - ] - self.assertEqual(calls, mock_convert.call_args_list) - - @mock.patch.object(objects.Portgroup, '_convert_to_version', autospec=True) - def test_migrate_vif_port_id_one(self, mock_convert): - with mock.patch.object(self.dbapi, 'get_not_versions', - autospec=True) as mock_get_not_versions: - mock_get_not_versions.return_value = self.db_portgroups - total, done = objects.portgroup.migrate_vif_port_id( - self.context, 1) - self.assertEqual(3, total) - self.assertEqual(1, done) - mock_get_not_versions.assert_called_once_with('Portgroup', ['1.4']) - calls = [ - mock.call(mock.ANY, '1.4', remove_unavailable_fields=False), - ] - self.assertEqual(calls, mock_convert.call_args_list) |