Skip to content

Commit 71cdb11

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Add 'openstack server migration list --type' option"
2 parents a40d22f + bf35f04 commit 71cdb11

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

openstackclient/compute/v2/server.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,6 +2065,14 @@ def get_parser(self, prog_name):
20652065
metavar='<status>',
20662066
help=_('Filter migrations by status')
20672067
)
2068+
parser.add_argument(
2069+
'--type',
2070+
metavar='<type>',
2071+
choices=[
2072+
'evacuation', 'live-migration', 'cold-migration', 'resize',
2073+
],
2074+
help=_('Filter migrations by type'),
2075+
)
20682076
parser.add_argument(
20692077
'--marker',
20702078
metavar='<marker>',
@@ -2140,10 +2148,6 @@ def print_migrations(self, parsed_args, compute_client, migrations):
21402148
if compute_client.api_version >= api_versions.APIVersion("2.59"):
21412149
columns.insert(0, "UUID")
21422150

2143-
# TODO(brinzhang): It also suppports filter migrations by type
2144-
# since 2.1. https://review.opendev.org/#/c/675117 supported
2145-
# filtering the migrations by 'migration_type' and 'source_compute'
2146-
# in novaclient, that will be added in OSC by follow-up.
21472151
if compute_client.api_version >= api_versions.APIVersion("2.23"):
21482152
columns.insert(0, "Id")
21492153
columns.insert(len(columns) - 2, "Type")
@@ -2168,6 +2172,13 @@ def take_action(self, parsed_args):
21682172
'status': parsed_args.status,
21692173
}
21702174

2175+
if parsed_args.type:
2176+
migration_type = parsed_args.type
2177+
# we're using an alias because the default value is confusing
2178+
if migration_type == 'cold-migration':
2179+
migration_type = 'migration'
2180+
search_opts['type'] = migration_type
2181+
21712182
if parsed_args.marker:
21722183
if compute_client.api_version < api_versions.APIVersion('2.59'):
21732184
msg = _(

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4092,6 +4092,7 @@ def test_server_migration_list(self):
40924092
'--server', 'server1',
40934093
'--host', 'host1',
40944094
'--status', 'migrating',
4095+
'--type', 'cold-migration',
40954096
]
40964097
verifylist = [
40974098
('server', 'server1'),
@@ -4106,6 +4107,7 @@ def test_server_migration_list(self):
41064107
'status': 'migrating',
41074108
'host': 'host1',
41084109
'server': 'server1',
4110+
'type': 'migration',
41094111
}
41104112

41114113
self.migrations_mock.list.assert_called_with(**kwargs)

0 commit comments

Comments
 (0)