Add 'openstack server migration list --type' option
Another gap with novaclient closed. Change-Id: Id3ca95ceda6f438fa72496ab9ab15ac09bb64fa5 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
5fd399eaba
commit
bf35f04682
openstackclient
@ -1889,6 +1889,14 @@ class ListMigration(command.Command):
|
|||||||
metavar='<status>',
|
metavar='<status>',
|
||||||
help=_('Filter migrations by status')
|
help=_('Filter migrations by status')
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--type',
|
||||||
|
metavar='<type>',
|
||||||
|
choices=[
|
||||||
|
'evacuation', 'live-migration', 'cold-migration', 'resize',
|
||||||
|
],
|
||||||
|
help=_('Filter migrations by type'),
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--marker',
|
'--marker',
|
||||||
metavar='<marker>',
|
metavar='<marker>',
|
||||||
@ -1964,10 +1972,6 @@ class ListMigration(command.Command):
|
|||||||
if compute_client.api_version >= api_versions.APIVersion("2.59"):
|
if compute_client.api_version >= api_versions.APIVersion("2.59"):
|
||||||
columns.insert(0, "UUID")
|
columns.insert(0, "UUID")
|
||||||
|
|
||||||
# TODO(brinzhang): It also suppports filter migrations by type
|
|
||||||
# since 2.1. https://review.opendev.org/#/c/675117 supported
|
|
||||||
# filtering the migrations by 'migration_type' and 'source_compute'
|
|
||||||
# in novaclient, that will be added in OSC by follow-up.
|
|
||||||
if compute_client.api_version >= api_versions.APIVersion("2.23"):
|
if compute_client.api_version >= api_versions.APIVersion("2.23"):
|
||||||
columns.insert(0, "Id")
|
columns.insert(0, "Id")
|
||||||
columns.insert(len(columns) - 2, "Type")
|
columns.insert(len(columns) - 2, "Type")
|
||||||
@ -1992,6 +1996,13 @@ class ListMigration(command.Command):
|
|||||||
'status': parsed_args.status,
|
'status': parsed_args.status,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
if parsed_args.marker:
|
if parsed_args.marker:
|
||||||
if compute_client.api_version < api_versions.APIVersion('2.59'):
|
if compute_client.api_version < api_versions.APIVersion('2.59'):
|
||||||
msg = _(
|
msg = _(
|
||||||
|
@ -3781,6 +3781,7 @@ class TestListMigration(TestServer):
|
|||||||
'--server', 'server1',
|
'--server', 'server1',
|
||||||
'--host', 'host1',
|
'--host', 'host1',
|
||||||
'--status', 'migrating',
|
'--status', 'migrating',
|
||||||
|
'--type', 'cold-migration',
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('server', 'server1'),
|
('server', 'server1'),
|
||||||
@ -3795,6 +3796,7 @@ class TestListMigration(TestServer):
|
|||||||
'status': 'migrating',
|
'status': 'migrating',
|
||||||
'host': 'host1',
|
'host': 'host1',
|
||||||
'server': 'server1',
|
'server': 'server1',
|
||||||
|
'type': 'migration',
|
||||||
}
|
}
|
||||||
|
|
||||||
self.migrations_mock.list.assert_called_with(**kwargs)
|
self.migrations_mock.list.assert_called_with(**kwargs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user