Adding retry decorator for plugin operations
This follows the same design pattern and uses the same decorator used by Neutron. The plugin operations will be retried when the following exceptions occur: sqlalchemy.orm.exc.StaleDataError oslo_db.exception.DBDeadlock oslo_db.exception.DBConnectionError oslo_db.exception.DBDuplicateEntry oslo_db.exception.RetryRequest oslo_db.exception.DBError (with 1035 code for SAVEPOINT errors) Each operation will be tried 10 times before the actual exception is raised. At that point the exception will be replaced by a GroupPolicyDriverException and returned to the client. Retry logic and decorator is implemented in Neutron and used as is. Change-Id: I42e5a62e81f423bbc3a131953245b789cdb1c1c8
This commit is contained in:
@@ -15,6 +15,7 @@ import six
|
||||
|
||||
from neutron.api.v2 import attributes as nattr
|
||||
from neutron import context as n_ctx
|
||||
from neutron.db import api as db_api
|
||||
from neutron.extensions import portbindings
|
||||
from neutron import manager as n_manager
|
||||
from neutron.plugins.common import constants as pconst
|
||||
@@ -459,6 +460,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
{'port_attributes': port_attributes})
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def create_policy_target(self, context, policy_target):
|
||||
self._ensure_tenant(context, policy_target['policy_target'])
|
||||
self._add_fixed_ips_to_port_attributes(policy_target)
|
||||
@@ -488,6 +490,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_policy_target(context, result['id'])
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_policy_target(self, context, policy_target_id, policy_target):
|
||||
self._add_fixed_ips_to_port_attributes(policy_target)
|
||||
session = context.session
|
||||
@@ -513,6 +516,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_policy_target(context, policy_target_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def delete_policy_target(self, context, policy_target_id):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -533,11 +537,13 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
policy_target_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_policy_target(self, context, policy_target_id, fields=None):
|
||||
return self._get_resource(context, 'policy_target', policy_target_id,
|
||||
'PolicyTargetContext', fields=fields)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_policy_targets(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
@@ -547,6 +553,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
marker=marker, page_reverse=page_reverse)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def create_policy_target_group(self, context, policy_target_group):
|
||||
self._ensure_tenant(context,
|
||||
policy_target_group['policy_target_group'])
|
||||
@@ -577,6 +584,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_policy_target_group(context, result['id'])
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_policy_target_group(self, context, policy_target_group_id,
|
||||
policy_target_group):
|
||||
session = context.session
|
||||
@@ -616,6 +624,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_policy_target_group(context, policy_target_group_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def delete_policy_target_group(self, context, policy_target_group_id):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -671,6 +680,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
policy_target_group_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_policy_target_group(self, context, policy_target_group_id,
|
||||
fields=None):
|
||||
return self._get_resource(context, 'policy_target_group',
|
||||
@@ -678,6 +688,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
'PolicyTargetGroupContext', fields=fields)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_policy_target_groups(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
@@ -687,6 +698,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
marker=marker, page_reverse=page_reverse)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def create_application_policy_group(self, context,
|
||||
application_policy_group):
|
||||
self._ensure_tenant(
|
||||
@@ -717,6 +729,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_application_policy_group(context, result['id'])
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_application_policy_group(self, context,
|
||||
application_policy_group_id,
|
||||
application_policy_group):
|
||||
@@ -749,6 +762,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
application_policy_group_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def delete_application_policy_group(self, context,
|
||||
application_policy_group_id):
|
||||
session = context.session
|
||||
@@ -771,6 +785,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
application_policy_group_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_application_policy_group(self, context,
|
||||
application_policy_group_id, fields=None):
|
||||
return self._get_resource(context, 'application_policy_group',
|
||||
@@ -779,6 +794,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
fields=fields)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_application_policy_groups(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
@@ -788,6 +804,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
sorts=sorts, limit=limit, marker=marker, page_reverse=page_reverse)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def create_l2_policy(self, context, l2_policy):
|
||||
self._ensure_tenant(context, l2_policy['l2_policy'])
|
||||
session = context.session
|
||||
@@ -814,6 +831,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_l2_policy(context, result['id'])
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_l2_policy(self, context, l2_policy_id, l2_policy):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -837,6 +855,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_l2_policy(context, l2_policy_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def delete_l2_policy(self, context, l2_policy_id):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -856,12 +875,14 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
"for l2_policy %s"), l2_policy_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_l2_policy(self, context, l2_policy_id, fields=None):
|
||||
return self._get_resource(context, 'l2_policy',
|
||||
l2_policy_id,
|
||||
'L2PolicyContext', fields=fields)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_l2_policies(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
@@ -871,6 +892,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
marker=marker, page_reverse=page_reverse)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def create_network_service_policy(self, context, network_service_policy):
|
||||
self._ensure_tenant(
|
||||
context, network_service_policy['network_service_policy'])
|
||||
@@ -903,6 +925,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_network_service_policy(context, result['id'])
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_network_service_policy(self, context, network_service_policy_id,
|
||||
network_service_policy):
|
||||
session = context.session
|
||||
@@ -932,6 +955,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
network_service_policy_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def delete_network_service_policy(
|
||||
self, context, network_service_policy_id):
|
||||
session = context.session
|
||||
@@ -954,6 +978,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
"for network_service_policy %s"), network_service_policy_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_network_service_policy(self, context, network_service_policy_id,
|
||||
fields=None):
|
||||
return self._get_resource(context, 'network_service_policy',
|
||||
@@ -961,6 +986,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
'NetworkServicePolicyContext', fields=fields)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_network_service_policies(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
@@ -970,6 +996,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
marker=marker, page_reverse=page_reverse)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def create_l3_policy(self, context, l3_policy):
|
||||
self._ensure_tenant(context, l3_policy['l3_policy'])
|
||||
session = context.session
|
||||
@@ -998,6 +1025,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_l3_policy(context, result['id'])
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_l3_policy(self, context, l3_policy_id, l3_policy):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -1022,6 +1050,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_l3_policy(context, l3_policy_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def delete_l3_policy(self, context, l3_policy_id, check_unused=False):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -1046,12 +1075,14 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return True
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_l3_policy(self, context, l3_policy_id, fields=None):
|
||||
return self._get_resource(context, 'l3_policy',
|
||||
l3_policy_id,
|
||||
'L3PolicyContext', fields=fields)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_l3_policies(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
@@ -1061,6 +1092,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
marker=marker, page_reverse=page_reverse)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def create_policy_classifier(self, context, policy_classifier):
|
||||
self._ensure_tenant(context,
|
||||
policy_classifier['policy_classifier'])
|
||||
@@ -1091,6 +1123,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_policy_classifier(context, result['id'])
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_policy_classifier(self, context, id, policy_classifier):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -1115,6 +1148,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_policy_classifier(context, id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def delete_policy_classifier(self, context, id):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -1134,6 +1168,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
"for policy_classifier %s"), id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_policy_classifier(self, context, policy_classifier_id,
|
||||
fields=None):
|
||||
return self._get_resource(context, 'policy_classifier',
|
||||
@@ -1141,6 +1176,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
'PolicyClassifierContext', fields=fields)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_policy_classifiers(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
@@ -1150,6 +1186,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
marker=marker, page_reverse=page_reverse)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def create_policy_action(self, context, policy_action):
|
||||
self._ensure_tenant(context, policy_action['policy_action'])
|
||||
session = context.session
|
||||
@@ -1179,6 +1216,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_policy_action(context, result['id'])
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_policy_action(self, context, id, policy_action):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -1204,6 +1242,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_policy_action(context, id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def delete_policy_action(self, context, id):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -1222,12 +1261,14 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
"for policy_action %s"), id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_policy_action(self, context, policy_action_id, fields=None):
|
||||
return self._get_resource(context, 'policy_action',
|
||||
policy_action_id,
|
||||
'PolicyActionContext', fields=fields)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_policy_actions(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
@@ -1237,6 +1278,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
marker=marker, page_reverse=page_reverse)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def create_policy_rule(self, context, policy_rule):
|
||||
self._ensure_tenant(context, policy_rule['policy_rule'])
|
||||
session = context.session
|
||||
@@ -1265,6 +1307,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_policy_rule(context, result['id'])
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_policy_rule(self, context, id, policy_rule):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -1288,6 +1331,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_policy_rule(context, id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def delete_policy_rule(self, context, id):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -1307,12 +1351,14 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
"for policy_rule %s"), id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_policy_rule(self, context, policy_rule_id, fields=None):
|
||||
return self._get_resource(context, 'policy_rule',
|
||||
policy_rule_id,
|
||||
'PolicyRuleContext', fields=fields)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_policy_rules(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
@@ -1322,6 +1368,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
marker=marker, page_reverse=page_reverse)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def create_policy_rule_set(self, context, policy_rule_set):
|
||||
self._ensure_tenant(context, policy_rule_set['policy_rule_set'])
|
||||
session = context.session
|
||||
@@ -1351,6 +1398,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_policy_rule_set(context, result['id'])
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_policy_rule_set(self, context, id, policy_rule_set):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -1375,6 +1423,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_policy_rule_set(context, id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def delete_policy_rule_set(self, context, id):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -1393,12 +1442,14 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
"for policy_rule_set %s"), id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_policy_rule_set(self, context, policy_rule_set_id, fields=None):
|
||||
return self._get_resource(context, 'policy_rule_set',
|
||||
policy_rule_set_id,
|
||||
'PolicyRuleSetContext', fields=fields)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_policy_rule_sets(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
@@ -1408,6 +1459,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
marker=marker, page_reverse=page_reverse)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def create_external_segment(self, context, external_segment):
|
||||
self._ensure_tenant(context, external_segment['external_segment'])
|
||||
session = context.session
|
||||
@@ -1440,6 +1492,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_external_segment(context, result['id'])
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_external_segment(self, context, external_segment_id,
|
||||
external_segment):
|
||||
session = context.session
|
||||
@@ -1470,6 +1523,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_external_segment(context, external_segment_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def delete_external_segment(self, context, external_segment_id):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -1493,12 +1547,14 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return True
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_external_segment(self, context, external_segment_id, fields=None):
|
||||
return self._get_resource(context, 'external_segment',
|
||||
external_segment_id,
|
||||
'ExternalSegmentContext', fields=fields)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_external_segments(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
@@ -1508,6 +1564,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
marker=marker, page_reverse=page_reverse)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def create_external_policy(self, context, external_policy):
|
||||
self._ensure_tenant(context, external_policy['external_policy'])
|
||||
session = context.session
|
||||
@@ -1537,6 +1594,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_external_policy(context, result['id'])
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_external_policy(self, context, external_policy_id,
|
||||
external_policy):
|
||||
session = context.session
|
||||
@@ -1564,6 +1622,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_external_policy(context, external_policy_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def delete_external_policy(self, context, external_policy_id,
|
||||
check_unused=False):
|
||||
session = context.session
|
||||
@@ -1584,12 +1643,14 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
"for external_policy %s"), external_policy_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_external_policy(self, context, external_policy_id, fields=None):
|
||||
return self._get_resource(context, 'external_policy',
|
||||
external_policy_id,
|
||||
'ExternalPolicyContext', fields=fields)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_external_policies(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
@@ -1599,6 +1660,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
marker=marker, page_reverse=page_reverse)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def create_nat_pool(self, context, nat_pool):
|
||||
self._ensure_tenant(context, nat_pool['nat_pool'])
|
||||
session = context.session
|
||||
@@ -1625,6 +1687,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_nat_pool(context, result['id'])
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_nat_pool(self, context, nat_pool_id, nat_pool):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -1646,6 +1709,7 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
return self.get_nat_pool(context, nat_pool_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def delete_nat_pool(self, context, nat_pool_id, check_unused=False):
|
||||
session = context.session
|
||||
with session.begin(subtransactions=True):
|
||||
@@ -1665,12 +1729,14 @@ class GroupPolicyPlugin(group_policy_mapping_db.GroupPolicyMappingDbPlugin):
|
||||
nat_pool_id)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_nat_pool(self, context, nat_pool_id, fields=None):
|
||||
return self._get_resource(context, 'nat_pool',
|
||||
nat_pool_id,
|
||||
'NatPoolContext', fields=fields)
|
||||
|
||||
@log.log_method_call
|
||||
@db_api.retry_if_session_inactive()
|
||||
def get_nat_pools(self, context, filters=None, fields=None,
|
||||
sorts=None, limit=None, marker=None,
|
||||
page_reverse=False):
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
from neutron.common import exceptions as n_exc
|
||||
from neutron.db import api as db_api
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from oslo_policy import policy as oslo_policy
|
||||
@@ -122,21 +123,31 @@ class PolicyDriverManager(stevedore.named.NamedExtensionManager):
|
||||
for driver in drivers:
|
||||
try:
|
||||
getattr(driver.obj, method_name)(context)
|
||||
except (gp_exc.GroupPolicyException, n_exc.NeutronException,
|
||||
oslo_policy.PolicyNotAuthorized):
|
||||
with excutils.save_and_reraise_exception():
|
||||
except Exception as e:
|
||||
if db_api.is_retriable(e):
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.debug(
|
||||
"Policy driver '%(name)s' failed in"
|
||||
" %(method)s, operation will be retried",
|
||||
{'name': driver.name, 'method': method_name}
|
||||
)
|
||||
elif isinstance(e, gp_exc.GroupPolicyException) or isinstance(
|
||||
e, n_exc.NeutronException) or isinstance(
|
||||
e, oslo_policy.PolicyNotAuthorized):
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(
|
||||
_LE("Policy driver '%(name)s' failed in"
|
||||
" %(method)s"),
|
||||
{'name': driver.name, 'method': method_name}
|
||||
)
|
||||
else:
|
||||
error = True
|
||||
# We are eating a non-GBP/non-Neutron exception here
|
||||
LOG.exception(
|
||||
_LE("Policy driver '%(name)s' failed in %(method)s"),
|
||||
{'name': driver.name, 'method': method_name}
|
||||
)
|
||||
except Exception:
|
||||
# We are eating a non-GBP/non-Neutron exception here
|
||||
LOG.exception(
|
||||
_LE("Policy driver '%(name)s' failed in %(method)s"),
|
||||
{'name': driver.name, 'method': method_name})
|
||||
error = True
|
||||
if not continue_on_failure:
|
||||
break
|
||||
{'name': driver.name, 'method': method_name})
|
||||
if not continue_on_failure:
|
||||
break
|
||||
if error:
|
||||
raise gp_exc.GroupPolicyDriverError(method=method_name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user