Merge "use retry_if_session_inactive from neutron-lib"
This commit is contained in:
commit
5f36615700
@ -25,7 +25,7 @@ from neutron_lib.callbacks import registry
|
|||||||
from neutron_lib.callbacks import resources
|
from neutron_lib.callbacks import resources
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
from neutron_lib import context
|
from neutron_lib import context
|
||||||
from neutron_lib.db import api as lib_db_api
|
from neutron_lib.db import api as db_api
|
||||||
from neutron_lib.db import utils as db_utils
|
from neutron_lib.db import utils as db_utils
|
||||||
from neutron_lib.exceptions import agent as agent_exc
|
from neutron_lib.exceptions import agent as agent_exc
|
||||||
from neutron_lib.exceptions import availability_zone as az_exc
|
from neutron_lib.exceptions import availability_zone as az_exc
|
||||||
@ -43,7 +43,6 @@ from neutron.api.rpc.callbacks import version_manager
|
|||||||
from neutron.common import constants as n_const
|
from neutron.common import constants as n_const
|
||||||
from neutron.conf.agent.database import agents_db
|
from neutron.conf.agent.database import agents_db
|
||||||
from neutron.db import _model_query as model_query
|
from neutron.db import _model_query as model_query
|
||||||
from neutron.db import api as db_api
|
|
||||||
from neutron.db.models import agent as agent_model
|
from neutron.db.models import agent as agent_model
|
||||||
from neutron.extensions import _availability_zone_filter_lib as azfil_ext
|
from neutron.extensions import _availability_zone_filter_lib as azfil_ext
|
||||||
from neutron.extensions import agent as ext_agent
|
from neutron.extensions import agent as ext_agent
|
||||||
@ -305,7 +304,7 @@ class AgentDbMixin(ext_agent.AgentPluginBase, AgentAvailabilityZoneMixin):
|
|||||||
return [self._make_agent_dict(agent, fields=fields)
|
return [self._make_agent_dict(agent, fields=fields)
|
||||||
for agent in agents]
|
for agent in agents]
|
||||||
|
|
||||||
@lib_db_api.retry_db_errors
|
@db_api.retry_db_errors
|
||||||
def agent_health_check(self):
|
def agent_health_check(self):
|
||||||
"""Scan agents and log if some are considered dead."""
|
"""Scan agents and log if some are considered dead."""
|
||||||
agents = self.get_agents(context.get_admin_context(),
|
agents = self.get_agents(context.get_admin_context(),
|
||||||
|
@ -22,8 +22,6 @@ from oslo_config import cfg
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from osprofiler import opts as profiler_opts
|
from osprofiler import opts as profiler_opts
|
||||||
import osprofiler.sqlalchemy
|
import osprofiler.sqlalchemy
|
||||||
from pecan import util as p_util
|
|
||||||
import six
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy import event # noqa
|
from sqlalchemy import event # noqa
|
||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
@ -54,42 +52,6 @@ def _copy_if_lds(item):
|
|||||||
return copy.deepcopy(item) if isinstance(item, (list, dict, set)) else item
|
return copy.deepcopy(item) if isinstance(item, (list, dict, set)) else item
|
||||||
|
|
||||||
|
|
||||||
def retry_if_session_inactive(context_var_name='context'):
|
|
||||||
"""Retries only if the session in the context is inactive.
|
|
||||||
|
|
||||||
Calls a retry_db_errors wrapped version of the function if the context's
|
|
||||||
session passed in is inactive, otherwise it just calls the function
|
|
||||||
directly. This is useful to avoid retrying things inside of a transaction
|
|
||||||
which is ineffective for DB races/errors.
|
|
||||||
|
|
||||||
This should be used in all cases where retries are desired and the method
|
|
||||||
accepts a context.
|
|
||||||
"""
|
|
||||||
def decorator(f):
|
|
||||||
try:
|
|
||||||
# NOTE(kevinbenton): we use pecan's util function here because it
|
|
||||||
# deals with the horrors of finding args of already decorated
|
|
||||||
# functions
|
|
||||||
ctx_arg_index = p_util.getargspec(f).args.index(context_var_name)
|
|
||||||
except ValueError:
|
|
||||||
raise RuntimeError("Could not find position of var %s" %
|
|
||||||
context_var_name)
|
|
||||||
f_with_retry = api.retry_db_errors(f)
|
|
||||||
|
|
||||||
@six.wraps(f)
|
|
||||||
def wrapped(*args, **kwargs):
|
|
||||||
# only use retry wrapper if we aren't nested in an active
|
|
||||||
# transaction
|
|
||||||
if context_var_name in kwargs:
|
|
||||||
context = kwargs[context_var_name]
|
|
||||||
else:
|
|
||||||
context = args[ctx_arg_index]
|
|
||||||
method = f if context.session.is_active else f_with_retry
|
|
||||||
return method(*args, **kwargs)
|
|
||||||
return wrapped
|
|
||||||
return decorator
|
|
||||||
|
|
||||||
|
|
||||||
@event.listens_for(orm.session.Session, "after_flush")
|
@event.listens_for(orm.session.Session, "after_flush")
|
||||||
def add_to_rel_load_list(session, flush_context=None):
|
def add_to_rel_load_list(session, flush_context=None):
|
||||||
# keep track of new items to load relationships on during commit
|
# keep track of new items to load relationships on during commit
|
||||||
|
@ -177,7 +177,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
@registry.receives(resources.RBAC_POLICY, [events.BEFORE_CREATE,
|
@registry.receives(resources.RBAC_POLICY, [events.BEFORE_CREATE,
|
||||||
events.BEFORE_UPDATE,
|
events.BEFORE_UPDATE,
|
||||||
events.BEFORE_DELETE])
|
events.BEFORE_DELETE])
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def validate_network_rbac_policy_change(self, resource, event, trigger,
|
def validate_network_rbac_policy_change(self, resource, event, trigger,
|
||||||
context, object_type, policy,
|
context, object_type, policy,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
@ -380,11 +380,11 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
{'resource': resource, 'item': item})
|
{'resource': resource, 'item': item})
|
||||||
return objects
|
return objects
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_network_bulk(self, context, networks):
|
def create_network_bulk(self, context, networks):
|
||||||
return self._create_bulk('network', context, networks)
|
return self._create_bulk('network', context, networks)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_network(self, context, network):
|
def create_network(self, context, network):
|
||||||
"""Handle creation of a single network."""
|
"""Handle creation of a single network."""
|
||||||
net_db = self.create_network_db(context, network)
|
net_db = self.create_network_db(context, network)
|
||||||
@ -411,7 +411,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
context.session.add(network)
|
context.session.add(network)
|
||||||
return network
|
return network
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def update_network(self, context, id, network):
|
def update_network(self, context, id, network):
|
||||||
n = network['network']
|
n = network['network']
|
||||||
with db_api.context_manager.writer.using(context):
|
with db_api.context_manager.writer.using(context):
|
||||||
@ -459,7 +459,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
if non_auto_ports.count():
|
if non_auto_ports.count():
|
||||||
raise exc.NetworkInUse(net_id=net_id)
|
raise exc.NetworkInUse(net_id=net_id)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def delete_network(self, context, id):
|
def delete_network(self, context, id):
|
||||||
registry.notify(resources.NETWORK, events.BEFORE_DELETE, self,
|
registry.notify(resources.NETWORK, events.BEFORE_DELETE, self,
|
||||||
context=context, network_id=id)
|
context=context, network_id=id)
|
||||||
@ -496,12 +496,12 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
registry.notify(resources.NETWORK, events.AFTER_DELETE,
|
registry.notify(resources.NETWORK, events.AFTER_DELETE,
|
||||||
self, context=context, network=network)
|
self, context=context, network=network)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_network(self, context, id, fields=None):
|
def get_network(self, context, id, fields=None):
|
||||||
network = self._get_network(context, id)
|
network = self._get_network(context, id)
|
||||||
return self._make_network_dict(network, fields, context=context)
|
return self._make_network_dict(network, fields, context=context)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_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,
|
sorts=None, limit=None, marker=None,
|
||||||
page_reverse=False):
|
page_reverse=False):
|
||||||
@ -517,7 +517,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
marker_obj=marker_obj,
|
marker_obj=marker_obj,
|
||||||
page_reverse=page_reverse)
|
page_reverse=page_reverse)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_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,
|
sorts=None, limit=None, marker=None,
|
||||||
page_reverse=False):
|
page_reverse=False):
|
||||||
@ -530,12 +530,12 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
limit=limit, marker=marker, page_reverse=page_reverse)
|
limit=limit, marker=marker, page_reverse=page_reverse)
|
||||||
]
|
]
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_networks_count(self, context, filters=None):
|
def get_networks_count(self, context, filters=None):
|
||||||
return model_query.get_collection_count(context, models_v2.Network,
|
return model_query.get_collection_count(context, models_v2.Network,
|
||||||
filters=filters)
|
filters=filters)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_subnet_bulk(self, context, subnets):
|
def create_subnet_bulk(self, context, subnets):
|
||||||
return self._create_bulk('subnet', context, subnets)
|
return self._create_bulk('subnet', context, subnets)
|
||||||
|
|
||||||
@ -716,7 +716,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
external_gateway_info}}
|
external_gateway_info}}
|
||||||
l3plugin.update_router(context, router_id, info)
|
l3plugin.update_router(context, router_id, info)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def _create_subnet_postcommit(self, context, result, network, ipam_subnet):
|
def _create_subnet_postcommit(self, context, result, network, ipam_subnet):
|
||||||
if hasattr(network, 'external') and network.external:
|
if hasattr(network, 'external') and network.external:
|
||||||
self._update_router_gw_ports(context,
|
self._update_router_gw_ports(context,
|
||||||
@ -779,7 +779,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
msg = _('No default subnetpool found for IPv%s') % ip_version
|
msg = _('No default subnetpool found for IPv%s') % ip_version
|
||||||
raise exc.BadRequest(resource='subnets', msg=msg)
|
raise exc.BadRequest(resource='subnets', msg=msg)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_subnet(self, context, subnet):
|
def create_subnet(self, context, subnet):
|
||||||
result, net, ipam_sub = self._create_subnet_precommit(context, subnet)
|
result, net, ipam_sub = self._create_subnet_precommit(context, subnet)
|
||||||
self._create_subnet_postcommit(context, result, net, ipam_sub)
|
self._create_subnet_postcommit(context, result, net, ipam_sub)
|
||||||
@ -848,7 +848,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
'end': str(netaddr.IPAddress(p.last, subnet['ip_version']))}
|
'end': str(netaddr.IPAddress(p.last, subnet['ip_version']))}
|
||||||
for p in allocation_pools]
|
for p in allocation_pools]
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def update_subnet(self, context, id, subnet):
|
def update_subnet(self, context, id, subnet):
|
||||||
"""Update the subnet with new info.
|
"""Update the subnet with new info.
|
||||||
|
|
||||||
@ -989,7 +989,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
"cannot delete", subnet_id)
|
"cannot delete", subnet_id)
|
||||||
raise exc.SubnetInUse(subnet_id=subnet_id)
|
raise exc.SubnetInUse(subnet_id=subnet_id)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def _remove_subnet_from_port(self, context, sub_id, port_id, auto_subnet):
|
def _remove_subnet_from_port(self, context, sub_id, port_id, auto_subnet):
|
||||||
try:
|
try:
|
||||||
fixed = [f for f in self.get_port(context, port_id)['fixed_ips']
|
fixed = [f for f in self.get_port(context, port_id)['fixed_ips']
|
||||||
@ -1017,7 +1017,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
'subnet': id})
|
'subnet': id})
|
||||||
raise exc.SubnetInUse(subnet_id=id)
|
raise exc.SubnetInUse(subnet_id=id)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def _remove_subnet_ip_allocations_from_ports(self, context, id):
|
def _remove_subnet_ip_allocations_from_ports(self, context, id):
|
||||||
# Do not allow a subnet to be deleted if a router is attached to it
|
# Do not allow a subnet to be deleted if a router is attached to it
|
||||||
self._subnet_check_ip_allocations_internal_router_ports(
|
self._subnet_check_ip_allocations_internal_router_ports(
|
||||||
@ -1035,7 +1035,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
self._remove_subnet_from_port(context, id, port_id,
|
self._remove_subnet_from_port(context, id, port_id,
|
||||||
auto_subnet=is_auto_addr_subnet)
|
auto_subnet=is_auto_addr_subnet)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def delete_subnet(self, context, id):
|
def delete_subnet(self, context, id):
|
||||||
LOG.debug("Deleting subnet %s", id)
|
LOG.debug("Deleting subnet %s", id)
|
||||||
# Make sure the subnet isn't used by other resources
|
# Make sure the subnet isn't used by other resources
|
||||||
@ -1056,12 +1056,12 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
registry.notify(resources.SUBNET, events.AFTER_DELETE,
|
registry.notify(resources.SUBNET, events.AFTER_DELETE,
|
||||||
self, context=context, subnet=subnet.to_dict())
|
self, context=context, subnet=subnet.to_dict())
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_subnet(self, context, id, fields=None):
|
def get_subnet(self, context, id, fields=None):
|
||||||
subnet_obj = self._get_subnet_object(context, id)
|
subnet_obj = self._get_subnet_object(context, id)
|
||||||
return self._make_subnet_dict(subnet_obj, fields, context=context)
|
return self._make_subnet_dict(subnet_obj, fields, context=context)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_subnets(self, context, filters=None, fields=None,
|
def get_subnets(self, context, filters=None, fields=None,
|
||||||
sorts=None, limit=None, marker=None,
|
sorts=None, limit=None, marker=None,
|
||||||
page_reverse=False):
|
page_reverse=False):
|
||||||
@ -1072,13 +1072,13 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
for subnet_object in subnet_objs
|
for subnet_object in subnet_objs
|
||||||
]
|
]
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_subnets_count(self, context, filters=None):
|
def get_subnets_count(self, context, filters=None):
|
||||||
filters = filters or {}
|
filters = filters or {}
|
||||||
return subnet_obj.Subnet.count(context, validate_filters=False,
|
return subnet_obj.Subnet.count(context, validate_filters=False,
|
||||||
**filters)
|
**filters)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_subnets_by_network(self, context, network_id):
|
def get_subnets_by_network(self, context, network_id):
|
||||||
return [self._make_subnet_dict(subnet_obj) for subnet_obj in
|
return [self._make_subnet_dict(subnet_obj) for subnet_obj in
|
||||||
self._get_subnets_by_network(context, network_id)]
|
self._get_subnets_by_network(context, network_id)]
|
||||||
@ -1152,7 +1152,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
"been set. Only one default may exist per IP family")
|
"been set. Only one default may exist per IP family")
|
||||||
raise exc.InvalidInput(error_message=msg)
|
raise exc.InvalidInput(error_message=msg)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_subnetpool(self, context, subnetpool):
|
def create_subnetpool(self, context, subnetpool):
|
||||||
sp = subnetpool['subnetpool']
|
sp = subnetpool['subnetpool']
|
||||||
sp_reader = subnet_alloc.SubnetPoolReader(sp)
|
sp_reader = subnet_alloc.SubnetPoolReader(sp)
|
||||||
@ -1181,7 +1181,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
|
|
||||||
return self._make_subnetpool_dict(subnetpool.db_obj)
|
return self._make_subnetpool_dict(subnetpool.db_obj)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def update_subnetpool(self, context, id, subnetpool):
|
def update_subnetpool(self, context, id, subnetpool):
|
||||||
new_sp = subnetpool['subnetpool']
|
new_sp = subnetpool['subnetpool']
|
||||||
|
|
||||||
@ -1219,12 +1219,12 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
updated, orig_sp.db_obj)
|
updated, orig_sp.db_obj)
|
||||||
return updated
|
return updated
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_subnetpool(self, context, id, fields=None):
|
def get_subnetpool(self, context, id, fields=None):
|
||||||
subnetpool = self._get_subnetpool(context, id)
|
subnetpool = self._get_subnetpool(context, id)
|
||||||
return self._make_subnetpool_dict(subnetpool.db_obj, fields)
|
return self._make_subnetpool_dict(subnetpool.db_obj, fields)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_subnetpools(self, context, filters=None, fields=None,
|
def get_subnetpools(self, context, filters=None, fields=None,
|
||||||
sorts=None, limit=None, marker=None,
|
sorts=None, limit=None, marker=None,
|
||||||
page_reverse=False):
|
page_reverse=False):
|
||||||
@ -1237,7 +1237,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
for pool in subnetpools
|
for pool in subnetpools
|
||||||
]
|
]
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_default_subnetpool(self, context, ip_version):
|
def get_default_subnetpool(self, context, ip_version):
|
||||||
"""Retrieve the default subnetpool for the given IP version."""
|
"""Retrieve the default subnetpool for the given IP version."""
|
||||||
filters = {'is_default': True,
|
filters = {'is_default': True,
|
||||||
@ -1246,7 +1246,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
if subnetpool:
|
if subnetpool:
|
||||||
return subnetpool[0]
|
return subnetpool[0]
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def delete_subnetpool(self, context, id):
|
def delete_subnetpool(self, context, id):
|
||||||
with db_api.context_manager.writer.using(context):
|
with db_api.context_manager.writer.using(context):
|
||||||
subnetpool = self._get_subnetpool(context, id=id)
|
subnetpool = self._get_subnetpool(context, id=id)
|
||||||
@ -1263,7 +1263,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
op=_("mac address update"), port_id=id,
|
op=_("mac address update"), port_id=id,
|
||||||
device_owner=device_owner)
|
device_owner=device_owner)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_port_bulk(self, context, ports):
|
def create_port_bulk(self, context, ports):
|
||||||
return self._create_bulk('port', context, ports)
|
return self._create_bulk('port', context, ports)
|
||||||
|
|
||||||
@ -1280,7 +1280,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
context.session.add(db_port)
|
context.session.add(db_port)
|
||||||
return db_port
|
return db_port
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_port(self, context, port):
|
def create_port(self, context, port):
|
||||||
db_port = self.create_port_db(context, port)
|
db_port = self.create_port_db(context, port)
|
||||||
return self._make_port_dict(db_port, process_extensions=False)
|
return self._make_port_dict(db_port, process_extensions=False)
|
||||||
@ -1344,7 +1344,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
self._check_mac_addr_update(context, db_port,
|
self._check_mac_addr_update(context, db_port,
|
||||||
new_mac, current_owner)
|
new_mac, current_owner)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def update_port(self, context, id, port):
|
def update_port(self, context, id, port):
|
||||||
new_port = port['port']
|
new_port = port['port']
|
||||||
|
|
||||||
@ -1379,7 +1379,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
raise os_db_exc.RetryRequest(e)
|
raise os_db_exc.RetryRequest(e)
|
||||||
return self._make_port_dict(db_port)
|
return self._make_port_dict(db_port)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def delete_port(self, context, id):
|
def delete_port(self, context, id):
|
||||||
with db_api.context_manager.writer.using(context):
|
with db_api.context_manager.writer.using(context):
|
||||||
self.ipam.delete_port(context, id)
|
self.ipam.delete_port(context, id)
|
||||||
@ -1401,7 +1401,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
"The port has already been deleted.",
|
"The port has already been deleted.",
|
||||||
port_id)
|
port_id)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
@db_api.context_manager.reader
|
@db_api.context_manager.reader
|
||||||
def get_port(self, context, id, fields=None):
|
def get_port(self, context, id, fields=None):
|
||||||
port = self._get_port(context, id)
|
port = self._get_port(context, id)
|
||||||
@ -1426,7 +1426,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
Port.fixed_ips.any(IPAllocation.subnet_id.in_(subnet_ids)))
|
Port.fixed_ips.any(IPAllocation.subnet_id.in_(subnet_ids)))
|
||||||
return query
|
return query
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_ports(self, context, filters=None, fields=None,
|
def get_ports(self, context, filters=None, fields=None,
|
||||||
sorts=None, limit=None, marker=None,
|
sorts=None, limit=None, marker=None,
|
||||||
page_reverse=False):
|
page_reverse=False):
|
||||||
@ -1441,7 +1441,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||||||
items.reverse()
|
items.reverse()
|
||||||
return items
|
return items
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_ports_count(self, context, filters=None):
|
def get_ports_count(self, context, filters=None):
|
||||||
return self._get_ports_query(context, filters).count()
|
return self._get_ports_query(context, filters).count()
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ from neutron_lib.callbacks import events
|
|||||||
from neutron_lib.callbacks import registry
|
from neutron_lib.callbacks import registry
|
||||||
from neutron_lib.callbacks import resources
|
from neutron_lib.callbacks import resources
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
|
from neutron_lib.db import api as lib_db_api
|
||||||
from neutron_lib import exceptions as n_exc
|
from neutron_lib import exceptions as n_exc
|
||||||
from neutron_lib.exceptions import dvr as dvr_exc
|
from neutron_lib.exceptions import dvr as dvr_exc
|
||||||
from neutron_lib.objects import exceptions
|
from neutron_lib.objects import exceptions
|
||||||
@ -59,7 +60,7 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase):
|
|||||||
return self._plugin
|
return self._plugin
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def _db_delete_mac_associated_with_agent(context, agent):
|
def _db_delete_mac_associated_with_agent(context, agent):
|
||||||
host = agent['host']
|
host = agent['host']
|
||||||
plugin = directory.get_plugin()
|
plugin = directory.get_plugin()
|
||||||
@ -92,7 +93,7 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase):
|
|||||||
return self._make_dvr_mac_address_dict(dvr_obj)
|
return self._make_dvr_mac_address_dict(dvr_obj)
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def _create_dvr_mac_address_retry(self, context, host, base_mac):
|
def _create_dvr_mac_address_retry(self, context, host, base_mac):
|
||||||
with db_api.context_manager.writer.using(context):
|
with db_api.context_manager.writer.using(context):
|
||||||
mac_address = net.get_random_mac(base_mac)
|
mac_address = net.get_random_mac(base_mac)
|
||||||
@ -141,7 +142,7 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase):
|
|||||||
'mac_address': str(dvr_mac_entry['mac_address'])}
|
'mac_address': str(dvr_mac_entry['mac_address'])}
|
||||||
|
|
||||||
@log_helpers.log_method_call
|
@log_helpers.log_method_call
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_ports_on_host_by_subnet(self, context, host, subnet):
|
def get_ports_on_host_by_subnet(self, context, host, subnet):
|
||||||
"""Returns DVR serviced ports on a given subnet in the input host
|
"""Returns DVR serviced ports on a given subnet in the input host
|
||||||
|
|
||||||
@ -171,7 +172,7 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase):
|
|||||||
return ports
|
return ports
|
||||||
|
|
||||||
@log_helpers.log_method_call
|
@log_helpers.log_method_call
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_subnet_for_dvr(self, context, subnet, fixed_ips=None):
|
def get_subnet_for_dvr(self, context, subnet, fixed_ips=None):
|
||||||
if fixed_ips:
|
if fixed_ips:
|
||||||
subnet_data = fixed_ips[0]['subnet_id']
|
subnet_data = fixed_ips[0]['subnet_id']
|
||||||
|
@ -26,7 +26,7 @@ from neutron_lib.callbacks import registry
|
|||||||
from neutron_lib.callbacks import resources
|
from neutron_lib.callbacks import resources
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
from neutron_lib import context as n_ctx
|
from neutron_lib import context as n_ctx
|
||||||
from neutron_lib.db import api as lib_db_api
|
from neutron_lib.db import api as db_api
|
||||||
from neutron_lib.db import utils as lib_db_utils
|
from neutron_lib.db import utils as lib_db_utils
|
||||||
from neutron_lib import exceptions as n_exc
|
from neutron_lib import exceptions as n_exc
|
||||||
from neutron_lib.exceptions import l3 as l3_exc
|
from neutron_lib.exceptions import l3 as l3_exc
|
||||||
@ -47,7 +47,6 @@ from neutron.common import utils
|
|||||||
from neutron.db import _model_query as model_query
|
from neutron.db import _model_query as model_query
|
||||||
from neutron.db import _resource_extend as resource_extend
|
from neutron.db import _resource_extend as resource_extend
|
||||||
from neutron.db import _utils as db_utils
|
from neutron.db import _utils as db_utils
|
||||||
from neutron.db import api as db_api
|
|
||||||
from neutron.db.models import l3 as l3_models
|
from neutron.db.models import l3 as l3_models
|
||||||
from neutron.db import models_v2
|
from neutron.db import models_v2
|
||||||
from neutron.db import standardattrdescription_db as st_attr
|
from neutron.db import standardattrdescription_db as st_attr
|
||||||
@ -718,7 +717,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
|||||||
raise n_exc.BadRequest(resource='router', msg=msg)
|
raise n_exc.BadRequest(resource='router', msg=msg)
|
||||||
|
|
||||||
def _validate_router_port_info(self, context, router, port_id):
|
def _validate_router_port_info(self, context, router, port_id):
|
||||||
with lib_db_api.autonested_transaction(context.session):
|
with db_api.autonested_transaction(context.session):
|
||||||
# check again within transaction to mitigate race
|
# check again within transaction to mitigate race
|
||||||
port = self._check_router_port(context, port_id, router.id)
|
port = self._check_router_port(context, port_id, router.id)
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ from neutron_lib.callbacks import priority_group
|
|||||||
from neutron_lib.callbacks import registry
|
from neutron_lib.callbacks import registry
|
||||||
from neutron_lib.callbacks import resources
|
from neutron_lib.callbacks import resources
|
||||||
from neutron_lib import constants as const
|
from neutron_lib import constants as const
|
||||||
from neutron_lib.db import api as lib_db_api
|
from neutron_lib.db import api as db_api
|
||||||
from neutron_lib import exceptions as n_exc
|
from neutron_lib import exceptions as n_exc
|
||||||
from neutron_lib.exceptions import agent as agent_exc
|
from neutron_lib.exceptions import agent as agent_exc
|
||||||
from neutron_lib.exceptions import l3 as l3_exc
|
from neutron_lib.exceptions import l3 as l3_exc
|
||||||
@ -40,7 +40,6 @@ from neutron._i18n import _
|
|||||||
from neutron.common import constants as l3_const
|
from neutron.common import constants as l3_const
|
||||||
from neutron.common import utils as n_utils
|
from neutron.common import utils as n_utils
|
||||||
from neutron.conf.db import l3_dvr_db
|
from neutron.conf.db import l3_dvr_db
|
||||||
from neutron.db import api as db_api
|
|
||||||
from neutron.db import l3_attrs_db
|
from neutron.db import l3_attrs_db
|
||||||
from neutron.db import l3_db
|
from neutron.db import l3_db
|
||||||
from neutron.db.models import allowed_address_pair as aap_models
|
from neutron.db.models import allowed_address_pair as aap_models
|
||||||
@ -452,7 +451,7 @@ class DVRResourceOperationHandler(object):
|
|||||||
# with the csnat port.
|
# with the csnat port.
|
||||||
# TODO(kevinbenton): switch to taskflow to manage
|
# TODO(kevinbenton): switch to taskflow to manage
|
||||||
# these rollbacks.
|
# these rollbacks.
|
||||||
@lib_db_api.retry_db_errors
|
@db_api.retry_db_errors
|
||||||
def revert():
|
def revert():
|
||||||
# TODO(kevinbenton): even though we get the
|
# TODO(kevinbenton): even though we get the
|
||||||
# port each time, there is a potential race
|
# port each time, there is a potential race
|
||||||
|
@ -28,6 +28,7 @@ from neutron_lib.callbacks import priority_group
|
|||||||
from neutron_lib.callbacks import registry
|
from neutron_lib.callbacks import registry
|
||||||
from neutron_lib.callbacks import resources
|
from neutron_lib.callbacks import resources
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
|
from neutron_lib.db import api as db_api
|
||||||
from neutron_lib import exceptions as n_exc
|
from neutron_lib import exceptions as n_exc
|
||||||
from neutron_lib.exceptions import l3 as l3_exc
|
from neutron_lib.exceptions import l3 as l3_exc
|
||||||
from neutron_lib.exceptions import l3_ext_ha_mode as l3ha_exc
|
from neutron_lib.exceptions import l3_ext_ha_mode as l3ha_exc
|
||||||
@ -48,7 +49,6 @@ from neutron.common import constants as n_const
|
|||||||
from neutron.common import utils as n_utils
|
from neutron.common import utils as n_utils
|
||||||
from neutron.conf.db import l3_hamode_db
|
from neutron.conf.db import l3_hamode_db
|
||||||
from neutron.db import _utils as db_utils
|
from neutron.db import _utils as db_utils
|
||||||
from neutron.db import api as db_api
|
|
||||||
from neutron.db.availability_zone import router as router_az_db
|
from neutron.db.availability_zone import router as router_az_db
|
||||||
from neutron.db import l3_dvr_db
|
from neutron.db import l3_dvr_db
|
||||||
from neutron.db.models import l3ha as l3ha_model
|
from neutron.db.models import l3ha as l3ha_model
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
from neutron_lib.callbacks import registry
|
from neutron_lib.callbacks import registry
|
||||||
from neutron_lib.callbacks import resources
|
from neutron_lib.callbacks import resources
|
||||||
|
from neutron_lib.db import api as db_api
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from neutron.db import api as db_api
|
|
||||||
from neutron.db import models_v2
|
from neutron.db import models_v2
|
||||||
from neutron.objects import provisioning_blocks as pb_obj
|
from neutron.objects import provisioning_blocks as pb_obj
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
import collections
|
import collections
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
from neutron_lib.db import api as lib_db_api
|
||||||
|
|
||||||
from neutron.db import api as db_api
|
from neutron.db import api as db_api
|
||||||
from neutron.objects import quota as quota_obj
|
from neutron.objects import quota as quota_obj
|
||||||
|
|
||||||
@ -35,7 +37,7 @@ class ReservationInfo(collections.namedtuple(
|
|||||||
"""Information about a resource reservation."""
|
"""Information about a resource reservation."""
|
||||||
|
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_quota_usage_by_resource_and_tenant(context, resource, tenant_id):
|
def get_quota_usage_by_resource_and_tenant(context, resource, tenant_id):
|
||||||
"""Return usage info for a given resource and tenant.
|
"""Return usage info for a given resource and tenant.
|
||||||
|
|
||||||
@ -53,7 +55,7 @@ def get_quota_usage_by_resource_and_tenant(context, resource, tenant_id):
|
|||||||
result.dirty)
|
result.dirty)
|
||||||
|
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_quota_usage_by_resource(context, resource):
|
def get_quota_usage_by_resource(context, resource):
|
||||||
objs = quota_obj.QuotaUsage.get_objects(context, resource=resource)
|
objs = quota_obj.QuotaUsage.get_objects(context, resource=resource)
|
||||||
return [QuotaUsageInfo(item.resource,
|
return [QuotaUsageInfo(item.resource,
|
||||||
@ -62,7 +64,7 @@ def get_quota_usage_by_resource(context, resource):
|
|||||||
item.dirty) for item in objs]
|
item.dirty) for item in objs]
|
||||||
|
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_quota_usage_by_tenant_id(context, tenant_id):
|
def get_quota_usage_by_tenant_id(context, tenant_id):
|
||||||
objs = quota_obj.QuotaUsage.get_objects(context, project_id=tenant_id)
|
objs = quota_obj.QuotaUsage.get_objects(context, project_id=tenant_id)
|
||||||
return [QuotaUsageInfo(item.resource,
|
return [QuotaUsageInfo(item.resource,
|
||||||
@ -71,7 +73,7 @@ def get_quota_usage_by_tenant_id(context, tenant_id):
|
|||||||
item.dirty) for item in objs]
|
item.dirty) for item in objs]
|
||||||
|
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def set_quota_usage(context, resource, tenant_id,
|
def set_quota_usage(context, resource, tenant_id,
|
||||||
in_use=None, delta=False):
|
in_use=None, delta=False):
|
||||||
"""Set resource quota usage.
|
"""Set resource quota usage.
|
||||||
@ -105,7 +107,7 @@ def set_quota_usage(context, resource, tenant_id,
|
|||||||
usage_data.in_use, usage_data.dirty)
|
usage_data.in_use, usage_data.dirty)
|
||||||
|
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
@db_api.context_manager.writer
|
@db_api.context_manager.writer
|
||||||
def set_quota_usage_dirty(context, resource, tenant_id, dirty=True):
|
def set_quota_usage_dirty(context, resource, tenant_id, dirty=True):
|
||||||
"""Set quota usage dirty bit for a given resource and tenant.
|
"""Set quota usage dirty bit for a given resource and tenant.
|
||||||
@ -124,7 +126,7 @@ def set_quota_usage_dirty(context, resource, tenant_id, dirty=True):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
@db_api.context_manager.writer
|
@db_api.context_manager.writer
|
||||||
def set_resources_quota_usage_dirty(context, resources, tenant_id, dirty=True):
|
def set_resources_quota_usage_dirty(context, resources, tenant_id, dirty=True):
|
||||||
"""Set quota usage dirty bit for a given tenant and multiple resources.
|
"""Set quota usage dirty bit for a given tenant and multiple resources.
|
||||||
@ -145,7 +147,7 @@ def set_resources_quota_usage_dirty(context, resources, tenant_id, dirty=True):
|
|||||||
return len(objs)
|
return len(objs)
|
||||||
|
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
@db_api.context_manager.writer
|
@db_api.context_manager.writer
|
||||||
def set_all_quota_usage_dirty(context, resource, dirty=True):
|
def set_all_quota_usage_dirty(context, resource, dirty=True):
|
||||||
"""Set the dirty bit on quota usage for all tenants.
|
"""Set the dirty bit on quota usage for all tenants.
|
||||||
@ -163,7 +165,7 @@ def set_all_quota_usage_dirty(context, resource, dirty=True):
|
|||||||
return len(objs)
|
return len(objs)
|
||||||
|
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_reservation(context, tenant_id, deltas, expiration=None):
|
def create_reservation(context, tenant_id, deltas, expiration=None):
|
||||||
# This method is usually called from within another transaction.
|
# This method is usually called from within another transaction.
|
||||||
# Consider using begin_nested
|
# Consider using begin_nested
|
||||||
@ -183,7 +185,7 @@ def create_reservation(context, tenant_id, deltas, expiration=None):
|
|||||||
for delta in reserv_obj.resource_deltas))
|
for delta in reserv_obj.resource_deltas))
|
||||||
|
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_reservation(context, reservation_id):
|
def get_reservation(context, reservation_id):
|
||||||
reserv_obj = quota_obj.Reservation.get_object(context, id=reservation_id)
|
reserv_obj = quota_obj.Reservation.get_object(context, id=reservation_id)
|
||||||
if not reserv_obj:
|
if not reserv_obj:
|
||||||
@ -195,7 +197,7 @@ def get_reservation(context, reservation_id):
|
|||||||
for delta in reserv_obj.resource_deltas))
|
for delta in reserv_obj.resource_deltas))
|
||||||
|
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
@db_api.context_manager.writer
|
@db_api.context_manager.writer
|
||||||
def remove_reservation(context, reservation_id, set_dirty=False):
|
def remove_reservation(context, reservation_id, set_dirty=False):
|
||||||
reservation = quota_obj.Reservation.get_object(context, id=reservation_id)
|
reservation = quota_obj.Reservation.get_object(context, id=reservation_id)
|
||||||
@ -212,7 +214,7 @@ def remove_reservation(context, reservation_id, set_dirty=False):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_reservations_for_resources(context, tenant_id, resources,
|
def get_reservations_for_resources(context, tenant_id, resources,
|
||||||
expired=False):
|
expired=False):
|
||||||
"""Retrieve total amount of reservations for specified resources.
|
"""Retrieve total amount of reservations for specified resources.
|
||||||
@ -231,7 +233,7 @@ def get_reservations_for_resources(context, tenant_id, resources,
|
|||||||
context, utcnow(), tenant_id, resources, expired)
|
context, utcnow(), tenant_id, resources, expired)
|
||||||
|
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
@db_api.context_manager.writer
|
@db_api.context_manager.writer
|
||||||
def remove_expired_reservations(context, tenant_id=None):
|
def remove_expired_reservations(context, tenant_id=None):
|
||||||
return quota_obj.Reservation.delete_expired(context, utcnow(), tenant_id)
|
return quota_obj.Reservation.delete_expired(context, utcnow(), tenant_id)
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from neutron_lib.api import attributes
|
from neutron_lib.api import attributes
|
||||||
|
from neutron_lib.db import api as lib_db_api
|
||||||
from neutron_lib import exceptions
|
from neutron_lib import exceptions
|
||||||
from neutron_lib.plugins import constants
|
from neutron_lib.plugins import constants
|
||||||
from neutron_lib.plugins import directory
|
from neutron_lib.plugins import directory
|
||||||
@ -52,7 +53,7 @@ class DbQuotaDriver(object):
|
|||||||
for key, resource in resources.items())
|
for key, resource in resources.items())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_tenant_quotas(context, resources, tenant_id):
|
def get_tenant_quotas(context, resources, tenant_id):
|
||||||
"""Given a list of resources, retrieve the quotas for the given
|
"""Given a list of resources, retrieve the quotas for the given
|
||||||
tenant. If no limits are found for the specified tenant, the operation
|
tenant. If no limits are found for the specified tenant, the operation
|
||||||
@ -76,7 +77,7 @@ class DbQuotaDriver(object):
|
|||||||
return tenant_quota
|
return tenant_quota
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_detailed_tenant_quotas(context, resources, tenant_id):
|
def get_detailed_tenant_quotas(context, resources, tenant_id):
|
||||||
"""Given a list of resources and a sepecific tenant, retrieve
|
"""Given a list of resources and a sepecific tenant, retrieve
|
||||||
the detailed quotas (limit, used, reserved).
|
the detailed quotas (limit, used, reserved).
|
||||||
@ -111,7 +112,7 @@ class DbQuotaDriver(object):
|
|||||||
return tenant_quota_ext
|
return tenant_quota_ext
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def delete_tenant_quota(context, tenant_id):
|
def delete_tenant_quota(context, tenant_id):
|
||||||
"""Delete the quota entries for a given tenant_id.
|
"""Delete the quota entries for a given tenant_id.
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ class DbQuotaDriver(object):
|
|||||||
raise n_exc.TenantQuotaNotFound(tenant_id=tenant_id)
|
raise n_exc.TenantQuotaNotFound(tenant_id=tenant_id)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_all_quotas(context, resources):
|
def get_all_quotas(context, resources):
|
||||||
"""Given a list of resources, retrieve the quotas for the all tenants.
|
"""Given a list of resources, retrieve the quotas for the all tenants.
|
||||||
|
|
||||||
@ -158,7 +159,7 @@ class DbQuotaDriver(object):
|
|||||||
return list(all_tenant_quotas.values())
|
return list(all_tenant_quotas.values())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def update_quota_limit(context, tenant_id, resource, limit):
|
def update_quota_limit(context, tenant_id, resource, limit):
|
||||||
tenant_quotas = quota_obj.Quota.get_objects(
|
tenant_quotas = quota_obj.Quota.get_objects(
|
||||||
context, project_id=tenant_id, resource=resource)
|
context, project_id=tenant_id, resource=resource)
|
||||||
@ -193,7 +194,7 @@ class DbQuotaDriver(object):
|
|||||||
quota_api.remove_expired_reservations(
|
quota_api.remove_expired_reservations(
|
||||||
context, tenant_id=tenant_id)
|
context, tenant_id=tenant_id)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def make_reservation(self, context, tenant_id, resources, deltas, plugin):
|
def make_reservation(self, context, tenant_id, resources, deltas, plugin):
|
||||||
# Lock current reservation table
|
# Lock current reservation table
|
||||||
# NOTE(salv-orlando): This routine uses DB write locks.
|
# NOTE(salv-orlando): This routine uses DB write locks.
|
||||||
|
@ -17,13 +17,13 @@ from neutron_lib.callbacks import events
|
|||||||
from neutron_lib.callbacks import exceptions as c_exc
|
from neutron_lib.callbacks import exceptions as c_exc
|
||||||
from neutron_lib.callbacks import registry
|
from neutron_lib.callbacks import registry
|
||||||
from neutron_lib.callbacks import resources
|
from neutron_lib.callbacks import resources
|
||||||
|
from neutron_lib.db import api as db_api
|
||||||
from neutron_lib.db import utils as db_utils
|
from neutron_lib.db import utils as db_utils
|
||||||
from neutron_lib import exceptions as n_exc
|
from neutron_lib import exceptions as n_exc
|
||||||
from oslo_db import exception as db_exc
|
from oslo_db import exception as db_exc
|
||||||
from sqlalchemy.orm import exc
|
from sqlalchemy.orm import exc
|
||||||
|
|
||||||
from neutron.db import _model_query as model_query
|
from neutron.db import _model_query as model_query
|
||||||
from neutron.db import api as db_api
|
|
||||||
from neutron.db import common_db_mixin
|
from neutron.db import common_db_mixin
|
||||||
from neutron.db import rbac_db_models as models
|
from neutron.db import rbac_db_models as models
|
||||||
from neutron.extensions import rbac as ext_rbac
|
from neutron.extensions import rbac as ext_rbac
|
||||||
|
@ -20,6 +20,7 @@ from neutron_lib.callbacks import exceptions
|
|||||||
from neutron_lib.callbacks import registry
|
from neutron_lib.callbacks import registry
|
||||||
from neutron_lib.callbacks import resources
|
from neutron_lib.callbacks import resources
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
|
from neutron_lib.db import api as lib_db_api
|
||||||
from neutron_lib.db import utils as db_utils
|
from neutron_lib.db import utils as db_utils
|
||||||
from neutron_lib import exceptions as n_exc
|
from neutron_lib import exceptions as n_exc
|
||||||
from neutron_lib.utils import helpers
|
from neutron_lib.utils import helpers
|
||||||
@ -67,7 +68,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
{'event': event, 'reason': e})
|
{'event': event, 'reason': e})
|
||||||
raise exc_cls(reason=reason, id=id)
|
raise exc_cls(reason=reason, id=id)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_security_group(self, context, security_group, default_sg=False):
|
def create_security_group(self, context, security_group, default_sg=False):
|
||||||
"""Create security group.
|
"""Create security group.
|
||||||
|
|
||||||
@ -133,7 +134,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
**kwargs)
|
**kwargs)
|
||||||
return secgroup_dict
|
return secgroup_dict
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_security_groups(self, context, filters=None, fields=None,
|
def get_security_groups(self, context, filters=None, fields=None,
|
||||||
sorts=None, limit=None,
|
sorts=None, limit=None,
|
||||||
marker=None, page_reverse=False, default_sg=False):
|
marker=None, page_reverse=False, default_sg=False):
|
||||||
@ -159,13 +160,13 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
|
|
||||||
return [self._make_security_group_dict(obj, fields) for obj in sg_objs]
|
return [self._make_security_group_dict(obj, fields) for obj in sg_objs]
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_security_groups_count(self, context, filters=None):
|
def get_security_groups_count(self, context, filters=None):
|
||||||
filters = filters or {}
|
filters = filters or {}
|
||||||
return sg_obj.SecurityGroup.count(
|
return sg_obj.SecurityGroup.count(
|
||||||
context, validate_filters=False, **filters)
|
context, validate_filters=False, **filters)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_security_group(self, context, id, fields=None, tenant_id=None):
|
def get_security_group(self, context, id, fields=None, tenant_id=None):
|
||||||
"""Tenant id is given to handle the case when creating a security
|
"""Tenant id is given to handle the case when creating a security
|
||||||
group rule on behalf of another use.
|
group rule on behalf of another use.
|
||||||
@ -192,7 +193,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
raise ext_sg.SecurityGroupNotFound(id=id)
|
raise ext_sg.SecurityGroupNotFound(id=id)
|
||||||
return sg
|
return sg
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def delete_security_group(self, context, id):
|
def delete_security_group(self, context, id):
|
||||||
filters = {'security_group_id': [id]}
|
filters = {'security_group_id': [id]}
|
||||||
with db_api.context_manager.reader.using(context):
|
with db_api.context_manager.reader.using(context):
|
||||||
@ -234,7 +235,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
registry.notify(resources.SECURITY_GROUP, events.AFTER_DELETE,
|
registry.notify(resources.SECURITY_GROUP, events.AFTER_DELETE,
|
||||||
self, **kwargs)
|
self, **kwargs)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def update_security_group(self, context, id, security_group):
|
def update_security_group(self, context, id, security_group):
|
||||||
s = security_group['security_group']
|
s = security_group['security_group']
|
||||||
|
|
||||||
@ -287,7 +288,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
'security_group_id': security_group['security_group_id']}
|
'security_group_id': security_group['security_group_id']}
|
||||||
return db_utils.resource_fields(res, fields)
|
return db_utils.resource_fields(res, fields)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def _create_port_security_group_binding(self, context, port_id,
|
def _create_port_security_group_binding(self, context, port_id,
|
||||||
security_group_id):
|
security_group_id):
|
||||||
with db_api.context_manager.writer.using(context):
|
with db_api.context_manager.writer.using(context):
|
||||||
@ -302,7 +303,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
self._make_security_group_binding_dict,
|
self._make_security_group_binding_dict,
|
||||||
filters=filters, fields=fields)
|
filters=filters, fields=fields)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def _delete_port_security_group_bindings(self, context, port_id):
|
def _delete_port_security_group_bindings(self, context, port_id):
|
||||||
with db_api.context_manager.writer.using(context):
|
with db_api.context_manager.writer.using(context):
|
||||||
query = model_query.query_with_hooks(
|
query = model_query.query_with_hooks(
|
||||||
@ -312,12 +313,12 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
for binding in bindings:
|
for binding in bindings:
|
||||||
context.session.delete(binding)
|
context.session.delete(binding)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_security_group_rule_bulk(self, context, security_group_rules):
|
def create_security_group_rule_bulk(self, context, security_group_rules):
|
||||||
return self._create_bulk('security_group_rule', context,
|
return self._create_bulk('security_group_rule', context,
|
||||||
security_group_rules)
|
security_group_rules)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_security_group_rule_bulk_native(self, context,
|
def create_security_group_rule_bulk_native(self, context,
|
||||||
security_group_rules):
|
security_group_rules):
|
||||||
rules = security_group_rules['security_group_rules']
|
rules = security_group_rules['security_group_rules']
|
||||||
@ -340,7 +341,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
context=context, security_group_rule=rdict)
|
context=context, security_group_rule=rdict)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_security_group_rule(self, context, security_group_rule):
|
def create_security_group_rule(self, context, security_group_rule):
|
||||||
res = self._create_security_group_rule(context, security_group_rule)
|
res = self._create_security_group_rule(context, security_group_rule)
|
||||||
registry.notify(
|
registry.notify(
|
||||||
@ -662,7 +663,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
raise ext_sg.SecurityGroupRuleParameterConflict(
|
raise ext_sg.SecurityGroupRuleParameterConflict(
|
||||||
ethertype=rule['ethertype'], cidr=input_prefix)
|
ethertype=rule['ethertype'], cidr=input_prefix)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_security_group_rules(self, context, filters=None, fields=None,
|
def get_security_group_rules(self, context, filters=None, fields=None,
|
||||||
sorts=None, limit=None, marker=None,
|
sorts=None, limit=None, marker=None,
|
||||||
page_reverse=False):
|
page_reverse=False):
|
||||||
@ -678,13 +679,13 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
for obj in rule_objs
|
for obj in rule_objs
|
||||||
]
|
]
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_security_group_rules_count(self, context, filters=None):
|
def get_security_group_rules_count(self, context, filters=None):
|
||||||
filters = filters or {}
|
filters = filters or {}
|
||||||
return sg_obj.SecurityGroupRule.count(
|
return sg_obj.SecurityGroupRule.count(
|
||||||
context, validate_filters=False, **filters)
|
context, validate_filters=False, **filters)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_security_group_rule(self, context, id, fields=None):
|
def get_security_group_rule(self, context, id, fields=None):
|
||||||
security_group_rule = self._get_security_group_rule(context, id)
|
security_group_rule = self._get_security_group_rule(context, id)
|
||||||
return self._make_security_group_rule_dict(
|
return self._make_security_group_rule_dict(
|
||||||
@ -696,7 +697,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
raise ext_sg.SecurityGroupRuleNotFound(id=id)
|
raise ext_sg.SecurityGroupRuleNotFound(id=id)
|
||||||
return sgr
|
return sgr
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def delete_security_group_rule(self, context, id):
|
def delete_security_group_rule(self, context, id):
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'context': context,
|
'context': context,
|
||||||
|
@ -18,10 +18,10 @@ from neutron_lib.callbacks import events
|
|||||||
from neutron_lib.callbacks import registry
|
from neutron_lib.callbacks import registry
|
||||||
from neutron_lib.callbacks import resources
|
from neutron_lib.callbacks import resources
|
||||||
from neutron_lib import constants as const
|
from neutron_lib import constants as const
|
||||||
|
from neutron_lib.db import api as db_api
|
||||||
from neutron_lib.utils import helpers
|
from neutron_lib.utils import helpers
|
||||||
|
|
||||||
from neutron._i18n import _
|
from neutron._i18n import _
|
||||||
from neutron.db import api as db_api
|
|
||||||
from neutron.db.models import allowed_address_pair as aap_models
|
from neutron.db.models import allowed_address_pair as aap_models
|
||||||
from neutron.db.models import securitygroup as sg_models
|
from neutron.db.models import securitygroup as sg_models
|
||||||
from neutron.db import models_v2
|
from neutron.db import models_v2
|
||||||
|
@ -877,7 +877,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
return result, mech_context
|
return result, mech_context
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_network(self, context, network):
|
def create_network(self, context, network):
|
||||||
self._before_create_network(context, network)
|
self._before_create_network(context, network)
|
||||||
result, mech_context = self._create_network_db(context, network)
|
result, mech_context = self._create_network_db(context, network)
|
||||||
@ -897,14 +897,14 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_network_bulk(self, context, networks):
|
def create_network_bulk(self, context, networks):
|
||||||
objects = self._create_bulk_ml2(
|
objects = self._create_bulk_ml2(
|
||||||
net_def.RESOURCE_NAME, context, networks)
|
net_def.RESOURCE_NAME, context, networks)
|
||||||
return [obj['result'] for obj in objects]
|
return [obj['result'] for obj in objects]
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def update_network(self, context, id, network):
|
def update_network(self, context, id, network):
|
||||||
net_data = network[net_def.RESOURCE_NAME]
|
net_data = network[net_def.RESOURCE_NAME]
|
||||||
provider._raise_if_updates_provider_attributes(net_data)
|
provider._raise_if_updates_provider_attributes(net_data)
|
||||||
@ -971,7 +971,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
self.notifier.network_update(context, updated_network)
|
self.notifier.network_update(context, updated_network)
|
||||||
return updated_network
|
return updated_network
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_network(self, context, id, fields=None):
|
def get_network(self, context, id, fields=None):
|
||||||
# NOTE(ihrachys) use writer manager to be able to update mtu
|
# NOTE(ihrachys) use writer manager to be able to update mtu
|
||||||
# TODO(ihrachys) remove in Queens+ when mtu is not nullable
|
# TODO(ihrachys) remove in Queens+ when mtu is not nullable
|
||||||
@ -989,7 +989,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
|
|
||||||
return db_utils.resource_fields(net_data, fields)
|
return db_utils.resource_fields(net_data, fields)
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_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
|
# NOTE(ihrachys) use writer manager to be able to update mtu
|
||||||
@ -1092,7 +1092,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
return result, mech_context
|
return result, mech_context
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_subnet(self, context, subnet):
|
def create_subnet(self, context, subnet):
|
||||||
self._before_create_subnet(context, subnet)
|
self._before_create_subnet(context, subnet)
|
||||||
result, mech_context = self._create_subnet_db(context, subnet)
|
result, mech_context = self._create_subnet_db(context, subnet)
|
||||||
@ -1111,14 +1111,14 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_subnet_bulk(self, context, subnets):
|
def create_subnet_bulk(self, context, subnets):
|
||||||
objects = self._create_bulk_ml2(
|
objects = self._create_bulk_ml2(
|
||||||
subnet_def.RESOURCE_NAME, context, subnets)
|
subnet_def.RESOURCE_NAME, context, subnets)
|
||||||
return [obj['result'] for obj in objects]
|
return [obj['result'] for obj in objects]
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def update_subnet(self, context, id, subnet):
|
def update_subnet(self, context, id, subnet):
|
||||||
with db_api.context_manager.writer.using(context):
|
with db_api.context_manager.writer.using(context):
|
||||||
updated_subnet, original_subnet = self._update_subnet_precommit(
|
updated_subnet, original_subnet = self._update_subnet_precommit(
|
||||||
@ -1252,7 +1252,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
return result, mech_context
|
return result, mech_context
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_port(self, context, port):
|
def create_port(self, context, port):
|
||||||
self._before_create_port(context, port)
|
self._before_create_port(context, port)
|
||||||
result, mech_context = self._create_port_db(context, port)
|
result, mech_context = self._create_port_db(context, port)
|
||||||
@ -1281,7 +1281,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
return bound_context.current
|
return bound_context.current
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_port_bulk(self, context, ports):
|
def create_port_bulk(self, context, ports):
|
||||||
objects = self._create_bulk_ml2(port_def.RESOURCE_NAME, context, ports)
|
objects = self._create_bulk_ml2(port_def.RESOURCE_NAME, context, ports)
|
||||||
return [obj['result'] for obj in objects]
|
return [obj['result'] for obj in objects]
|
||||||
@ -1330,7 +1330,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
raise psec_exc.PortSecurityPortHasSecurityGroup()
|
raise psec_exc.PortSecurityPortHasSecurityGroup()
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def update_port(self, context, id, port):
|
def update_port(self, context, id, port):
|
||||||
attrs = port[port_def.RESOURCE_NAME]
|
attrs = port[port_def.RESOURCE_NAME]
|
||||||
need_port_update_notify = False
|
need_port_update_notify = False
|
||||||
@ -1492,7 +1492,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
binding.persist_state_to_session(plugin_context.session)
|
binding.persist_state_to_session(plugin_context.session)
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def update_distributed_port_binding(self, context, id, port):
|
def update_distributed_port_binding(self, context, id, port):
|
||||||
attrs = port[port_def.RESOURCE_NAME]
|
attrs = port[port_def.RESOURCE_NAME]
|
||||||
|
|
||||||
@ -1550,7 +1550,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
raise exc.ServicePortInUse(port_id=port_id, reason=e)
|
raise exc.ServicePortInUse(port_id=port_id, reason=e)
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def delete_port(self, context, id, l3_port_check=True):
|
def delete_port(self, context, id, l3_port_check=True):
|
||||||
self._pre_delete_port(context, id, l3_port_check)
|
self._pre_delete_port(context, id, l3_port_check)
|
||||||
# TODO(armax): get rid of the l3 dependency in the with block
|
# TODO(armax): get rid of the l3 dependency in the with block
|
||||||
@ -1636,7 +1636,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
self.notifier.port_delete(context, port['id'])
|
self.notifier.port_delete(context, port['id'])
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive(context_var_name='plugin_context')
|
@lib_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
|
# NOTE(ihrachys) use writer manager to be able to update mtu when
|
||||||
@ -1693,7 +1693,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
return self._bind_port_if_needed(port_context)
|
return self._bind_port_if_needed(port_context)
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive(context_var_name='plugin_context')
|
@lib_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
|
# NOTE(ihrachys) use writer manager to be able to update mtu when
|
||||||
@ -1758,7 +1758,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
context, {port_id: status}, host)[port_id]
|
context, {port_id: status}, host)[port_id]
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def update_port_statuses(self, context, port_id_to_status, host=None):
|
def update_port_statuses(self, context, port_id_to_status, host=None):
|
||||||
result = {}
|
result = {}
|
||||||
port_ids = port_id_to_status.keys()
|
port_ids = port_id_to_status.keys()
|
||||||
@ -1866,7 +1866,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
|
|
||||||
return port['id']
|
return port['id']
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def port_bound_to_host(self, context, port_id, host):
|
def port_bound_to_host(self, context, port_id, host):
|
||||||
if not host:
|
if not host:
|
||||||
return
|
return
|
||||||
@ -1886,7 +1886,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
port_host = db.get_port_binding_host(context, port_id)
|
port_host = db.get_port_binding_host(context, port_id)
|
||||||
return port if (port_host == host) else None
|
return port if (port_host == host) else None
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_ports_from_devices(self, context, devices):
|
def get_ports_from_devices(self, context, devices):
|
||||||
port_ids_to_devices = dict(
|
port_ids_to_devices = dict(
|
||||||
(self._device_to_port_id(context, device), device)
|
(self._device_to_port_id(context, device), device)
|
||||||
@ -2051,7 +2051,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
mech_context._plugin_context.session)
|
mech_context._plugin_context.session)
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def create_port_binding(self, context, port_id, binding):
|
def create_port_binding(self, context, port_id, binding):
|
||||||
attrs = binding[pbe_ext.RESOURCE_NAME]
|
attrs = binding[pbe_ext.RESOURCE_NAME]
|
||||||
with db_api.context_manager.writer.using(context):
|
with db_api.context_manager.writer.using(context):
|
||||||
@ -2097,7 +2097,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
return self._make_port_binding_dict(bind_context._binding)
|
return self._make_port_binding_dict(bind_context._binding)
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_port_bindings(self, context, port_id, filters=None, fields=None,
|
def get_port_bindings(self, context, port_id, filters=None, fields=None,
|
||||||
sorts=None, limit=None, marker=None,
|
sorts=None, limit=None, marker=None,
|
||||||
page_reverse=False):
|
page_reverse=False):
|
||||||
@ -2114,7 +2114,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
for binding in bindings]
|
for binding in bindings]
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def get_port_binding(self, context, host, port_id, fields=None):
|
def get_port_binding(self, context, host, port_id, fields=None):
|
||||||
port = ports_obj.Port.get_object(context, id=port_id)
|
port = ports_obj.Port.get_object(context, id=port_id)
|
||||||
if not port:
|
if not port:
|
||||||
@ -2132,7 +2132,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
return binding
|
return binding
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def update_port_binding(self, context, host, port_id, binding):
|
def update_port_binding(self, context, host, port_id, binding):
|
||||||
attrs = binding[pbe_ext.RESOURCE_NAME]
|
attrs = binding[pbe_ext.RESOURCE_NAME]
|
||||||
with db_api.context_manager.writer.using(context):
|
with db_api.context_manager.writer.using(context):
|
||||||
@ -2166,7 +2166,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
return self._make_port_binding_dict(bind_context._binding)
|
return self._make_port_binding_dict(bind_context._binding)
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def activate(self, context, host, port_id):
|
def activate(self, context, host, port_id):
|
||||||
with db_api.context_manager.writer.using(context):
|
with db_api.context_manager.writer.using(context):
|
||||||
# TODO(mlavalle) Next two lines can be removed when bug #1770267 is
|
# TODO(mlavalle) Next two lines can be removed when bug #1770267 is
|
||||||
@ -2218,7 +2218,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
raise n_exc.PortBindingError(port_id=port_id, host=host)
|
raise n_exc.PortBindingError(port_id=port_id, host=host)
|
||||||
|
|
||||||
@utils.transaction_guard
|
@utils.transaction_guard
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def delete_port_binding(self, context, host, port_id):
|
def delete_port_binding(self, context, host, port_id):
|
||||||
ports_obj.PortBinding.delete_objects(context, host=host,
|
ports_obj.PortBinding.delete_objects(context, host=host,
|
||||||
port_id=port_id)
|
port_id=port_id)
|
||||||
|
@ -219,7 +219,7 @@ class TrackedResource(BaseResource):
|
|||||||
# can happen is two or more workers are trying to create a resource of a
|
# can happen is two or more workers are trying to create a resource of a
|
||||||
# give kind for the same tenant concurrently. Retrying the operation will
|
# give kind for the same tenant concurrently. Retrying the operation will
|
||||||
# ensure that an UPDATE statement is emitted rather than an INSERT one
|
# ensure that an UPDATE statement is emitted rather than an INSERT one
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def _set_quota_usage(self, context, tenant_id, in_use):
|
def _set_quota_usage(self, context, tenant_id, in_use):
|
||||||
return quota_api.set_quota_usage(
|
return quota_api.set_quota_usage(
|
||||||
context, self.name, tenant_id, in_use=in_use)
|
context, self.name, tenant_id, in_use=in_use)
|
||||||
|
@ -20,6 +20,7 @@ from neutron_lib.api.definitions import network as net_def
|
|||||||
from neutron_lib.callbacks import events
|
from neutron_lib.callbacks import events
|
||||||
from neutron_lib.callbacks import registry
|
from neutron_lib.callbacks import registry
|
||||||
from neutron_lib.callbacks import resources
|
from neutron_lib.callbacks import resources
|
||||||
|
from neutron_lib.db import api as db_api
|
||||||
from neutron_lib.db import utils as db_utils
|
from neutron_lib.db import utils as db_utils
|
||||||
from neutron_lib import exceptions as n_exc
|
from neutron_lib import exceptions as n_exc
|
||||||
from neutron_lib.objects import exceptions as obj_exc
|
from neutron_lib.objects import exceptions as obj_exc
|
||||||
@ -31,7 +32,6 @@ from oslo_log import log as logging
|
|||||||
from neutron._i18n import _
|
from neutron._i18n import _
|
||||||
from neutron.common import exceptions as c_exc
|
from neutron.common import exceptions as c_exc
|
||||||
from neutron.db import _resource_extend as resource_extend
|
from neutron.db import _resource_extend as resource_extend
|
||||||
from neutron.db import api as db_api
|
|
||||||
from neutron.db import common_db_mixin
|
from neutron.db import common_db_mixin
|
||||||
from neutron.objects import auto_allocate as auto_allocate_obj
|
from neutron.objects import auto_allocate as auto_allocate_obj
|
||||||
from neutron.objects import base as base_obj
|
from neutron.objects import base as base_obj
|
||||||
|
@ -23,6 +23,7 @@ from neutron_lib.callbacks import events
|
|||||||
from neutron_lib.callbacks import registry
|
from neutron_lib.callbacks import registry
|
||||||
from neutron_lib.callbacks import resources
|
from neutron_lib.callbacks import resources
|
||||||
from neutron_lib import constants as lib_consts
|
from neutron_lib import constants as lib_consts
|
||||||
|
from neutron_lib.db import api as lib_db_api
|
||||||
from neutron_lib.db import utils as db_utils
|
from neutron_lib.db import utils as db_utils
|
||||||
from neutron_lib import exceptions as lib_exc
|
from neutron_lib import exceptions as lib_exc
|
||||||
from neutron_lib.exceptions import l3 as lib_l3_exc
|
from neutron_lib.exceptions import l3 as lib_l3_exc
|
||||||
@ -136,7 +137,7 @@ class PortForwardingPlugin(fip_pf.PortForwardingPluginBase):
|
|||||||
|
|
||||||
@registry.receives(resources.PORT, [events.AFTER_UPDATE,
|
@registry.receives(resources.PORT, [events.AFTER_UPDATE,
|
||||||
events.PRECOMMIT_DELETE])
|
events.PRECOMMIT_DELETE])
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def _process_port_request(self, resource, event, trigger, context,
|
def _process_port_request(self, resource, event, trigger, context,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
# Deleting floatingip will receive port resource with precommit_delete
|
# Deleting floatingip will receive port resource with precommit_delete
|
||||||
|
@ -18,6 +18,7 @@ from neutron_lib.callbacks import events
|
|||||||
from neutron_lib.callbacks import registry
|
from neutron_lib.callbacks import registry
|
||||||
from neutron_lib.callbacks import resources
|
from neutron_lib.callbacks import resources
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
|
from neutron_lib.db import api as lib_db_api
|
||||||
from neutron_lib.db import utils as db_utils
|
from neutron_lib.db import utils as db_utils
|
||||||
from neutron_lib import exceptions as n_exc
|
from neutron_lib import exceptions as n_exc
|
||||||
from neutron_lib.plugins import directory
|
from neutron_lib.plugins import directory
|
||||||
@ -183,7 +184,7 @@ class SegmentDbMixin(common_db_mixin.CommonDbMixin):
|
|||||||
segment=segment_dict)
|
segment=segment_dict)
|
||||||
|
|
||||||
|
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
@lockutils.synchronized('update_segment_host_mapping')
|
@lockutils.synchronized('update_segment_host_mapping')
|
||||||
def update_segment_host_mapping(context, host, current_segment_ids):
|
def update_segment_host_mapping(context, host, current_segment_ids):
|
||||||
with db_api.context_manager.writer.using(context):
|
with db_api.context_manager.writer.using(context):
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from neutron_lib.db import api as lib_db_api
|
||||||
from neutron_lib.objects import exceptions as obj_exc
|
from neutron_lib.objects import exceptions as obj_exc
|
||||||
from neutron_lib.plugins import directory
|
from neutron_lib.plugins import directory
|
||||||
from oslo_log import helpers as log_helpers
|
from oslo_log import helpers as log_helpers
|
||||||
@ -72,7 +73,7 @@ class TagPlugin(common_db_mixin.CommonDbMixin, tagging.TagPluginBase):
|
|||||||
raise tagging.TagNotFound(tag=tag)
|
raise tagging.TagNotFound(tag=tag)
|
||||||
|
|
||||||
@log_helpers.log_method_call
|
@log_helpers.log_method_call
|
||||||
@db_api.retry_if_session_inactive()
|
@lib_db_api.retry_if_session_inactive()
|
||||||
def update_tags(self, context, resource, resource_id, body):
|
def update_tags(self, context, resource, resource_id, body):
|
||||||
with db_api.context_manager.writer.using(context):
|
with db_api.context_manager.writer.using(context):
|
||||||
# We get and do all operations with objects in one session
|
# We get and do all operations with objects in one session
|
||||||
|
Loading…
Reference in New Issue
Block a user