Skip to content

Commit 1a5dd4a

Browse files
committed
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>
1 parent cb6659d commit 1a5dd4a

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

openstackclient/compute/v2/server.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,7 @@ def _show_progress(progress):
20412041
raise SystemExit
20422042

20432043

2044-
class ListMigration(command.Command):
2044+
class ListMigration(command.Lister):
20452045
_description = _("""List server migrations""")
20462046

20472047
def get_parser(self, prog_name):
@@ -2168,16 +2168,21 @@ def take_action(self, parsed_args):
21682168

21692169
search_opts = {
21702170
'host': parsed_args.host,
2171-
'server': parsed_args.server,
21722171
'status': parsed_args.status,
21732172
}
21742173

2174+
if parsed_args.server:
2175+
search_opts['instance_uuid'] = utils.find_resource(
2176+
compute_client.servers,
2177+
parsed_args.server,
2178+
).id
2179+
21752180
if parsed_args.type:
21762181
migration_type = parsed_args.type
21772182
# we're using an alias because the default value is confusing
21782183
if migration_type == 'cold-migration':
21792184
migration_type = 'migration'
2180-
search_opts['type'] = migration_type
2185+
search_opts['migration_type'] = migration_type
21812186

21822187
if parsed_args.marker:
21832188
if compute_client.api_version < api_versions.APIVersion('2.59'):

openstackclient/tests/unit/compute/v2/test_server.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4079,7 +4079,6 @@ def test_server_migration_list_no_options(self):
40794079
kwargs = {
40804080
'status': None,
40814081
'host': None,
4082-
'server': None,
40834082
}
40844083

40854084
self.migrations_mock.list.assert_called_with(**kwargs)
@@ -4106,10 +4105,11 @@ def test_server_migration_list(self):
41064105
kwargs = {
41074106
'status': 'migrating',
41084107
'host': 'host1',
4109-
'server': 'server1',
4110-
'type': 'migration',
4108+
'instance_uuid': self.server.id,
4109+
'migration_type': 'migration',
41114110
}
41124111

4112+
self.servers_mock.get.assert_called_with('server1')
41134113
self.migrations_mock.list.assert_called_with(**kwargs)
41144114

41154115
self.assertEqual(self.MIGRATION_COLUMNS, columns)
@@ -4145,7 +4145,6 @@ def test_server_migration_list(self):
41454145
kwargs = {
41464146
'status': 'migrating',
41474147
'host': None,
4148-
'server': None,
41494148
}
41504149

41514150
self.migrations_mock.list.assert_called_with(**kwargs)
@@ -4194,7 +4193,6 @@ def test_server_migration_list(self):
41944193
'limit': 1,
41954194
'marker': 'test_kp',
41964195
'host': None,
4197-
'server': None,
41984196
'changes_since': '2019-08-09T08:03:25Z',
41994197
}
42004198

@@ -4303,7 +4301,6 @@ def test_server_migration_list_with_changes_before(self):
43034301
'limit': 1,
43044302
'marker': 'test_kp',
43054303
'host': None,
4306-
'server': None,
43074304
'changes_since': '2019-08-07T08:03:25Z',
43084305
'changes_before': '2019-08-09T08:03:25Z',
43094306
}
@@ -4375,7 +4372,6 @@ def test_server_migration_list_with_project(self):
43754372
'limit': 1,
43764373
'marker': 'test_kp',
43774374
'host': None,
4378-
'server': None,
43794375
'project_id': '0c2accde-644a-45fa-8c10-e76debc7fbc3',
43804376
'changes_since': '2019-08-07T08:03:25Z',
43814377
'changes_before': "2019-08-09T08:03:25Z",
@@ -4438,7 +4434,6 @@ def test_server_migration_list_with_user(self):
44384434
'limit': 1,
44394435
'marker': 'test_kp',
44404436
'host': None,
4441-
'server': None,
44424437
'user_id': 'dd214878-ca12-40fb-b035-fa7d2c1e86d6',
44434438
'changes_since': '2019-08-07T08:03:25Z',
44444439
'changes_before': "2019-08-09T08:03:25Z",
@@ -4500,7 +4495,6 @@ def test_server_migration_list_with_project_and_user(self):
45004495
'status': 'migrating',
45014496
'limit': 1,
45024497
'host': None,
4503-
'server': None,
45044498
'project_id': '0c2accde-644a-45fa-8c10-e76debc7fbc3',
45054499
'user_id': 'dd214878-ca12-40fb-b035-fa7d2c1e86d6',
45064500
'changes_since': '2019-08-07T08:03:25Z',

0 commit comments

Comments
 (0)