Switch to reader context
Since the mtu is already non-nullable, the writer context can be switched to a reader context. In addition, the redundant reader context can be removed. Change-Id: I482a3892dee8ee94ab70142cf734f71e766178ed Closes-Bug: #1859258
This commit is contained in:
parent
31730e4369
commit
af274fa826
|
@ -306,12 +306,9 @@ class DbBasePluginCommon(object):
|
||||||
if filters.get('cidr'):
|
if filters.get('cidr'):
|
||||||
filters.update(
|
filters.update(
|
||||||
{'cidr': [netaddr.IPNetwork(x).cidr for x in filters['cidr']]})
|
{'cidr': [netaddr.IPNetwork(x).cidr for x in filters['cidr']]})
|
||||||
# TODO(ihrachys) remove explicit reader usage when subnet OVO switches
|
return subnet_obj.Subnet.get_objects(context, _pager=pager,
|
||||||
# to engine facade by default
|
validate_filters=False,
|
||||||
with db_api.CONTEXT_READER.using(context):
|
**filters)
|
||||||
return subnet_obj.Subnet.get_objects(context, _pager=pager,
|
|
||||||
validate_filters=False,
|
|
||||||
**filters)
|
|
||||||
|
|
||||||
def _make_network_dict(self, network, fields=None,
|
def _make_network_dict(self, network, fields=None,
|
||||||
process_extensions=True, context=None):
|
process_extensions=True, context=None):
|
||||||
|
|
|
@ -1144,9 +1144,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
||||||
@db_api.retry_if_session_inactive()
|
@db_api.retry_if_session_inactive()
|
||||||
def get_networks(self, context, filters=None, fields=None,
|
def get_networks(self, context, filters=None, fields=None,
|
||||||
sorts=None, limit=None, marker=None, page_reverse=False):
|
sorts=None, limit=None, marker=None, page_reverse=False):
|
||||||
# NOTE(ihrachys) use writer manager to be able to update mtu
|
with db_api.CONTEXT_READER.using(context):
|
||||||
# TODO(ihrachys) remove in Queens when mtu is not nullable
|
|
||||||
with db_api.CONTEXT_WRITER.using(context):
|
|
||||||
nets_db = super(Ml2Plugin, self)._get_networks(
|
nets_db = super(Ml2Plugin, self)._get_networks(
|
||||||
context, filters, None, sorts, limit, marker, page_reverse)
|
context, filters, None, sorts, limit, marker, page_reverse)
|
||||||
|
|
||||||
|
@ -1959,10 +1957,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
||||||
@db_api.retry_if_session_inactive(context_var_name='plugin_context')
|
@db_api.retry_if_session_inactive(context_var_name='plugin_context')
|
||||||
def get_bound_port_context(self, plugin_context, port_id, host=None,
|
def get_bound_port_context(self, plugin_context, port_id, host=None,
|
||||||
cached_networks=None):
|
cached_networks=None):
|
||||||
# NOTE(ihrachys) use writer manager to be able to update mtu when
|
with db_api.CONTEXT_READER.using(plugin_context) as session:
|
||||||
# fetching network
|
|
||||||
# TODO(ihrachys) remove in Queens+ when mtu is not nullable
|
|
||||||
with db_api.CONTEXT_WRITER.using(plugin_context) as session:
|
|
||||||
try:
|
try:
|
||||||
port_db = (session.query(models_v2.Port).
|
port_db = (session.query(models_v2.Port).
|
||||||
enable_eagerloads(False).
|
enable_eagerloads(False).
|
||||||
|
@ -2016,10 +2011,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
||||||
@db_api.retry_if_session_inactive(context_var_name='plugin_context')
|
@db_api.retry_if_session_inactive(context_var_name='plugin_context')
|
||||||
def get_bound_ports_contexts(self, plugin_context, dev_ids, host=None):
|
def get_bound_ports_contexts(self, plugin_context, dev_ids, host=None):
|
||||||
result = {}
|
result = {}
|
||||||
# NOTE(ihrachys) use writer manager to be able to update mtu when
|
with db_api.CONTEXT_READER.using(plugin_context):
|
||||||
# fetching network
|
|
||||||
# TODO(ihrachys) remove in Queens+ when mtu is not nullable
|
|
||||||
with db_api.CONTEXT_WRITER.using(plugin_context):
|
|
||||||
dev_to_full_pids = db.partial_port_ids_to_full_ids(
|
dev_to_full_pids = db.partial_port_ids_to_full_ids(
|
||||||
plugin_context, dev_ids)
|
plugin_context, dev_ids)
|
||||||
# get all port objects for IDs
|
# get all port objects for IDs
|
||||||
|
|
Loading…
Reference in New Issue