Merge "Remove old online migration codes"
This commit is contained in:
commit
5ed42147d7
@ -26,36 +26,6 @@ from ironic.objects import fields as object_fields
|
|||||||
from ironic.objects import notification
|
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
|
@base.IronicObjectRegistry.register
|
||||||
class Port(base.IronicObject, object_base.VersionedObjectDictCompat):
|
class Port(base.IronicObject, object_base.VersionedObjectDictCompat):
|
||||||
# Version 1.0: Initial version
|
# Version 1.0: Initial version
|
||||||
|
@ -27,37 +27,6 @@ from ironic.objects import fields as object_fields
|
|||||||
from ironic.objects import notification
|
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
|
@base.IronicObjectRegistry.register
|
||||||
class Portgroup(base.IronicObject, object_base.VersionedObjectDictCompat):
|
class Portgroup(base.IronicObject, object_base.VersionedObjectDictCompat):
|
||||||
# Version 1.0: Initial version
|
# Version 1.0: Initial version
|
||||||
|
@ -349,33 +349,3 @@ class TestMigrateVifPortId(db_base.DbTestCase):
|
|||||||
address='52:54:00:cf:2d:3%s' % i,
|
address='52:54:00:cf:2d:3%s' % i,
|
||||||
extra=extra, version='1.7')
|
extra=extra, version='1.7')
|
||||||
self.db_ports.append(port)
|
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)
|
|
||||||
|
@ -218,33 +218,3 @@ class TestMigrateVifPortId(db_base.DbTestCase):
|
|||||||
address='52:54:00:cf:2d:3%s' % i,
|
address='52:54:00:cf:2d:3%s' % i,
|
||||||
extra=extra, version='1.3')
|
extra=extra, version='1.3')
|
||||||
self.db_portgroups.append(portgroup)
|
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)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user