diff --git a/novaclient/tests/v1_1/contrib/test_migrations.py b/novaclient/tests/v1_1/contrib/test_migrations.py index 7b49c4cc7..2b4d4cb03 100644 --- a/novaclient/tests/v1_1/contrib/test_migrations.py +++ b/novaclient/tests/v1_1/contrib/test_migrations.py @@ -36,7 +36,7 @@ class MigrationsTest(utils.TestCase): ml = cs.migrations.list('host1', 'finished', 'child1') cs.assert_called('GET', - '/os-migrations?status=finished&host=host1' - '&cell_name=child1') + '/os-migrations?cell_name=child1&host=host1' + '&status=finished') for m in ml: self.assertTrue(isinstance(m, migrations.Migration)) diff --git a/novaclient/tests/v1_1/test_shell.py b/novaclient/tests/v1_1/test_shell.py index 48b08d9b1..dec56b218 100644 --- a/novaclient/tests/v1_1/test_shell.py +++ b/novaclient/tests/v1_1/test_shell.py @@ -1799,5 +1799,5 @@ class ShellTest(utils.TestCase): self.run_command('migration-list --host host1 --cell_name child1 ' '--status finished') self.assert_called('GET', - '/os-migrations?status=finished&host=host1' - '&cell_name=child1') + '/os-migrations?cell_name=child1&host=host1' + '&status=finished') diff --git a/novaclient/v1_1/contrib/migrations.py b/novaclient/v1_1/contrib/migrations.py index fc7c89213..9322849aa 100644 --- a/novaclient/v1_1/contrib/migrations.py +++ b/novaclient/v1_1/contrib/migrations.py @@ -44,7 +44,11 @@ class MigrationManager(base.ManagerWithFind): if cell_name: opts['cell_name'] = cell_name - query_string = "?%s" % urlutils.urlencode(opts) if opts else "" + # Transform the dict to a sequence of two-element tuples in fixed + # order, then the encoded string will be consistent in Python 2&3. + new_opts = sorted(opts.items(), key=lambda x: x[0]) + + query_string = "?%s" % urlutils.urlencode(new_opts) if new_opts else "" return self._list("/os-migrations%s" % query_string, "migrations")