Resolve issues with 'server migration list'

The 'os-migrations' API accepts 'instance_uuid' and 'migration_type'
query string parameters, not 'server' and 'type'. For the former, as the
name would suggest, the value should be a server UUID, not a name.

In addition, this is a list command and therefore should subclass the
'Lister' base class.

Change-Id: I736f5575156fc04d7ada7783a1865ab3b438396f
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2020-11-09 14:53:57 +00:00
parent cb6659d7cd
commit 1a5dd4af5b
2 changed files with 11 additions and 12 deletions

View File

@ -2041,7 +2041,7 @@ revert to release the new server and restart the old one.""")
raise SystemExit
class ListMigration(command.Command):
class ListMigration(command.Lister):
_description = _("""List server migrations""")
def get_parser(self, prog_name):
@ -2168,16 +2168,21 @@ class ListMigration(command.Command):
search_opts = {
'host': parsed_args.host,
'server': parsed_args.server,
'status': parsed_args.status,
}
if parsed_args.server:
search_opts['instance_uuid'] = utils.find_resource(
compute_client.servers,
parsed_args.server,
).id
if parsed_args.type:
migration_type = parsed_args.type
# we're using an alias because the default value is confusing
if migration_type == 'cold-migration':
migration_type = 'migration'
search_opts['type'] = migration_type
search_opts['migration_type'] = migration_type
if parsed_args.marker:
if compute_client.api_version < api_versions.APIVersion('2.59'):

View File

@ -4079,7 +4079,6 @@ class TestListMigration(TestServer):
kwargs = {
'status': None,
'host': None,
'server': None,
}
self.migrations_mock.list.assert_called_with(**kwargs)
@ -4106,10 +4105,11 @@ class TestListMigration(TestServer):
kwargs = {
'status': 'migrating',
'host': 'host1',
'server': 'server1',
'type': 'migration',
'instance_uuid': self.server.id,
'migration_type': 'migration',
}
self.servers_mock.get.assert_called_with('server1')
self.migrations_mock.list.assert_called_with(**kwargs)
self.assertEqual(self.MIGRATION_COLUMNS, columns)
@ -4145,7 +4145,6 @@ class TestListMigrationV223(TestListMigration):
kwargs = {
'status': 'migrating',
'host': None,
'server': None,
}
self.migrations_mock.list.assert_called_with(**kwargs)
@ -4194,7 +4193,6 @@ class TestListMigrationV259(TestListMigration):
'limit': 1,
'marker': 'test_kp',
'host': None,
'server': None,
'changes_since': '2019-08-09T08:03:25Z',
}
@ -4303,7 +4301,6 @@ class TestListMigrationV266(TestListMigration):
'limit': 1,
'marker': 'test_kp',
'host': None,
'server': None,
'changes_since': '2019-08-07T08:03:25Z',
'changes_before': '2019-08-09T08:03:25Z',
}
@ -4375,7 +4372,6 @@ class TestListMigrationV280(TestListMigration):
'limit': 1,
'marker': 'test_kp',
'host': None,
'server': None,
'project_id': '0c2accde-644a-45fa-8c10-e76debc7fbc3',
'changes_since': '2019-08-07T08:03:25Z',
'changes_before': "2019-08-09T08:03:25Z",
@ -4438,7 +4434,6 @@ class TestListMigrationV280(TestListMigration):
'limit': 1,
'marker': 'test_kp',
'host': None,
'server': None,
'user_id': 'dd214878-ca12-40fb-b035-fa7d2c1e86d6',
'changes_since': '2019-08-07T08:03:25Z',
'changes_before': "2019-08-09T08:03:25Z",
@ -4500,7 +4495,6 @@ class TestListMigrationV280(TestListMigration):
'status': 'migrating',
'limit': 1,
'host': None,
'server': None,
'project_id': '0c2accde-644a-45fa-8c10-e76debc7fbc3',
'user_id': 'dd214878-ca12-40fb-b035-fa7d2c1e86d6',
'changes_since': '2019-08-07T08:03:25Z',