Merge "Don't catch DBDuplicate in default SG creation"
This commit is contained in:
commit
01e687bcdf
@ -15,7 +15,6 @@
|
|||||||
import netaddr
|
import netaddr
|
||||||
from neutron_lib.api import validators
|
from neutron_lib.api import validators
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
from oslo_db import exception as db_exc
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
@ -720,27 +719,14 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
|||||||
default_group = query.filter_by(tenant_id=tenant_id).one()
|
default_group = query.filter_by(tenant_id=tenant_id).one()
|
||||||
return default_group['security_group_id']
|
return default_group['security_group_id']
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return self._create_default_security_group(context, tenant_id)
|
security_group = {
|
||||||
|
'security_group':
|
||||||
def _create_default_security_group(self, context, tenant_id):
|
{'name': 'default',
|
||||||
security_group = {
|
'tenant_id': tenant_id,
|
||||||
'security_group':
|
'description': _('Default security group')}
|
||||||
{'name': 'default',
|
}
|
||||||
'tenant_id': tenant_id,
|
return self.create_security_group(
|
||||||
'description': _('Default security group')}
|
context, security_group, default_sg=True)['id']
|
||||||
}
|
|
||||||
try:
|
|
||||||
security_group = self.create_security_group(
|
|
||||||
context, security_group, default_sg=True)
|
|
||||||
return security_group['id']
|
|
||||||
except db_exc.DBDuplicateEntry as ex:
|
|
||||||
# default security group was created concurrently
|
|
||||||
LOG.debug("Duplicate default security group %s was "
|
|
||||||
"not created", ex.value)
|
|
||||||
# raise a retry request to restart the whole process since
|
|
||||||
# we could be in a REPEATABLE READ isolation level and won't
|
|
||||||
# be able to see the SG group in this transaction.
|
|
||||||
raise db_exc.RetryRequest(ex)
|
|
||||||
|
|
||||||
def _get_security_groups_on_port(self, context, port):
|
def _get_security_groups_on_port(self, context, port):
|
||||||
"""Check that all security groups on port belong to tenant.
|
"""Check that all security groups on port belong to tenant.
|
||||||
|
Loading…
Reference in New Issue
Block a user