Skip to content

Commit d03a600

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "db: Synchronize function signatures"
2 parents e7c18ef + b5dd59f commit d03a600

File tree

2 files changed

+52
-43
lines changed

2 files changed

+52
-43
lines changed

nova/db/api.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def not_equal(*values):
7474
return IMPL.not_equal(*values)
7575

7676

77-
def create_context_manager(connection):
77+
def create_context_manager(connection=None):
7878
"""Create a database context manager object for a cell database connection.
7979
8080
:param connection: The database connection string
@@ -117,9 +117,9 @@ def service_get_by_uuid(context, service_uuid):
117117
return IMPL.service_get_by_uuid(context, service_uuid)
118118

119119

120-
def service_get_minimum_version(context, binary):
120+
def service_get_minimum_version(context, binaries):
121121
"""Get the minimum service version in the database."""
122-
return IMPL.service_get_minimum_version(context, binary)
122+
return IMPL.service_get_minimum_version(context, binaries)
123123

124124

125125
def service_get_by_host_and_topic(context, host, topic):
@@ -395,9 +395,9 @@ def certificate_get_all_by_user_and_project(context, user_id, project_id):
395395
####################
396396

397397

398-
def migration_update(context, id, values):
398+
def migration_update(context, migration_id, values):
399399
"""Update a migration instance."""
400-
return IMPL.migration_update(context, id, values)
400+
return IMPL.migration_update(context, migration_id, values)
401401

402402

403403
def migration_create(context, values):
@@ -522,31 +522,31 @@ def virtual_interface_get_by_uuid(context, vif_uuid):
522522
return IMPL.virtual_interface_get_by_uuid(context, vif_uuid)
523523

524524

525-
def virtual_interface_get_by_instance(context, instance_id):
525+
def virtual_interface_get_by_instance(context, instance_uuid):
526526
"""Gets all virtual interfaces for instance.
527527
528528
:param instance_uuid: UUID of the instance to filter on.
529529
"""
530-
return IMPL.virtual_interface_get_by_instance(context, instance_id)
530+
return IMPL.virtual_interface_get_by_instance(context, instance_uuid)
531531

532532

533533
def virtual_interface_get_by_instance_and_network(
534-
context, instance_id, network_id,
534+
context, instance_uuid, network_id,
535535
):
536536
"""Get all virtual interface for instance that's associated with
537537
network.
538538
"""
539-
return IMPL.virtual_interface_get_by_instance_and_network(context,
540-
instance_id,
541-
network_id)
539+
return IMPL.virtual_interface_get_by_instance_and_network(
540+
context, instance_uuid, network_id,
541+
)
542542

543543

544-
def virtual_interface_delete_by_instance(context, instance_id):
544+
def virtual_interface_delete_by_instance(context, instance_uuid):
545545
"""Delete virtual interface records associated with instance.
546546
547547
:param instance_uuid: UUID of the instance to filter on.
548548
"""
549-
return IMPL.virtual_interface_delete_by_instance(context, instance_id)
549+
return IMPL.virtual_interface_delete_by_instance(context, instance_uuid)
550550

551551

552552
def virtual_interface_delete(context, id):
@@ -786,16 +786,18 @@ def instance_update_and_get_original(context, instance_uuid, values,
786786
return rv
787787

788788

789-
def instance_add_security_group(context, instance_id, security_group_id):
789+
def instance_add_security_group(context, instance_uuid, security_group_id):
790790
"""Associate the given security group with the given instance."""
791-
return IMPL.instance_add_security_group(context, instance_id,
792-
security_group_id)
791+
return IMPL.instance_add_security_group(
792+
context, instance_uuid, security_group_id,
793+
)
793794

794795

795-
def instance_remove_security_group(context, instance_id, security_group_id):
796+
def instance_remove_security_group(context, instance_uuid, security_group_id):
796797
"""Disassociate the given security group from the given instance."""
797-
return IMPL.instance_remove_security_group(context, instance_id,
798-
security_group_id)
798+
return IMPL.instance_remove_security_group(
799+
context, instance_uuid, security_group_id,
800+
)
799801

800802

801803
####################
@@ -1126,9 +1128,9 @@ def pci_device_destroy(context, node_id, address):
11261128
return IMPL.pci_device_destroy(context, node_id, address)
11271129

11281130

1129-
def pci_device_update(context, node_id, address, value):
1131+
def pci_device_update(context, node_id, address, values):
11301132
"""Update a pci device."""
1131-
return IMPL.pci_device_update(context, node_id, address, value)
1133+
return IMPL.pci_device_update(context, node_id, address, values)
11321134

11331135

11341136
####################
@@ -1265,9 +1267,9 @@ def actions_get(context, instance_uuid, limit=None, marker=None,
12651267
return IMPL.actions_get(context, instance_uuid, limit, marker, filters)
12661268

12671269

1268-
def action_get_by_request_id(context, uuid, request_id):
1270+
def action_get_by_request_id(context, instance_uuid, request_id):
12691271
"""Get the action by request_id and given instance."""
1270-
return IMPL.action_get_by_request_id(context, uuid, request_id)
1272+
return IMPL.action_get_by_request_id(context, instance_uuid, request_id)
12711273

12721274

12731275
def action_event_start(context, values):

nova/db/sqlalchemy/api.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def require_context(f):
174174
def wrapper(*args, **kwargs):
175175
nova.context.require_context(args[0])
176176
return f(*args, **kwargs)
177+
wrapper.__signature__ = inspect.signature(f)
177178
return wrapper
178179

179180

@@ -202,6 +203,7 @@ def wrapper(*args, **kwargs):
202203

203204
with reader_mode.using(context):
204205
return f(*args, **kwargs)
206+
wrapper.__signature__ = inspect.signature(f)
205207
return wrapper
206208

207209

@@ -213,11 +215,12 @@ def pick_context_manager_writer(f):
213215
Wrapped function must have a RequestContext in the arguments.
214216
"""
215217
@functools.wraps(f)
216-
def wrapped(context, *args, **kwargs):
218+
def wrapper(context, *args, **kwargs):
217219
ctxt_mgr = get_context_manager(context)
218220
with ctxt_mgr.writer.using(context):
219221
return f(context, *args, **kwargs)
220-
return wrapped
222+
wrapper.__signature__ = inspect.signature(f)
223+
return wrapper
221224

222225

223226
def pick_context_manager_reader(f):
@@ -228,11 +231,12 @@ def pick_context_manager_reader(f):
228231
Wrapped function must have a RequestContext in the arguments.
229232
"""
230233
@functools.wraps(f)
231-
def wrapped(context, *args, **kwargs):
234+
def wrapper(context, *args, **kwargs):
232235
ctxt_mgr = get_context_manager(context)
233236
with ctxt_mgr.reader.using(context):
234237
return f(context, *args, **kwargs)
235-
return wrapped
238+
wrapper.__signature__ = inspect.signature(f)
239+
return wrapper
236240

237241

238242
def pick_context_manager_reader_allow_async(f):
@@ -243,11 +247,12 @@ def pick_context_manager_reader_allow_async(f):
243247
Wrapped function must have a RequestContext in the arguments.
244248
"""
245249
@functools.wraps(f)
246-
def wrapped(context, *args, **kwargs):
250+
def wrapper(context, *args, **kwargs):
247251
ctxt_mgr = get_context_manager(context)
248252
with ctxt_mgr.reader.allow_async.using(context):
249253
return f(context, *args, **kwargs)
250-
return wrapped
254+
wrapper.__signature__ = inspect.signature(f)
255+
return wrapper
251256

252257

253258
def model_query(
@@ -1539,8 +1544,10 @@ def instance_get_all(context, columns_to_join=None):
15391544

15401545
@require_context
15411546
@pick_context_manager_reader_allow_async
1542-
def instance_get_all_by_filters(context, filters, sort_key, sort_dir,
1543-
limit=None, marker=None, columns_to_join=None):
1547+
def instance_get_all_by_filters(
1548+
context, filters, sort_key='created_at', sort_dir='desc', limit=None,
1549+
marker=None, columns_to_join=None,
1550+
):
15441551
"""Get all instances matching all filters sorted by the primary key.
15451552
15461553
See instance_get_all_by_filters_sort for more information.
@@ -2541,18 +2548,18 @@ def _instance_extra_create(context, values):
25412548

25422549

25432550
@pick_context_manager_writer
2544-
def instance_extra_update_by_uuid(context, instance_uuid, values):
2551+
def instance_extra_update_by_uuid(context, instance_uuid, updates):
25452552
"""Update the instance extra record by instance uuid
25462553
25472554
:param instance_uuid: UUID of the instance tied to the record
25482555
:param updates: A dict of updates to apply
25492556
"""
25502557
rows_updated = model_query(context, models.InstanceExtra).\
25512558
filter_by(instance_uuid=instance_uuid).\
2552-
update(values)
2559+
update(updates)
25532560
if not rows_updated:
25542561
LOG.debug("Created instance_extra for %s", instance_uuid)
2555-
create_values = copy.copy(values)
2562+
create_values = copy.copy(updates)
25562563
create_values["instance_uuid"] = instance_uuid
25572564
_instance_extra_create(context, create_values)
25582565
rows_updated = 1
@@ -3305,23 +3312,23 @@ def migration_create(context, values):
33053312

33063313
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
33073314
@pick_context_manager_writer
3308-
def migration_update(context, id, values):
3315+
def migration_update(context, migration_id, values):
33093316
"""Update a migration instance."""
3310-
migration = migration_get(context, id)
3317+
migration = migration_get(context, migration_id)
33113318
migration.update(values)
33123319

33133320
return migration
33143321

33153322

33163323
@pick_context_manager_reader
3317-
def migration_get(context, id):
3324+
def migration_get(context, migration_id):
33183325
"""Finds a migration by the ID."""
33193326
result = model_query(context, models.Migration, read_deleted="yes").\
3320-
filter_by(id=id).\
3327+
filter_by(id=migration_id).\
33213328
first()
33223329

33233330
if not result:
3324-
raise exception.MigrationNotFound(migration_id=id)
3331+
raise exception.MigrationNotFound(migration_id=migration_id)
33253332

33263333
return result
33273334

@@ -3340,16 +3347,16 @@ def migration_get_by_uuid(context, migration_uuid):
33403347

33413348

33423349
@pick_context_manager_reader
3343-
def migration_get_by_id_and_instance(context, id, instance_uuid):
3350+
def migration_get_by_id_and_instance(context, migration_id, instance_uuid):
33443351
"""Finds a migration by the migration ID and the instance UUID."""
33453352
result = model_query(context, models.Migration).\
3346-
filter_by(id=id).\
3353+
filter_by(id=migration_id).\
33473354
filter_by(instance_uuid=instance_uuid).\
33483355
first()
33493356

33503357
if not result:
3351-
raise exception.MigrationNotFoundForInstance(migration_id=id,
3352-
instance_id=instance_uuid)
3358+
raise exception.MigrationNotFoundForInstance(
3359+
migration_id=migration_id, instance_id=instance_uuid)
33533360

33543361
return result
33553362

0 commit comments

Comments
 (0)