summaryrefslogtreecommitdiff
path: root/novaclient/v2
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem.os@gmail.com>2019-08-07 09:11:14 -0400
committerMatt Riedemann <mriedem.os@gmail.com>2019-08-08 18:13:33 -0400
commit0e7c99c8ead42326d8660103b0c78df70b775fe4 (patch)
treeac3a7d3392f63a889dbc850eb3124e0c23133654 /novaclient/v2
parente281368c9679b385ecfb05737e614a05a9bab291 (diff)
downloadpython-novaclient-0e7c99c8ead42326d8660103b0c78df70b775fe4.tar.gz
Add --migration-type and --source-compute to migration-list
The GET /os-migrations API take a migration_type and source_compute filter parameter on the request since the v2.0 API. This adds support for specifying those parameters in the "nova migration-list" CLI and related MigrationManager.list() python API binding methods. A functional test is added which will cover the new options on all three of the decorated do_migration_list shell methods with lower bounds on 2.1, 2.59 and 2.66. Since the only type of migration we can safely generate in a single-node CI job is a resize the test does a resize. As such, _pick_alternate_flavor is moved into the base test class for re-use. Implements blueprint more-migration-list-filters Change-Id: I4be9a06df3e0d40d3990d067ce112247a81b45b4
Diffstat (limited to 'novaclient/v2')
-rw-r--r--novaclient/v2/migrations.py36
-rw-r--r--novaclient/v2/shell.py45
2 files changed, 71 insertions, 10 deletions
diff --git a/novaclient/v2/migrations.py b/novaclient/v2/migrations.py
index ab62f2c5..0e94b456 100644
--- a/novaclient/v2/migrations.py
+++ b/novaclient/v2/migrations.py
@@ -28,7 +28,8 @@ class MigrationManager(base.ManagerWithFind):
def _list_base(self, host=None, status=None, instance_uuid=None,
marker=None, limit=None, changes_since=None,
- changes_before=None):
+ changes_before=None, migration_type=None,
+ source_compute=None):
opts = {}
if host:
opts['host'] = host
@@ -44,23 +45,34 @@ class MigrationManager(base.ManagerWithFind):
opts['changes-since'] = changes_since
if changes_before:
opts['changes-before'] = changes_before
+ if migration_type:
+ opts['migration_type'] = migration_type
+ if source_compute:
+ opts['source_compute'] = source_compute
return self._list("/os-migrations", "migrations", filters=opts)
@api_versions.wraps("2.0", "2.58")
- def list(self, host=None, status=None, instance_uuid=None):
+ def list(self, host=None, status=None, instance_uuid=None,
+ migration_type=None, source_compute=None):
"""
Get a list of migrations.
:param host: filter migrations by host name (optional).
:param status: filter migrations by status (optional).
:param instance_uuid: filter migrations by instance uuid (optional).
+ :param migration_type: Filter migrations by type. Valid values are:
+ evacuation, live-migration, migration, resize
+ :param source_compute: Filter migrations by source compute host name.
"""
return self._list_base(host=host, status=status,
- instance_uuid=instance_uuid)
+ instance_uuid=instance_uuid,
+ migration_type=migration_type,
+ source_compute=source_compute)
@api_versions.wraps("2.59", "2.65")
def list(self, host=None, status=None, instance_uuid=None,
- marker=None, limit=None, changes_since=None):
+ marker=None, limit=None, changes_since=None,
+ migration_type=None, source_compute=None):
"""
Get a list of migrations.
:param host: filter migrations by host name (optional).
@@ -76,16 +88,21 @@ class MigrationManager(base.ManagerWithFind):
:param changes_since: only return migrations changed later or equal
to a certain point of time. The provided time should be an ISO 8061
formatted time. e.g. 2016-03-04T06:27:59Z . (optional).
+ :param migration_type: Filter migrations by type. Valid values are:
+ evacuation, live-migration, migration, resize
+ :param source_compute: Filter migrations by source compute host name.
"""
return self._list_base(host=host, status=status,
instance_uuid=instance_uuid,
marker=marker, limit=limit,
- changes_since=changes_since)
+ changes_since=changes_since,
+ migration_type=migration_type,
+ source_compute=source_compute)
@api_versions.wraps("2.66")
def list(self, host=None, status=None, instance_uuid=None,
marker=None, limit=None, changes_since=None,
- changes_before=None):
+ changes_before=None, migration_type=None, source_compute=None):
"""
Get a list of migrations.
:param host: filter migrations by host name (optional).
@@ -104,9 +121,14 @@ class MigrationManager(base.ManagerWithFind):
:param changes_before: Only return migrations changed earlier or
equal to a certain point of time. The provided time should be an ISO
8061 formatted time. e.g. 2016-03-05T06:27:59Z . (optional).
+ :param migration_type: Filter migrations by type. Valid values are:
+ evacuation, live-migration, migration, resize
+ :param source_compute: Filter migrations by source compute host name.
"""
return self._list_base(host=host, status=status,
instance_uuid=instance_uuid,
marker=marker, limit=limit,
changes_since=changes_since,
- changes_before=changes_before)
+ changes_before=changes_before,
+ migration_type=migration_type,
+ source_compute=source_compute)
diff --git a/novaclient/v2/shell.py b/novaclient/v2/shell.py
index 7b9c0206..34dea57f 100644
--- a/novaclient/v2/shell.py
+++ b/novaclient/v2/shell.py
@@ -5422,10 +5422,23 @@ def _print_migrations(cs, migrations):
dest='status',
metavar='<status>',
help=_('Fetch migrations for the given status.'))
+@utils.arg(
+ '--migration-type',
+ dest='migration_type',
+ metavar='<migration_type>',
+ help=_('Filter migrations by type. Valid values are: evacuation, '
+ 'live-migration, migration, resize'))
+@utils.arg(
+ '--source-compute',
+ dest='source_compute',
+ metavar='<source_compute>',
+ help=_('Filter migrations by source compute host name.'))
def do_migration_list(cs, args):
"""Print a list of migrations."""
migrations = cs.migrations.list(args.host, args.status,
- instance_uuid=args.instance_uuid)
+ instance_uuid=args.instance_uuid,
+ migration_type=args.migration_type,
+ source_compute=args.source_compute)
_print_migrations(cs, migrations)
@@ -5446,6 +5459,17 @@ def do_migration_list(cs, args):
metavar='<status>',
help=_('Fetch migrations for the given status.'))
@utils.arg(
+ '--migration-type',
+ dest='migration_type',
+ metavar='<migration_type>',
+ help=_('Filter migrations by type. Valid values are: evacuation, '
+ 'live-migration, migration, resize'))
+@utils.arg(
+ '--source-compute',
+ dest='source_compute',
+ metavar='<source_compute>',
+ help=_('Filter migrations by source compute host name.'))
+@utils.arg(
'--marker',
dest='marker',
metavar='<marker>',
@@ -5483,7 +5507,9 @@ def do_migration_list(cs, args):
migrations = cs.migrations.list(args.host, args.status,
instance_uuid=args.instance_uuid,
marker=args.marker, limit=args.limit,
- changes_since=args.changes_since)
+ changes_since=args.changes_since,
+ migration_type=args.migration_type,
+ source_compute=args.source_compute)
# TODO(yikun): Output a "Marker" column if there is a next link?
_print_migrations(cs, migrations)
@@ -5505,6 +5531,17 @@ def do_migration_list(cs, args):
metavar='<status>',
help=_('Fetch migrations for the given status.'))
@utils.arg(
+ '--migration-type',
+ dest='migration_type',
+ metavar='<migration_type>',
+ help=_('Filter migrations by type. Valid values are: evacuation, '
+ 'live-migration, migration, resize'))
+@utils.arg(
+ '--source-compute',
+ dest='source_compute',
+ metavar='<source_compute>',
+ help=_('Filter migrations by source compute host name.'))
+@utils.arg(
'--marker',
dest='marker',
metavar='<marker>',
@@ -5559,7 +5596,9 @@ def do_migration_list(cs, args):
instance_uuid=args.instance_uuid,
marker=args.marker, limit=args.limit,
changes_since=args.changes_since,
- changes_before=args.changes_before)
+ changes_before=args.changes_before,
+ migration_type=args.migration_type,
+ source_compute=args.source_compute)
_print_migrations(cs, migrations)