Skip to content

Commit 76a946b

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "In Python3.7 async is a keyword [1]"
2 parents df6e184 + 2d53296 commit 76a946b

File tree

9 files changed

+30
-29
lines changed

9 files changed

+30
-29
lines changed

nova/api/openstack/compute/migrate_server.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def _migrate_live(self, req, id, body):
8282
host = body["os-migrateLive"]["host"]
8383
block_migration = body["os-migrateLive"]["block_migration"]
8484
force = None
85-
async = api_version_request.is_supported(req, min_version='2.34')
85+
async_ = api_version_request.is_supported(req, min_version='2.34')
8686
if api_version_request.is_supported(req, min_version='2.30'):
8787
force = self._get_force_param_for_live_migration(body, host)
8888
if api_version_request.is_supported(req, min_version='2.25'):
@@ -103,7 +103,8 @@ def _migrate_live(self, req, id, body):
103103
instance = common.get_instance(self.compute_api, context, id)
104104
try:
105105
self.compute_api.live_migrate(context, instance, block_migration,
106-
disk_over_commit, host, force, async)
106+
disk_over_commit, host, force,
107+
async_)
107108
except exception.InstanceUnknownCell as e:
108109
raise exc.HTTPNotFound(explanation=e.format_message())
109110
except (exception.NoValidHost,
@@ -116,7 +117,7 @@ def _migrate_live(self, req, id, body):
116117
exception.InvalidSharedStorage,
117118
exception.HypervisorUnavailable,
118119
exception.MigrationPreCheckError) as ex:
119-
if async:
120+
if async_:
120121
with excutils.save_and_reraise_exception():
121122
LOG.error("Unexpected exception received from "
122123
"conductor during pre-live-migration checks "

nova/compute/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4337,7 +4337,7 @@ def update_instance_metadata(self, context, instance,
43374337
@check_instance_cell
43384338
@check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.PAUSED])
43394339
def live_migrate(self, context, instance, block_migration,
4340-
disk_over_commit, host_name, force=None, async=False):
4340+
disk_over_commit, host_name, force=None, async_=False):
43414341
"""Migrate a server lively to a new host."""
43424342
LOG.debug("Going to try to live migrate instance to %s",
43434343
host_name or "another host", instance=instance)
@@ -4393,7 +4393,7 @@ def live_migrate(self, context, instance, block_migration,
43934393
self.compute_task_api.live_migrate_instance(context, instance,
43944394
host_name, block_migration=block_migration,
43954395
disk_over_commit=disk_over_commit,
4396-
request_spec=request_spec, async=async)
4396+
request_spec=request_spec, async_=async_)
43974397
except oslo_exceptions.MessagingTimeout as messaging_timeout:
43984398
with excutils.save_and_reraise_exception():
43994399
# NOTE(pkoniszewski): It is possible that MessagingTimeout

nova/conductor/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ def resize_instance(self, context, instance, extra_instance_updates,
9999

100100
def live_migrate_instance(self, context, instance, host_name,
101101
block_migration, disk_over_commit,
102-
request_spec=None, async=False):
102+
request_spec=None, async_=False):
103103
scheduler_hint = {'host': host_name}
104-
if async:
104+
if async_:
105105
self.conductor_compute_rpcapi.live_migrate_instance(
106106
context, instance, scheduler_hint, block_migration,
107107
disk_over_commit, request_spec)

nova/db/sqlalchemy/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def wrapper(*args, **kwargs):
202202
use_slave = keyed_args.get('use_slave', False)
203203

204204
if use_slave:
205-
reader_mode = get_context_manager(context).async
205+
reader_mode = get_context_manager(context).async_
206206
else:
207207
reader_mode = get_context_manager(context).reader
208208

nova/tests/unit/api/openstack/compute/test_migrate_server.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
3636
_api_version = '2.1'
3737
disk_over_commit = False
3838
force = None
39-
async = False
39+
async_ = False
4040
host_name = None
4141

4242
def setUp(self):
@@ -60,7 +60,7 @@ def test_migrate(self):
6060
'_migrate_live': 'live_migrate'}
6161
body_map = {'_migrate_live': self._get_migration_body(host='hostname')}
6262
args_map = {'_migrate_live': ((False, self.disk_over_commit,
63-
'hostname', self.force, self.async),
63+
'hostname', self.force, self.async_),
6464
{}),
6565
'_migrate': ((), {'host_name': self.host_name})}
6666
self._test_actions(['_migrate', '_migrate_live'], body_map=body_map,
@@ -72,7 +72,7 @@ def test_migrate_none_hostname(self):
7272
'_migrate_live': 'live_migrate'}
7373
body_map = {'_migrate_live': self._get_migration_body(host=None)}
7474
args_map = {'_migrate_live': ((False, self.disk_over_commit, None,
75-
self.force, self.async),
75+
self.force, self.async_),
7676
{}),
7777
'_migrate': ((), {'host_name': None})}
7878
self._test_actions(['_migrate', '_migrate_live'], body_map=body_map,
@@ -91,7 +91,7 @@ def test_migrate_raise_conflict_on_invalid_state(self):
9191
body_map = {'_migrate_live':
9292
self._get_migration_body(host='hostname')}
9393
args_map = {'_migrate_live': ((False, self.disk_over_commit,
94-
'hostname', self.force, self.async),
94+
'hostname', self.force, self.async_),
9595
{}),
9696
'_migrate': ((), {'host_name': self.host_name})}
9797
exception_arg = {'_migrate': 'migrate',
@@ -108,7 +108,7 @@ def test_actions_with_locked_instance(self):
108108
body_map = {'_migrate_live':
109109
self._get_migration_body(host='hostname')}
110110
args_map = {'_migrate_live': ((False, self.disk_over_commit,
111-
'hostname', self.force, self.async),
111+
'hostname', self.force, self.async_),
112112
{}),
113113
'_migrate': ((), {'host_name': self.host_name})}
114114
self._test_actions_with_locked_instance(
@@ -146,7 +146,7 @@ def _test_migrate_live_succeeded(self, param):
146146
self.assertEqual(202, live_migrate_method.wsgi_code)
147147
mock_live_migrate.assert_called_once_with(
148148
self.context, instance, False, self.disk_over_commit,
149-
'hostname', self.force, self.async)
149+
'hostname', self.force, self.async_)
150150

151151
self.mock_get.assert_called_once_with(self.context, instance.uuid,
152152
expected_attrs=None)
@@ -224,7 +224,7 @@ def _test_migrate_live_failed_with_exception(
224224
self.assertIn(six.text_type(fake_exc), ex.explanation)
225225
mock_live_migrate.assert_called_once_with(
226226
self.context, instance, False, self.disk_over_commit,
227-
'hostname', self.force, self.async)
227+
'hostname', self.force, self.async_)
228228
self.mock_get.assert_called_once_with(self.context, instance.uuid,
229229
expected_attrs=None)
230230

@@ -319,7 +319,7 @@ def test_live_migrate_block_migration_auto(self):
319319
body_map = {'_migrate_live': {'os-migrateLive': {'host': 'hostname',
320320
'block_migration': 'auto'}}}
321321
args_map = {'_migrate_live': ((None, None, 'hostname', self.force,
322-
self.async), {})}
322+
self.async_), {})}
323323
self._test_actions(['_migrate_live'], body_map=body_map,
324324
method_translations=method_translations,
325325
args_map=args_map)
@@ -352,7 +352,7 @@ def _test_live_migrate(self, force=False):
352352
'block_migration': 'auto',
353353
'force': litteral_force}}}
354354
args_map = {'_migrate_live': ((None, None, 'hostname', force,
355-
self.async), {})}
355+
self.async_), {})}
356356
self._test_actions(['_migrate_live'], body_map=body_map,
357357
method_translations=method_translations,
358358
args_map=args_map)
@@ -372,7 +372,7 @@ def test_forced_live_migrate_with_no_provided_host(self):
372372

373373

374374
class MigrateServerTestsV234(MigrateServerTestsV230):
375-
async = True
375+
async_ = True
376376

377377
def setUp(self):
378378
super(MigrateServerTestsV234, self).setUp()
@@ -441,7 +441,7 @@ def test_migrate_live_compute_host_not_found(self):
441441
self.req, instance.uuid, body=body)
442442
mock_live_migrate.assert_called_once_with(
443443
self.context, instance, None, self.disk_over_commit,
444-
'hostname', self.force, self.async)
444+
'hostname', self.force, self.async_)
445445
self.mock_get.assert_called_once_with(self.context, instance.uuid,
446446
expected_attrs=None)
447447

@@ -459,7 +459,7 @@ def test_migrate_live_unexpected_error(self):
459459
self.req, instance.uuid, body=body)
460460
mock_live_migrate.assert_called_once_with(
461461
self.context, instance, None, self.disk_over_commit,
462-
'hostname', self.force, self.async)
462+
'hostname', self.force, self.async_)
463463
self.mock_get.assert_called_once_with(self.context, instance.uuid,
464464
expected_attrs=None)
465465

nova/tests/unit/compute/test_compute.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11181,7 +11181,7 @@ def do_test(record_action_start, get_by_instance_uuid,
1118111181
block_migration=True,
1118211182
disk_over_commit=True,
1118311183
host_name='fake_dest_host',
11184-
force=force, async=False)
11184+
force=force, async_=False)
1118511185

1118611186
record_action_start.assert_called_once_with(self.context, instance,
1118711187
'live-migration')
@@ -11193,7 +11193,7 @@ def do_test(record_action_start, get_by_instance_uuid,
1119311193
self.context, instance, host,
1119411194
block_migration=True,
1119511195
disk_over_commit=True,
11196-
request_spec=fake_spec, async=False)
11196+
request_spec=fake_spec, async_=False)
1119711197

1119811198
delete_tokens_for_instance.assert_called_once_with(
1119911199
self.context, instance.uuid)

nova/tests/unit/compute/test_compute_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2527,7 +2527,7 @@ def _live_migrate_instance(self, instance, _save, _action, get_spec):
25272527
block_migration=True,
25282528
disk_over_commit=True,
25292529
request_spec=fake_spec,
2530-
async=False)
2530+
async_=False)
25312531

25322532
def _get_volumes_for_test_swap_volume(self):
25332533
volumes = {}

nova/tests/unit/virt/libvirt/test_guest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ def test_abort_job(self):
686686
self.domain.blockJobAbort.assert_called_once_with('vda', flags=0)
687687

688688
def test_abort_job_async(self):
689-
self.gblock.abort_job(async=True)
689+
self.gblock.abort_job(async_=True)
690690
self.domain.blockJobAbort.assert_called_once_with(
691691
'vda', flags=fakelibvirt.VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC)
692692

nova/virt/libvirt/guest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,18 +741,18 @@ def __init__(self, guest, disk):
741741
self._guest = guest
742742
self._disk = disk
743743

744-
def abort_job(self, async=False, pivot=False):
744+
def abort_job(self, async_=False, pivot=False):
745745
"""Request to cancel a live block device job
746746
747-
:param async: Cancel the block device job (e.g. 'copy' or
748-
'commit'), and return as soon as possible, without
749-
waiting for job completion
747+
:param async_: Cancel the block device job (e.g. 'copy' or
748+
'commit'), and return as soon as possible, without
749+
waiting for job completion
750750
:param pivot: Pivot to the destination image when ending a
751751
'copy' or "active commit" (meaning: merging the
752752
contents of current active disk into its backing
753753
file) job
754754
"""
755-
flags = async and libvirt.VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC or 0
755+
flags = async_ and libvirt.VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC or 0
756756
flags |= pivot and libvirt.VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT or 0
757757
self._guest._domain.blockJobAbort(self._disk, flags=flags)
758758

0 commit comments

Comments
 (0)