Finish switching server migration to sdk
Change-Id: Ic0e6dfdc986989599bfc73b8c274631232161c25
This commit is contained in:
parent
88672d22c4
commit
d1c1c36af1
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from novaclient import api_versions
|
|
||||||
from openstack import utils as sdk_utils
|
from openstack import utils as sdk_utils
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
@ -256,7 +255,7 @@ class ListMigration(command.Lister):
|
|||||||
|
|
||||||
|
|
||||||
def _get_migration_by_uuid(compute_client, server_id, migration_uuid):
|
def _get_migration_by_uuid(compute_client, server_id, migration_uuid):
|
||||||
for migration in compute_client.server_migrations.list(server_id):
|
for migration in compute_client.server_migrations(server_id):
|
||||||
if migration.uuid == migration_uuid:
|
if migration.uuid == migration_uuid:
|
||||||
return migration
|
return migration
|
||||||
break
|
break
|
||||||
@ -290,9 +289,9 @@ class ShowMigration(command.ShowOne):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
compute_client = self.app.client_manager.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
|
|
||||||
if compute_client.api_version < api_versions.APIVersion('2.24'):
|
if not sdk_utils.supports_microversion(compute_client, '2.24'):
|
||||||
msg = _(
|
msg = _(
|
||||||
'--os-compute-api-version 2.24 or greater is required to '
|
'--os-compute-api-version 2.24 or greater is required to '
|
||||||
'support the server migration show command'
|
'support the server migration show command'
|
||||||
@ -308,16 +307,16 @@ class ShowMigration(command.ShowOne):
|
|||||||
)
|
)
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
if compute_client.api_version < api_versions.APIVersion('2.59'):
|
if not sdk_utils.supports_microversion(compute_client, '2.59'):
|
||||||
msg = _(
|
msg = _(
|
||||||
'--os-compute-api-version 2.59 or greater is required to '
|
'--os-compute-api-version 2.59 or greater is required to '
|
||||||
'retrieve server migrations by UUID'
|
'retrieve server migrations by UUID'
|
||||||
)
|
)
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
server = utils.find_resource(
|
server = compute_client.find_server(
|
||||||
compute_client.servers,
|
|
||||||
parsed_args.server,
|
parsed_args.server,
|
||||||
|
ignore_missing=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
# the nova API doesn't currently allow retrieval by UUID but it's a
|
# the nova API doesn't currently allow retrieval by UUID but it's a
|
||||||
@ -328,11 +327,13 @@ class ShowMigration(command.ShowOne):
|
|||||||
compute_client, server.id, parsed_args.migration,
|
compute_client, server.id, parsed_args.migration,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
server_migration = compute_client.server_migrations.get(
|
server_migration = compute_client.get_server_migration(
|
||||||
server.id, parsed_args.migration,
|
server.id,
|
||||||
|
parsed_args.migration,
|
||||||
|
ignore_missing=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
columns = (
|
column_headers = (
|
||||||
'ID',
|
'ID',
|
||||||
'Server UUID',
|
'Server UUID',
|
||||||
'Status',
|
'Status',
|
||||||
@ -351,14 +352,35 @@ class ShowMigration(command.ShowOne):
|
|||||||
'Updated At',
|
'Updated At',
|
||||||
)
|
)
|
||||||
|
|
||||||
if compute_client.api_version >= api_versions.APIVersion('2.59'):
|
columns = (
|
||||||
columns += ('UUID',)
|
'id',
|
||||||
|
'server_id',
|
||||||
|
'status',
|
||||||
|
'source_compute',
|
||||||
|
'source_node',
|
||||||
|
'dest_compute',
|
||||||
|
'dest_host',
|
||||||
|
'dest_node',
|
||||||
|
'memory_total_bytes',
|
||||||
|
'memory_processed_bytes',
|
||||||
|
'memory_remaining_bytes',
|
||||||
|
'disk_total_bytes',
|
||||||
|
'disk_processed_bytes',
|
||||||
|
'disk_remaining_bytes',
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
)
|
||||||
|
|
||||||
if compute_client.api_version >= api_versions.APIVersion('2.80'):
|
if sdk_utils.supports_microversion(compute_client, '2.59'):
|
||||||
columns += ('User ID', 'Project ID')
|
column_headers += ('UUID',)
|
||||||
|
columns += ('uuid',)
|
||||||
|
|
||||||
|
if sdk_utils.supports_microversion(compute_client, '2.80'):
|
||||||
|
column_headers += ('User ID', 'Project ID')
|
||||||
|
columns += ('user_id', 'project_id')
|
||||||
|
|
||||||
data = utils.get_item_properties(server_migration, columns)
|
data = utils.get_item_properties(server_migration, columns)
|
||||||
return columns, data
|
return column_headers, data
|
||||||
|
|
||||||
|
|
||||||
class AbortMigration(command.Command):
|
class AbortMigration(command.Command):
|
||||||
@ -382,9 +404,9 @@ class AbortMigration(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
compute_client = self.app.client_manager.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
|
|
||||||
if compute_client.api_version < api_versions.APIVersion('2.24'):
|
if not sdk_utils.supports_microversion(compute_client, '2.24'):
|
||||||
msg = _(
|
msg = _(
|
||||||
'--os-compute-api-version 2.24 or greater is required to '
|
'--os-compute-api-version 2.24 or greater is required to '
|
||||||
'support the server migration abort command'
|
'support the server migration abort command'
|
||||||
@ -400,16 +422,16 @@ class AbortMigration(command.Command):
|
|||||||
)
|
)
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
if compute_client.api_version < api_versions.APIVersion('2.59'):
|
if not sdk_utils.supports_microversion(compute_client, '2.59'):
|
||||||
msg = _(
|
msg = _(
|
||||||
'--os-compute-api-version 2.59 or greater is required to '
|
'--os-compute-api-version 2.59 or greater is required to '
|
||||||
'abort server migrations by UUID'
|
'abort server migrations by UUID'
|
||||||
)
|
)
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
server = utils.find_resource(
|
server = compute_client.find_server(
|
||||||
compute_client.servers,
|
|
||||||
parsed_args.server,
|
parsed_args.server,
|
||||||
|
ignore_missing=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
# the nova API doesn't currently allow retrieval by UUID but it's a
|
# the nova API doesn't currently allow retrieval by UUID but it's a
|
||||||
@ -421,8 +443,10 @@ class AbortMigration(command.Command):
|
|||||||
compute_client, server.id, parsed_args.migration,
|
compute_client, server.id, parsed_args.migration,
|
||||||
).id
|
).id
|
||||||
|
|
||||||
compute_client.server_migrations.live_migration_abort(
|
compute_client.abort_server_migration(
|
||||||
server.id, migration_id,
|
migration_id,
|
||||||
|
server.id,
|
||||||
|
ignore_missing=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -447,9 +471,9 @@ class ForceCompleteMigration(command.Command):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
compute_client = self.app.client_manager.compute
|
compute_client = self.app.client_manager.sdk_connection.compute
|
||||||
|
|
||||||
if compute_client.api_version < api_versions.APIVersion('2.22'):
|
if not sdk_utils.supports_microversion(compute_client, '2.22'):
|
||||||
msg = _(
|
msg = _(
|
||||||
'--os-compute-api-version 2.22 or greater is required to '
|
'--os-compute-api-version 2.22 or greater is required to '
|
||||||
'support the server migration force complete command'
|
'support the server migration force complete command'
|
||||||
@ -465,16 +489,16 @@ class ForceCompleteMigration(command.Command):
|
|||||||
)
|
)
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
if compute_client.api_version < api_versions.APIVersion('2.59'):
|
if not sdk_utils.supports_microversion(compute_client, '2.59'):
|
||||||
msg = _(
|
msg = _(
|
||||||
'--os-compute-api-version 2.59 or greater is required to '
|
'--os-compute-api-version 2.59 or greater is required to '
|
||||||
'abort server migrations by UUID'
|
'abort server migrations by UUID'
|
||||||
)
|
)
|
||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
server = utils.find_resource(
|
server = compute_client.find_server(
|
||||||
compute_client.servers,
|
|
||||||
parsed_args.server,
|
parsed_args.server,
|
||||||
|
ignore_missing=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
# the nova API doesn't currently allow retrieval by UUID but it's a
|
# the nova API doesn't currently allow retrieval by UUID but it's a
|
||||||
@ -486,6 +510,6 @@ class ForceCompleteMigration(command.Command):
|
|||||||
compute_client, server.id, parsed_args.migration,
|
compute_client, server.id, parsed_args.migration,
|
||||||
).id
|
).id
|
||||||
|
|
||||||
compute_client.server_migrations.live_migrate_force_complete(
|
compute_client.force_complete_server_migration(
|
||||||
server.id, migration_id,
|
migration_id, server.id
|
||||||
)
|
)
|
||||||
|
@ -25,6 +25,7 @@ from openstack.compute.v2 import migration as _migration
|
|||||||
from openstack.compute.v2 import server as _server
|
from openstack.compute.v2 import server as _server
|
||||||
from openstack.compute.v2 import server_group as _server_group
|
from openstack.compute.v2 import server_group as _server_group
|
||||||
from openstack.compute.v2 import server_interface as _server_interface
|
from openstack.compute.v2 import server_interface as _server_interface
|
||||||
|
from openstack.compute.v2 import server_migration as _server_migration
|
||||||
from openstack.compute.v2 import service
|
from openstack.compute.v2 import service
|
||||||
from openstack.compute.v2 import volume_attachment
|
from openstack.compute.v2 import volume_attachment
|
||||||
|
|
||||||
@ -1483,57 +1484,61 @@ def create_migrations(attrs=None, count=2):
|
|||||||
return migrations
|
return migrations
|
||||||
|
|
||||||
|
|
||||||
class FakeServerMigration(object):
|
def create_one_server_migration(attrs=None):
|
||||||
"""Fake one or more server migrations."""
|
"""Create a fake server migration.
|
||||||
|
|
||||||
@staticmethod
|
:param dict attrs: A dictionary with all attributes
|
||||||
def create_one_server_migration(attrs=None, methods=None):
|
:return A fake openstack.compute.v2.server_migration.ServerMigration object
|
||||||
"""Create a fake server migration.
|
"""
|
||||||
|
attrs = attrs or {}
|
||||||
|
|
||||||
:param dict attrs:
|
# Set default attributes.
|
||||||
A dictionary with all attributes
|
|
||||||
:param dict methods:
|
|
||||||
A dictionary with all methods
|
|
||||||
:return:
|
|
||||||
A FakeResource object, with id, type, and so on
|
|
||||||
"""
|
|
||||||
attrs = attrs or {}
|
|
||||||
methods = methods or {}
|
|
||||||
|
|
||||||
# Set default attributes.
|
migration_info = {
|
||||||
|
"created_at": "2016-01-29T13:42:02.000000",
|
||||||
|
"dest_compute": "compute2",
|
||||||
|
"dest_host": "1.2.3.4",
|
||||||
|
"dest_node": "node2",
|
||||||
|
"id": random.randint(1, 999),
|
||||||
|
"server_uuid": uuid.uuid4().hex,
|
||||||
|
"source_compute": "compute1",
|
||||||
|
"source_node": "node1",
|
||||||
|
"status": "running",
|
||||||
|
"memory_total_bytes": random.randint(1, 99999),
|
||||||
|
"memory_processed_bytes": random.randint(1, 99999),
|
||||||
|
"memory_remaining_bytes": random.randint(1, 99999),
|
||||||
|
"disk_total_bytes": random.randint(1, 99999),
|
||||||
|
"disk_processed_bytes": random.randint(1, 99999),
|
||||||
|
"disk_remaining_bytes": random.randint(1, 99999),
|
||||||
|
"updated_at": "2016-01-29T13:42:02.000000",
|
||||||
|
# added in 2.59
|
||||||
|
"uuid": uuid.uuid4().hex,
|
||||||
|
# added in 2.80
|
||||||
|
"user_id": uuid.uuid4().hex,
|
||||||
|
"project_id": uuid.uuid4().hex,
|
||||||
|
}
|
||||||
|
|
||||||
migration_info = {
|
# Overwrite default attributes.
|
||||||
"created_at": "2016-01-29T13:42:02.000000",
|
migration_info.update(attrs)
|
||||||
"dest_compute": "compute2",
|
|
||||||
"dest_host": "1.2.3.4",
|
|
||||||
"dest_node": "node2",
|
|
||||||
"id": random.randint(1, 999),
|
|
||||||
"server_uuid": uuid.uuid4().hex,
|
|
||||||
"source_compute": "compute1",
|
|
||||||
"source_node": "node1",
|
|
||||||
"status": "running",
|
|
||||||
"memory_total_bytes": random.randint(1, 99999),
|
|
||||||
"memory_processed_bytes": random.randint(1, 99999),
|
|
||||||
"memory_remaining_bytes": random.randint(1, 99999),
|
|
||||||
"disk_total_bytes": random.randint(1, 99999),
|
|
||||||
"disk_processed_bytes": random.randint(1, 99999),
|
|
||||||
"disk_remaining_bytes": random.randint(1, 99999),
|
|
||||||
"updated_at": "2016-01-29T13:42:02.000000",
|
|
||||||
# added in 2.59
|
|
||||||
"uuid": uuid.uuid4().hex,
|
|
||||||
# added in 2.80
|
|
||||||
"user_id": uuid.uuid4().hex,
|
|
||||||
"project_id": uuid.uuid4().hex,
|
|
||||||
}
|
|
||||||
|
|
||||||
# Overwrite default attributes.
|
migration = _server_migration.ServerMigration(**migration_info)
|
||||||
migration_info.update(attrs)
|
return migration
|
||||||
|
|
||||||
migration = fakes.FakeResource(
|
|
||||||
info=copy.deepcopy(migration_info),
|
def create_server_migrations(attrs=None, methods=None, count=2):
|
||||||
methods=methods,
|
"""Create multiple server migrations.
|
||||||
loaded=True)
|
|
||||||
return migration
|
:param dict attrs: A dictionary with all attributes
|
||||||
|
:param int count: The number of server migrations to fake
|
||||||
|
:return A list of fake
|
||||||
|
openstack.compute.v2.server_migration.ServerMigration objects
|
||||||
|
"""
|
||||||
|
migrations = []
|
||||||
|
for i in range(0, count):
|
||||||
|
migrations.append(
|
||||||
|
create_one_server_migration(attrs, methods))
|
||||||
|
|
||||||
|
return migrations
|
||||||
|
|
||||||
|
|
||||||
class FakeVolumeAttachment(object):
|
class FakeVolumeAttachment(object):
|
||||||
|
@ -40,6 +40,18 @@ class TestServerMigration(compute_fakes.TestComputev2):
|
|||||||
self.app.client_manager.sdk_connection.compute = mock.Mock()
|
self.app.client_manager.sdk_connection.compute = mock.Mock()
|
||||||
self.sdk_client = self.app.client_manager.sdk_connection.compute
|
self.sdk_client = self.app.client_manager.sdk_connection.compute
|
||||||
|
|
||||||
|
patcher = mock.patch.object(
|
||||||
|
sdk_utils, 'supports_microversion', return_value=True)
|
||||||
|
self.addCleanup(patcher.stop)
|
||||||
|
self.supports_microversion_mock = patcher.start()
|
||||||
|
|
||||||
|
def _set_mock_microversion(self, mock_v):
|
||||||
|
"""Set a specific microversion for the mock supports_microversion()."""
|
||||||
|
self.supports_microversion_mock.reset_mock(return_value=True)
|
||||||
|
self.supports_microversion_mock.side_effect = (
|
||||||
|
lambda _, v:
|
||||||
|
api_versions.APIVersion(v) <= api_versions.APIVersion(mock_v))
|
||||||
|
|
||||||
|
|
||||||
class TestListMigration(TestServerMigration):
|
class TestListMigration(TestServerMigration):
|
||||||
"""Test fetch all migrations."""
|
"""Test fetch all migrations."""
|
||||||
@ -51,14 +63,16 @@ class TestListMigration(TestServerMigration):
|
|||||||
]
|
]
|
||||||
|
|
||||||
MIGRATION_FIELDS = [
|
MIGRATION_FIELDS = [
|
||||||
'source_node', 'dest_node', 'source_compute', 'dest_compute',
|
'source_node', 'dest_node', 'source_compute',
|
||||||
'dest_host', 'status', 'server_id', 'old_flavor_id',
|
'dest_compute', 'dest_host', 'status', 'server_id', 'old_flavor_id',
|
||||||
'new_flavor_id', 'created_at', 'updated_at'
|
'new_flavor_id', 'created_at', 'updated_at'
|
||||||
]
|
]
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
|
self._set_mock_microversion('2.1')
|
||||||
|
|
||||||
self.server = compute_fakes.FakeServer.create_one_sdk_server()
|
self.server = compute_fakes.FakeServer.create_one_sdk_server()
|
||||||
self.sdk_client.find_server.return_value = self.server
|
self.sdk_client.find_server.return_value = self.server
|
||||||
|
|
||||||
@ -71,20 +85,6 @@ class TestListMigration(TestServerMigration):
|
|||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = server_migration.ListMigration(self.app, None)
|
self.cmd = server_migration.ListMigration(self.app, None)
|
||||||
|
|
||||||
patcher = mock.patch.object(
|
|
||||||
sdk_utils, 'supports_microversion', return_value=True)
|
|
||||||
self.addCleanup(patcher.stop)
|
|
||||||
self.supports_microversion_mock = patcher.start()
|
|
||||||
self._set_mock_microversion(
|
|
||||||
self.app.client_manager.compute.api_version.get_string())
|
|
||||||
|
|
||||||
def _set_mock_microversion(self, mock_v):
|
|
||||||
"""Set a specific microversion for the mock supports_microversion()."""
|
|
||||||
self.supports_microversion_mock.reset_mock(return_value=True)
|
|
||||||
self.supports_microversion_mock.side_effect = (
|
|
||||||
lambda _, v:
|
|
||||||
api_versions.APIVersion(v) <= api_versions.APIVersion(mock_v))
|
|
||||||
|
|
||||||
def test_server_migration_list_no_options(self):
|
def test_server_migration_list_no_options(self):
|
||||||
arglist = []
|
arglist = []
|
||||||
verifylist = []
|
verifylist = []
|
||||||
@ -600,12 +600,15 @@ class TestServerMigrationShow(TestServerMigration):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.server = compute_fakes.FakeServer.create_one_server()
|
self.server = compute_fakes.FakeServer.create_one_sdk_server()
|
||||||
self.servers_mock.get.return_value = self.server
|
self.sdk_client.find_server.return_value = self.server
|
||||||
|
|
||||||
self.server_migration = compute_fakes.FakeServerMigration\
|
self.server_migration = compute_fakes.create_one_server_migration()
|
||||||
.create_one_server_migration()
|
self.sdk_client.get_server_migration.return_value =\
|
||||||
self.server_migrations_mock.get.return_value = self.server_migration
|
self.server_migration
|
||||||
|
self.sdk_client.server_migrations.return_value = iter(
|
||||||
|
[self.server_migration]
|
||||||
|
)
|
||||||
|
|
||||||
self.columns = (
|
self.columns = (
|
||||||
'ID',
|
'ID',
|
||||||
@ -628,7 +631,7 @@ class TestServerMigrationShow(TestServerMigration):
|
|||||||
|
|
||||||
self.data = (
|
self.data = (
|
||||||
self.server_migration.id,
|
self.server_migration.id,
|
||||||
self.server_migration.server_uuid,
|
self.server_migration.server_id,
|
||||||
self.server_migration.status,
|
self.server_migration.status,
|
||||||
self.server_migration.source_compute,
|
self.server_migration.source_compute,
|
||||||
self.server_migration.source_node,
|
self.server_migration.source_node,
|
||||||
@ -661,19 +664,18 @@ class TestServerMigrationShow(TestServerMigration):
|
|||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, data)
|
self.assertEqual(self.data, data)
|
||||||
|
|
||||||
self.servers_mock.get.assert_called_with(self.server.id)
|
self.sdk_client.find_server.assert_called_with(
|
||||||
self.server_migrations_mock.get.assert_called_with(
|
self.server.id, ignore_missing=False)
|
||||||
self.server.id, '2',)
|
self.sdk_client.get_server_migration.assert_called_with(
|
||||||
|
self.server.id, '2', ignore_missing=False)
|
||||||
|
|
||||||
def test_server_migration_show(self):
|
def test_server_migration_show(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.24')
|
||||||
'2.24')
|
|
||||||
|
|
||||||
self._test_server_migration_show()
|
self._test_server_migration_show()
|
||||||
|
|
||||||
def test_server_migration_show_v259(self):
|
def test_server_migration_show_v259(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.59')
|
||||||
'2.59')
|
|
||||||
|
|
||||||
self.columns += ('UUID',)
|
self.columns += ('UUID',)
|
||||||
self.data += (self.server_migration.uuid,)
|
self.data += (self.server_migration.uuid,)
|
||||||
@ -681,8 +683,7 @@ class TestServerMigrationShow(TestServerMigration):
|
|||||||
self._test_server_migration_show()
|
self._test_server_migration_show()
|
||||||
|
|
||||||
def test_server_migration_show_v280(self):
|
def test_server_migration_show_v280(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.80')
|
||||||
'2.80')
|
|
||||||
|
|
||||||
self.columns += ('UUID', 'User ID', 'Project ID')
|
self.columns += ('UUID', 'User ID', 'Project ID')
|
||||||
self.data += (
|
self.data += (
|
||||||
@ -694,8 +695,7 @@ class TestServerMigrationShow(TestServerMigration):
|
|||||||
self._test_server_migration_show()
|
self._test_server_migration_show()
|
||||||
|
|
||||||
def test_server_migration_show_pre_v224(self):
|
def test_server_migration_show_pre_v224(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.23')
|
||||||
'2.23')
|
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
self.server.id,
|
self.server.id,
|
||||||
@ -713,9 +713,11 @@ class TestServerMigrationShow(TestServerMigration):
|
|||||||
str(ex))
|
str(ex))
|
||||||
|
|
||||||
def test_server_migration_show_by_uuid(self):
|
def test_server_migration_show_by_uuid(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.59')
|
||||||
'2.59')
|
|
||||||
self.server_migrations_mock.list.return_value = [self.server_migration]
|
self.sdk_client.server_migrations.return_value = iter(
|
||||||
|
[self.server_migration]
|
||||||
|
)
|
||||||
|
|
||||||
self.columns += ('UUID',)
|
self.columns += ('UUID',)
|
||||||
self.data += (self.server_migration.uuid,)
|
self.data += (self.server_migration.uuid,)
|
||||||
@ -732,14 +734,14 @@ class TestServerMigrationShow(TestServerMigration):
|
|||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, data)
|
self.assertEqual(self.data, data)
|
||||||
|
|
||||||
self.servers_mock.get.assert_called_with(self.server.id)
|
self.sdk_client.find_server.assert_called_with(
|
||||||
self.server_migrations_mock.list.assert_called_with(self.server.id)
|
self.server.id, ignore_missing=False)
|
||||||
self.server_migrations_mock.get.assert_not_called()
|
self.sdk_client.server_migrations.assert_called_with(self.server.id)
|
||||||
|
self.sdk_client.get_server_migration.assert_not_called()
|
||||||
|
|
||||||
def test_server_migration_show_by_uuid_no_matches(self):
|
def test_server_migration_show_by_uuid_no_matches(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.59')
|
||||||
'2.59')
|
self.sdk_client.server_migrations.return_value = iter([])
|
||||||
self.server_migrations_mock.list.return_value = []
|
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
self.server.id,
|
self.server.id,
|
||||||
@ -757,8 +759,7 @@ class TestServerMigrationShow(TestServerMigration):
|
|||||||
str(ex))
|
str(ex))
|
||||||
|
|
||||||
def test_server_migration_show_by_uuid_pre_v259(self):
|
def test_server_migration_show_by_uuid_pre_v259(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.58')
|
||||||
'2.58')
|
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
self.server.id,
|
self.server.id,
|
||||||
@ -776,8 +777,7 @@ class TestServerMigrationShow(TestServerMigration):
|
|||||||
str(ex))
|
str(ex))
|
||||||
|
|
||||||
def test_server_migration_show_invalid_id(self):
|
def test_server_migration_show_invalid_id(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.24')
|
||||||
'2.24')
|
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
self.server.id,
|
self.server.id,
|
||||||
@ -800,17 +800,16 @@ class TestServerMigrationAbort(TestServerMigration):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.server = compute_fakes.FakeServer.create_one_server()
|
self.server = compute_fakes.FakeServer.create_one_sdk_server()
|
||||||
|
|
||||||
# Return value for utils.find_resource for server.
|
# Return value for utils.find_resource for server.
|
||||||
self.servers_mock.get.return_value = self.server
|
self.sdk_client.find_server.return_value = self.server
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = server_migration.AbortMigration(self.app, None)
|
self.cmd = server_migration.AbortMigration(self.app, None)
|
||||||
|
|
||||||
def test_migration_abort(self):
|
def test_migration_abort(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.24')
|
||||||
'2.24')
|
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
self.server.id,
|
self.server.id,
|
||||||
@ -821,14 +820,14 @@ class TestServerMigrationAbort(TestServerMigration):
|
|||||||
|
|
||||||
result = self.cmd.take_action(parsed_args)
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.servers_mock.get.assert_called_with(self.server.id)
|
self.sdk_client.find_server.assert_called_with(
|
||||||
self.server_migrations_mock.live_migration_abort.assert_called_with(
|
self.server.id, ignore_missing=False)
|
||||||
self.server.id, '2',)
|
self.sdk_client.abort_server_migration.assert_called_with(
|
||||||
|
'2', self.server.id, ignore_missing=False)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
def test_migration_abort_pre_v224(self):
|
def test_migration_abort_pre_v224(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.23')
|
||||||
'2.23')
|
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
self.server.id,
|
self.server.id,
|
||||||
@ -846,12 +845,12 @@ class TestServerMigrationAbort(TestServerMigration):
|
|||||||
str(ex))
|
str(ex))
|
||||||
|
|
||||||
def test_server_migration_abort_by_uuid(self):
|
def test_server_migration_abort_by_uuid(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.59')
|
||||||
'2.59')
|
|
||||||
|
|
||||||
self.server_migration = compute_fakes.FakeServerMigration\
|
self.server_migration = compute_fakes.create_one_server_migration()
|
||||||
.create_one_server_migration()
|
self.sdk_client.server_migrations.return_value = iter(
|
||||||
self.server_migrations_mock.list.return_value = [self.server_migration]
|
[self.server_migration]
|
||||||
|
)
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
self.server.id,
|
self.server.id,
|
||||||
@ -862,17 +861,19 @@ class TestServerMigrationAbort(TestServerMigration):
|
|||||||
|
|
||||||
result = self.cmd.take_action(parsed_args)
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.servers_mock.get.assert_called_with(self.server.id)
|
self.sdk_client.find_server.assert_called_with(
|
||||||
self.server_migrations_mock.list.assert_called_with(self.server.id)
|
self.server.id, ignore_missing=False)
|
||||||
self.server_migrations_mock.live_migration_abort.assert_called_with(
|
self.sdk_client.server_migrations.assert_called_with(self.server.id)
|
||||||
self.server.id, self.server_migration.id)
|
self.sdk_client.abort_server_migration.assert_called_with(
|
||||||
|
self.server_migration.id, self.server.id, ignore_missing=False)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
def test_server_migration_abort_by_uuid_no_matches(self):
|
def test_server_migration_abort_by_uuid_no_matches(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.59')
|
||||||
'2.59')
|
|
||||||
|
|
||||||
self.server_migrations_mock.list.return_value = []
|
self.sdk_client.server_migrations.return_value = iter(
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
self.server.id,
|
self.server.id,
|
||||||
@ -890,8 +891,7 @@ class TestServerMigrationAbort(TestServerMigration):
|
|||||||
str(ex))
|
str(ex))
|
||||||
|
|
||||||
def test_server_migration_abort_by_uuid_pre_v259(self):
|
def test_server_migration_abort_by_uuid_pre_v259(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.58')
|
||||||
'2.58')
|
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
self.server.id,
|
self.server.id,
|
||||||
@ -914,17 +914,16 @@ class TestServerMigrationForceComplete(TestServerMigration):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.server = compute_fakes.FakeServer.create_one_server()
|
self.server = compute_fakes.FakeServer.create_one_sdk_server()
|
||||||
|
|
||||||
# Return value for utils.find_resource for server.
|
# Return value for utils.find_resource for server.
|
||||||
self.servers_mock.get.return_value = self.server
|
self.sdk_client.find_server.return_value = self.server
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = server_migration.ForceCompleteMigration(self.app, None)
|
self.cmd = server_migration.ForceCompleteMigration(self.app, None)
|
||||||
|
|
||||||
def test_migration_force_complete(self):
|
def test_migration_force_complete(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.22')
|
||||||
'2.22')
|
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
self.server.id,
|
self.server.id,
|
||||||
@ -935,14 +934,14 @@ class TestServerMigrationForceComplete(TestServerMigration):
|
|||||||
|
|
||||||
result = self.cmd.take_action(parsed_args)
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.servers_mock.get.assert_called_with(self.server.id)
|
self.sdk_client.find_server.assert_called_with(
|
||||||
self.server_migrations_mock.live_migrate_force_complete\
|
self.server.id, ignore_missing=False)
|
||||||
.assert_called_with(self.server.id, '2',)
|
self.sdk_client.force_complete_server_migration\
|
||||||
|
.assert_called_with('2', self.server.id)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
def test_migration_force_complete_pre_v222(self):
|
def test_migration_force_complete_pre_v222(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.21')
|
||||||
'2.21')
|
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
self.server.id,
|
self.server.id,
|
||||||
@ -960,12 +959,12 @@ class TestServerMigrationForceComplete(TestServerMigration):
|
|||||||
str(ex))
|
str(ex))
|
||||||
|
|
||||||
def test_server_migration_force_complete_by_uuid(self):
|
def test_server_migration_force_complete_by_uuid(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.59')
|
||||||
'2.59')
|
|
||||||
|
|
||||||
self.server_migration = compute_fakes.FakeServerMigration\
|
self.server_migration = compute_fakes.create_one_server_migration()
|
||||||
.create_one_server_migration()
|
self.sdk_client.server_migrations.return_value = iter(
|
||||||
self.server_migrations_mock.list.return_value = [self.server_migration]
|
[self.server_migration]
|
||||||
|
)
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
self.server.id,
|
self.server.id,
|
||||||
@ -976,17 +975,17 @@ class TestServerMigrationForceComplete(TestServerMigration):
|
|||||||
|
|
||||||
result = self.cmd.take_action(parsed_args)
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.servers_mock.get.assert_called_with(self.server.id)
|
self.sdk_client.find_server.assert_called_with(
|
||||||
self.server_migrations_mock.list.assert_called_with(self.server.id)
|
self.server.id, ignore_missing=False)
|
||||||
self.server_migrations_mock.live_migrate_force_complete\
|
self.sdk_client.server_migrations.assert_called_with(self.server.id)
|
||||||
.assert_called_with(self.server.id, self.server_migration.id)
|
self.sdk_client.force_complete_server_migration.\
|
||||||
|
assert_called_with(self.server_migration.id, self.server.id)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
def test_server_migration_force_complete_by_uuid_no_matches(self):
|
def test_server_migration_force_complete_by_uuid_no_matches(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.59')
|
||||||
'2.59')
|
|
||||||
|
|
||||||
self.server_migrations_mock.list.return_value = []
|
self.sdk_client.server_migrations.return_value = iter([])
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
self.server.id,
|
self.server.id,
|
||||||
@ -1004,8 +1003,7 @@ class TestServerMigrationForceComplete(TestServerMigration):
|
|||||||
str(ex))
|
str(ex))
|
||||||
|
|
||||||
def test_server_migration_force_complete_by_uuid_pre_v259(self):
|
def test_server_migration_force_complete_by_uuid_pre_v259(self):
|
||||||
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
self._set_mock_microversion('2.58')
|
||||||
'2.58')
|
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
self.server.id,
|
self.server.id,
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Finish switching server migration to the OpenStackSDK
|
Loading…
Reference in New Issue
Block a user