diff --git a/nova/api/openstack/compute/migrate_server.py b/nova/api/openstack/compute/migrate_server.py index 789e7721e943..43beee991226 100644 --- a/nova/api/openstack/compute/migrate_server.py +++ b/nova/api/openstack/compute/migrate_server.py @@ -82,7 +82,7 @@ class MigrateServerController(wsgi.Controller): host = body["os-migrateLive"]["host"] block_migration = body["os-migrateLive"]["block_migration"] 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'): force = self._get_force_param_for_live_migration(body, host) 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) try: 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: raise exc.HTTPNotFound(explanation=e.format_message()) except (exception.NoValidHost, @@ -116,7 +117,7 @@ class MigrateServerController(wsgi.Controller): exception.InvalidSharedStorage, exception.HypervisorUnavailable, exception.MigrationPreCheckError) as ex: - if async: + if async_: with excutils.save_and_reraise_exception(): LOG.error("Unexpected exception received from " "conductor during pre-live-migration checks " diff --git a/nova/compute/api.py b/nova/compute/api.py index 7e0972cfc064..7eacf6384494 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -4311,7 +4311,7 @@ class API(base.Base): @check_instance_cell @check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.PAUSED]) 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.""" LOG.debug("Going to try to live migrate instance to %s", host_name or "another host", instance=instance) @@ -4367,7 +4367,7 @@ class API(base.Base): self.compute_task_api.live_migrate_instance(context, instance, host_name, block_migration=block_migration, 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: with excutils.save_and_reraise_exception(): # NOTE(pkoniszewski): It is possible that MessagingTimeout diff --git a/nova/conductor/api.py b/nova/conductor/api.py index c7d8fbd85888..ccf6b102797f 100644 --- a/nova/conductor/api.py +++ b/nova/conductor/api.py @@ -99,9 +99,9 @@ class ComputeTaskAPI(object): def live_migrate_instance(self, context, instance, host_name, block_migration, disk_over_commit, - request_spec=None, async=False): + request_spec=None, async_=False): scheduler_hint = {'host': host_name} - if async: + if async_: self.conductor_compute_rpcapi.live_migrate_instance( context, instance, scheduler_hint, block_migration, disk_over_commit, request_spec) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index a67747e4087b..59f0a8c2924a 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -202,7 +202,7 @@ def select_db_reader_mode(f): use_slave = keyed_args.get('use_slave', False) if use_slave: - reader_mode = get_context_manager(context).async + reader_mode = get_context_manager(context).async_ else: reader_mode = get_context_manager(context).reader diff --git a/nova/tests/unit/api/openstack/compute/test_migrate_server.py b/nova/tests/unit/api/openstack/compute/test_migrate_server.py index 133eb46f9fb3..664685cefe39 100644 --- a/nova/tests/unit/api/openstack/compute/test_migrate_server.py +++ b/nova/tests/unit/api/openstack/compute/test_migrate_server.py @@ -36,7 +36,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests): _api_version = '2.1' disk_over_commit = False force = None - async = False + async_ = False host_name = None def setUp(self): @@ -60,7 +60,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests): '_migrate_live': 'live_migrate'} body_map = {'_migrate_live': self._get_migration_body(host='hostname')} 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})} 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'} body_map = {'_migrate_live': self._get_migration_body(host=None)} args_map = {'_migrate_live': ((False, self.disk_over_commit, None, - self.force, self.async), + self.force, self.async_), {}), '_migrate': ((), {'host_name': None})} 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': self._get_migration_body(host='hostname')} 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})} exception_arg = {'_migrate': 'migrate', @@ -108,7 +108,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests): body_map = {'_migrate_live': self._get_migration_body(host='hostname')} 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})} 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) mock_live_migrate.assert_called_once_with( 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, expected_attrs=None) @@ -224,7 +224,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests): self.assertIn(six.text_type(fake_exc), ex.explanation) mock_live_migrate.assert_called_once_with( 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, expected_attrs=None) @@ -319,7 +319,7 @@ class MigrateServerTestsV225(MigrateServerTestsV21): body_map = {'_migrate_live': {'os-migrateLive': {'host': 'hostname', 'block_migration': 'auto'}}} args_map = {'_migrate_live': ((None, None, 'hostname', self.force, - self.async), {})} + self.async_), {})} self._test_actions(['_migrate_live'], body_map=body_map, method_translations=method_translations, args_map=args_map) @@ -352,7 +352,7 @@ class MigrateServerTestsV230(MigrateServerTestsV225): 'block_migration': 'auto', 'force': litteral_force}}} args_map = {'_migrate_live': ((None, None, 'hostname', force, - self.async), {})} + self.async_), {})} self._test_actions(['_migrate_live'], body_map=body_map, method_translations=method_translations, args_map=args_map) @@ -372,7 +372,7 @@ class MigrateServerTestsV230(MigrateServerTestsV225): class MigrateServerTestsV234(MigrateServerTestsV230): - async = True + async_ = True def setUp(self): super(MigrateServerTestsV234, self).setUp() @@ -441,7 +441,7 @@ class MigrateServerTestsV234(MigrateServerTestsV230): self.req, instance.uuid, body=body) mock_live_migrate.assert_called_once_with( 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, expected_attrs=None) @@ -459,7 +459,7 @@ class MigrateServerTestsV234(MigrateServerTestsV230): self.req, instance.uuid, body=body) mock_live_migrate.assert_called_once_with( 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, expected_attrs=None) diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py index f6e79ea0c1e3..82756d271083 100644 --- a/nova/tests/unit/compute/test_compute.py +++ b/nova/tests/unit/compute/test_compute.py @@ -11162,7 +11162,7 @@ class ComputeAPITestCase(BaseTestCase): block_migration=True, disk_over_commit=True, host_name='fake_dest_host', - force=force, async=False) + force=force, async_=False) record_action_start.assert_called_once_with(self.context, instance, 'live-migration') @@ -11174,7 +11174,7 @@ class ComputeAPITestCase(BaseTestCase): self.context, instance, host, block_migration=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( self.context, instance.uuid) diff --git a/nova/tests/unit/compute/test_compute_api.py b/nova/tests/unit/compute/test_compute_api.py index 41d98fb15a16..53bc03b3f49f 100644 --- a/nova/tests/unit/compute/test_compute_api.py +++ b/nova/tests/unit/compute/test_compute_api.py @@ -2534,7 +2534,7 @@ class _ComputeAPIUnitTestMixIn(object): block_migration=True, disk_over_commit=True, request_spec=fake_spec, - async=False) + async_=False) def _get_volumes_for_test_swap_volume(self): volumes = {} diff --git a/nova/tests/unit/virt/libvirt/test_guest.py b/nova/tests/unit/virt/libvirt/test_guest.py index 1598e3ceb82f..b4515cc3faa4 100644 --- a/nova/tests/unit/virt/libvirt/test_guest.py +++ b/nova/tests/unit/virt/libvirt/test_guest.py @@ -687,7 +687,7 @@ class GuestBlockTestCase(test.NoDBTestCase): self.domain.blockJobAbort.assert_called_once_with('vda', flags=0) 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( 'vda', flags=fakelibvirt.VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC) diff --git a/nova/virt/libvirt/guest.py b/nova/virt/libvirt/guest.py index ab9746b442fb..a4a5dc15a3e1 100644 --- a/nova/virt/libvirt/guest.py +++ b/nova/virt/libvirt/guest.py @@ -743,18 +743,18 @@ class BlockDevice(object): self._guest = guest 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 - :param async: Cancel the block device job (e.g. 'copy' or - 'commit'), and return as soon as possible, without - waiting for job completion + :param async_: Cancel the block device job (e.g. 'copy' or + 'commit'), and return as soon as possible, without + waiting for job completion :param pivot: Pivot to the destination image when ending a 'copy' or "active commit" (meaning: merging the contents of current active disk into its backing 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 self._guest._domain.blockJobAbort(self._disk, flags=flags)