In Python3.7 async is a keyword [1]
Change all instances of "async" to "async_" [1] https://docs.python.org/3/whatsnew/3.7.html Change-Id: I974b1177ba8313ac502910ca358cf386ef00bc02 Closes-Bug: #1782746
This commit is contained in:
parent
d9e04c4ff0
commit
2d532963fa
nova
api/openstack/compute
compute
conductor
db/sqlalchemy
tests/unit
api/openstack/compute
compute
virt/libvirt
virt/libvirt
@ -82,7 +82,7 @@ class MigrateServerController(wsgi.Controller):
|
|||||||
host = body["os-migrateLive"]["host"]
|
host = body["os-migrateLive"]["host"]
|
||||||
block_migration = body["os-migrateLive"]["block_migration"]
|
block_migration = body["os-migrateLive"]["block_migration"]
|
||||||
force = None
|
force = None
|
||||||
async = api_version_request.is_supported(req, min_version='2.34')
|
async_ = api_version_request.is_supported(req, min_version='2.34')
|
||||||
if api_version_request.is_supported(req, min_version='2.30'):
|
if api_version_request.is_supported(req, min_version='2.30'):
|
||||||
force = self._get_force_param_for_live_migration(body, host)
|
force = self._get_force_param_for_live_migration(body, host)
|
||||||
if api_version_request.is_supported(req, min_version='2.25'):
|
if api_version_request.is_supported(req, min_version='2.25'):
|
||||||
@ -103,7 +103,8 @@ class MigrateServerController(wsgi.Controller):
|
|||||||
instance = common.get_instance(self.compute_api, context, id)
|
instance = common.get_instance(self.compute_api, context, id)
|
||||||
try:
|
try:
|
||||||
self.compute_api.live_migrate(context, instance, block_migration,
|
self.compute_api.live_migrate(context, instance, block_migration,
|
||||||
disk_over_commit, host, force, async)
|
disk_over_commit, host, force,
|
||||||
|
async_)
|
||||||
except exception.InstanceUnknownCell as e:
|
except exception.InstanceUnknownCell as e:
|
||||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||||
except (exception.NoValidHost,
|
except (exception.NoValidHost,
|
||||||
@ -116,7 +117,7 @@ class MigrateServerController(wsgi.Controller):
|
|||||||
exception.InvalidSharedStorage,
|
exception.InvalidSharedStorage,
|
||||||
exception.HypervisorUnavailable,
|
exception.HypervisorUnavailable,
|
||||||
exception.MigrationPreCheckError) as ex:
|
exception.MigrationPreCheckError) as ex:
|
||||||
if async:
|
if async_:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
LOG.error("Unexpected exception received from "
|
LOG.error("Unexpected exception received from "
|
||||||
"conductor during pre-live-migration checks "
|
"conductor during pre-live-migration checks "
|
||||||
|
@ -4311,7 +4311,7 @@ class API(base.Base):
|
|||||||
@check_instance_cell
|
@check_instance_cell
|
||||||
@check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.PAUSED])
|
@check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.PAUSED])
|
||||||
def live_migrate(self, context, instance, block_migration,
|
def live_migrate(self, context, instance, block_migration,
|
||||||
disk_over_commit, host_name, force=None, async=False):
|
disk_over_commit, host_name, force=None, async_=False):
|
||||||
"""Migrate a server lively to a new host."""
|
"""Migrate a server lively to a new host."""
|
||||||
LOG.debug("Going to try to live migrate instance to %s",
|
LOG.debug("Going to try to live migrate instance to %s",
|
||||||
host_name or "another host", instance=instance)
|
host_name or "another host", instance=instance)
|
||||||
@ -4367,7 +4367,7 @@ class API(base.Base):
|
|||||||
self.compute_task_api.live_migrate_instance(context, instance,
|
self.compute_task_api.live_migrate_instance(context, instance,
|
||||||
host_name, block_migration=block_migration,
|
host_name, block_migration=block_migration,
|
||||||
disk_over_commit=disk_over_commit,
|
disk_over_commit=disk_over_commit,
|
||||||
request_spec=request_spec, async=async)
|
request_spec=request_spec, async_=async_)
|
||||||
except oslo_exceptions.MessagingTimeout as messaging_timeout:
|
except oslo_exceptions.MessagingTimeout as messaging_timeout:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
# NOTE(pkoniszewski): It is possible that MessagingTimeout
|
# NOTE(pkoniszewski): It is possible that MessagingTimeout
|
||||||
|
@ -99,9 +99,9 @@ class ComputeTaskAPI(object):
|
|||||||
|
|
||||||
def live_migrate_instance(self, context, instance, host_name,
|
def live_migrate_instance(self, context, instance, host_name,
|
||||||
block_migration, disk_over_commit,
|
block_migration, disk_over_commit,
|
||||||
request_spec=None, async=False):
|
request_spec=None, async_=False):
|
||||||
scheduler_hint = {'host': host_name}
|
scheduler_hint = {'host': host_name}
|
||||||
if async:
|
if async_:
|
||||||
self.conductor_compute_rpcapi.live_migrate_instance(
|
self.conductor_compute_rpcapi.live_migrate_instance(
|
||||||
context, instance, scheduler_hint, block_migration,
|
context, instance, scheduler_hint, block_migration,
|
||||||
disk_over_commit, request_spec)
|
disk_over_commit, request_spec)
|
||||||
|
@ -202,7 +202,7 @@ def select_db_reader_mode(f):
|
|||||||
use_slave = keyed_args.get('use_slave', False)
|
use_slave = keyed_args.get('use_slave', False)
|
||||||
|
|
||||||
if use_slave:
|
if use_slave:
|
||||||
reader_mode = get_context_manager(context).async
|
reader_mode = get_context_manager(context).async_
|
||||||
else:
|
else:
|
||||||
reader_mode = get_context_manager(context).reader
|
reader_mode = get_context_manager(context).reader
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
|||||||
_api_version = '2.1'
|
_api_version = '2.1'
|
||||||
disk_over_commit = False
|
disk_over_commit = False
|
||||||
force = None
|
force = None
|
||||||
async = False
|
async_ = False
|
||||||
host_name = None
|
host_name = None
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -60,7 +60,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
|||||||
'_migrate_live': 'live_migrate'}
|
'_migrate_live': 'live_migrate'}
|
||||||
body_map = {'_migrate_live': self._get_migration_body(host='hostname')}
|
body_map = {'_migrate_live': self._get_migration_body(host='hostname')}
|
||||||
args_map = {'_migrate_live': ((False, self.disk_over_commit,
|
args_map = {'_migrate_live': ((False, self.disk_over_commit,
|
||||||
'hostname', self.force, self.async),
|
'hostname', self.force, self.async_),
|
||||||
{}),
|
{}),
|
||||||
'_migrate': ((), {'host_name': self.host_name})}
|
'_migrate': ((), {'host_name': self.host_name})}
|
||||||
self._test_actions(['_migrate', '_migrate_live'], body_map=body_map,
|
self._test_actions(['_migrate', '_migrate_live'], body_map=body_map,
|
||||||
@ -72,7 +72,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
|||||||
'_migrate_live': 'live_migrate'}
|
'_migrate_live': 'live_migrate'}
|
||||||
body_map = {'_migrate_live': self._get_migration_body(host=None)}
|
body_map = {'_migrate_live': self._get_migration_body(host=None)}
|
||||||
args_map = {'_migrate_live': ((False, self.disk_over_commit, None,
|
args_map = {'_migrate_live': ((False, self.disk_over_commit, None,
|
||||||
self.force, self.async),
|
self.force, self.async_),
|
||||||
{}),
|
{}),
|
||||||
'_migrate': ((), {'host_name': None})}
|
'_migrate': ((), {'host_name': None})}
|
||||||
self._test_actions(['_migrate', '_migrate_live'], body_map=body_map,
|
self._test_actions(['_migrate', '_migrate_live'], body_map=body_map,
|
||||||
@ -91,7 +91,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
|||||||
body_map = {'_migrate_live':
|
body_map = {'_migrate_live':
|
||||||
self._get_migration_body(host='hostname')}
|
self._get_migration_body(host='hostname')}
|
||||||
args_map = {'_migrate_live': ((False, self.disk_over_commit,
|
args_map = {'_migrate_live': ((False, self.disk_over_commit,
|
||||||
'hostname', self.force, self.async),
|
'hostname', self.force, self.async_),
|
||||||
{}),
|
{}),
|
||||||
'_migrate': ((), {'host_name': self.host_name})}
|
'_migrate': ((), {'host_name': self.host_name})}
|
||||||
exception_arg = {'_migrate': 'migrate',
|
exception_arg = {'_migrate': 'migrate',
|
||||||
@ -108,7 +108,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
|||||||
body_map = {'_migrate_live':
|
body_map = {'_migrate_live':
|
||||||
self._get_migration_body(host='hostname')}
|
self._get_migration_body(host='hostname')}
|
||||||
args_map = {'_migrate_live': ((False, self.disk_over_commit,
|
args_map = {'_migrate_live': ((False, self.disk_over_commit,
|
||||||
'hostname', self.force, self.async),
|
'hostname', self.force, self.async_),
|
||||||
{}),
|
{}),
|
||||||
'_migrate': ((), {'host_name': self.host_name})}
|
'_migrate': ((), {'host_name': self.host_name})}
|
||||||
self._test_actions_with_locked_instance(
|
self._test_actions_with_locked_instance(
|
||||||
@ -146,7 +146,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
|||||||
self.assertEqual(202, live_migrate_method.wsgi_code)
|
self.assertEqual(202, live_migrate_method.wsgi_code)
|
||||||
mock_live_migrate.assert_called_once_with(
|
mock_live_migrate.assert_called_once_with(
|
||||||
self.context, instance, False, self.disk_over_commit,
|
self.context, instance, False, self.disk_over_commit,
|
||||||
'hostname', self.force, self.async)
|
'hostname', self.force, self.async_)
|
||||||
|
|
||||||
self.mock_get.assert_called_once_with(self.context, instance.uuid,
|
self.mock_get.assert_called_once_with(self.context, instance.uuid,
|
||||||
expected_attrs=None)
|
expected_attrs=None)
|
||||||
@ -224,7 +224,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
|||||||
self.assertIn(six.text_type(fake_exc), ex.explanation)
|
self.assertIn(six.text_type(fake_exc), ex.explanation)
|
||||||
mock_live_migrate.assert_called_once_with(
|
mock_live_migrate.assert_called_once_with(
|
||||||
self.context, instance, False, self.disk_over_commit,
|
self.context, instance, False, self.disk_over_commit,
|
||||||
'hostname', self.force, self.async)
|
'hostname', self.force, self.async_)
|
||||||
self.mock_get.assert_called_once_with(self.context, instance.uuid,
|
self.mock_get.assert_called_once_with(self.context, instance.uuid,
|
||||||
expected_attrs=None)
|
expected_attrs=None)
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ class MigrateServerTestsV225(MigrateServerTestsV21):
|
|||||||
body_map = {'_migrate_live': {'os-migrateLive': {'host': 'hostname',
|
body_map = {'_migrate_live': {'os-migrateLive': {'host': 'hostname',
|
||||||
'block_migration': 'auto'}}}
|
'block_migration': 'auto'}}}
|
||||||
args_map = {'_migrate_live': ((None, None, 'hostname', self.force,
|
args_map = {'_migrate_live': ((None, None, 'hostname', self.force,
|
||||||
self.async), {})}
|
self.async_), {})}
|
||||||
self._test_actions(['_migrate_live'], body_map=body_map,
|
self._test_actions(['_migrate_live'], body_map=body_map,
|
||||||
method_translations=method_translations,
|
method_translations=method_translations,
|
||||||
args_map=args_map)
|
args_map=args_map)
|
||||||
@ -352,7 +352,7 @@ class MigrateServerTestsV230(MigrateServerTestsV225):
|
|||||||
'block_migration': 'auto',
|
'block_migration': 'auto',
|
||||||
'force': litteral_force}}}
|
'force': litteral_force}}}
|
||||||
args_map = {'_migrate_live': ((None, None, 'hostname', force,
|
args_map = {'_migrate_live': ((None, None, 'hostname', force,
|
||||||
self.async), {})}
|
self.async_), {})}
|
||||||
self._test_actions(['_migrate_live'], body_map=body_map,
|
self._test_actions(['_migrate_live'], body_map=body_map,
|
||||||
method_translations=method_translations,
|
method_translations=method_translations,
|
||||||
args_map=args_map)
|
args_map=args_map)
|
||||||
@ -372,7 +372,7 @@ class MigrateServerTestsV230(MigrateServerTestsV225):
|
|||||||
|
|
||||||
|
|
||||||
class MigrateServerTestsV234(MigrateServerTestsV230):
|
class MigrateServerTestsV234(MigrateServerTestsV230):
|
||||||
async = True
|
async_ = True
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(MigrateServerTestsV234, self).setUp()
|
super(MigrateServerTestsV234, self).setUp()
|
||||||
@ -441,7 +441,7 @@ class MigrateServerTestsV234(MigrateServerTestsV230):
|
|||||||
self.req, instance.uuid, body=body)
|
self.req, instance.uuid, body=body)
|
||||||
mock_live_migrate.assert_called_once_with(
|
mock_live_migrate.assert_called_once_with(
|
||||||
self.context, instance, None, self.disk_over_commit,
|
self.context, instance, None, self.disk_over_commit,
|
||||||
'hostname', self.force, self.async)
|
'hostname', self.force, self.async_)
|
||||||
self.mock_get.assert_called_once_with(self.context, instance.uuid,
|
self.mock_get.assert_called_once_with(self.context, instance.uuid,
|
||||||
expected_attrs=None)
|
expected_attrs=None)
|
||||||
|
|
||||||
@ -459,7 +459,7 @@ class MigrateServerTestsV234(MigrateServerTestsV230):
|
|||||||
self.req, instance.uuid, body=body)
|
self.req, instance.uuid, body=body)
|
||||||
mock_live_migrate.assert_called_once_with(
|
mock_live_migrate.assert_called_once_with(
|
||||||
self.context, instance, None, self.disk_over_commit,
|
self.context, instance, None, self.disk_over_commit,
|
||||||
'hostname', self.force, self.async)
|
'hostname', self.force, self.async_)
|
||||||
self.mock_get.assert_called_once_with(self.context, instance.uuid,
|
self.mock_get.assert_called_once_with(self.context, instance.uuid,
|
||||||
expected_attrs=None)
|
expected_attrs=None)
|
||||||
|
|
||||||
|
@ -11162,7 +11162,7 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
block_migration=True,
|
block_migration=True,
|
||||||
disk_over_commit=True,
|
disk_over_commit=True,
|
||||||
host_name='fake_dest_host',
|
host_name='fake_dest_host',
|
||||||
force=force, async=False)
|
force=force, async_=False)
|
||||||
|
|
||||||
record_action_start.assert_called_once_with(self.context, instance,
|
record_action_start.assert_called_once_with(self.context, instance,
|
||||||
'live-migration')
|
'live-migration')
|
||||||
@ -11174,7 +11174,7 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
self.context, instance, host,
|
self.context, instance, host,
|
||||||
block_migration=True,
|
block_migration=True,
|
||||||
disk_over_commit=True,
|
disk_over_commit=True,
|
||||||
request_spec=fake_spec, async=False)
|
request_spec=fake_spec, async_=False)
|
||||||
|
|
||||||
delete_tokens_for_instance.assert_called_once_with(
|
delete_tokens_for_instance.assert_called_once_with(
|
||||||
self.context, instance.uuid)
|
self.context, instance.uuid)
|
||||||
|
@ -2534,7 +2534,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||||||
block_migration=True,
|
block_migration=True,
|
||||||
disk_over_commit=True,
|
disk_over_commit=True,
|
||||||
request_spec=fake_spec,
|
request_spec=fake_spec,
|
||||||
async=False)
|
async_=False)
|
||||||
|
|
||||||
def _get_volumes_for_test_swap_volume(self):
|
def _get_volumes_for_test_swap_volume(self):
|
||||||
volumes = {}
|
volumes = {}
|
||||||
|
@ -687,7 +687,7 @@ class GuestBlockTestCase(test.NoDBTestCase):
|
|||||||
self.domain.blockJobAbort.assert_called_once_with('vda', flags=0)
|
self.domain.blockJobAbort.assert_called_once_with('vda', flags=0)
|
||||||
|
|
||||||
def test_abort_job_async(self):
|
def test_abort_job_async(self):
|
||||||
self.gblock.abort_job(async=True)
|
self.gblock.abort_job(async_=True)
|
||||||
self.domain.blockJobAbort.assert_called_once_with(
|
self.domain.blockJobAbort.assert_called_once_with(
|
||||||
'vda', flags=fakelibvirt.VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC)
|
'vda', flags=fakelibvirt.VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC)
|
||||||
|
|
||||||
|
@ -743,10 +743,10 @@ class BlockDevice(object):
|
|||||||
self._guest = guest
|
self._guest = guest
|
||||||
self._disk = disk
|
self._disk = disk
|
||||||
|
|
||||||
def abort_job(self, async=False, pivot=False):
|
def abort_job(self, async_=False, pivot=False):
|
||||||
"""Request to cancel a live block device job
|
"""Request to cancel a live block device job
|
||||||
|
|
||||||
:param async: Cancel the block device job (e.g. 'copy' or
|
:param async_: Cancel the block device job (e.g. 'copy' or
|
||||||
'commit'), and return as soon as possible, without
|
'commit'), and return as soon as possible, without
|
||||||
waiting for job completion
|
waiting for job completion
|
||||||
:param pivot: Pivot to the destination image when ending a
|
:param pivot: Pivot to the destination image when ending a
|
||||||
@ -754,7 +754,7 @@ class BlockDevice(object):
|
|||||||
contents of current active disk into its backing
|
contents of current active disk into its backing
|
||||||
file) job
|
file) job
|
||||||
"""
|
"""
|
||||||
flags = async and libvirt.VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC or 0
|
flags = async_ and libvirt.VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC or 0
|
||||||
flags |= pivot and libvirt.VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT or 0
|
flags |= pivot and libvirt.VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT or 0
|
||||||
self._guest._domain.blockJobAbort(self._disk, flags=flags)
|
self._guest._domain.blockJobAbort(self._disk, flags=flags)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user