OVO: ensure decomposed plugin do not break with OVO
Commit af52d499a5
broke decomposed
plugins.
This was for a number of reasons:
1. _make_security_group_dict should always get the object as
as parameter. There were some cases where it received the
database object
2. The returned port security groups needed to be a list
3. A rule create needed to fetch from the DB
In addition to this the methods resource_extend.apply_funcs
should receive the database object.
Change-Id: I740da1ea65a0af9451701e3a40fd673fa82f0f5b
This commit is contained in:
parent
c507656044
commit
98b9177c3e
|
@ -123,7 +123,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
||||||
|
|
||||||
# fetch sg from db to load the sg rules with sg model.
|
# fetch sg from db to load the sg rules with sg model.
|
||||||
sg = sg_obj.SecurityGroup.get_object(context, id=sg.id)
|
sg = sg_obj.SecurityGroup.get_object(context, id=sg.id)
|
||||||
secgroup_dict = self._make_security_group_dict(sg.db_obj)
|
secgroup_dict = self._make_security_group_dict(sg)
|
||||||
|
|
||||||
kwargs['security_group'] = secgroup_dict
|
kwargs['security_group'] = secgroup_dict
|
||||||
registry.notify(resources.SECURITY_GROUP, events.AFTER_CREATE, self,
|
registry.notify(resources.SECURITY_GROUP, events.AFTER_CREATE, self,
|
||||||
|
@ -264,10 +264,12 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
||||||
'name': security_group['name'],
|
'name': security_group['name'],
|
||||||
'tenant_id': security_group['tenant_id'],
|
'tenant_id': security_group['tenant_id'],
|
||||||
'description': security_group['description']}
|
'description': security_group['description']}
|
||||||
res['security_group_rules'] = [self._make_security_group_rule_dict(r)
|
res['security_group_rules'] = [
|
||||||
for r in security_group.rules]
|
self._make_security_group_rule_dict(r.db_obj)
|
||||||
|
for r in security_group.rules
|
||||||
|
]
|
||||||
resource_extend.apply_funcs(ext_sg.SECURITYGROUPS, res,
|
resource_extend.apply_funcs(ext_sg.SECURITYGROUPS, res,
|
||||||
security_group)
|
security_group.db_obj)
|
||||||
return db_utils.resource_fields(res, fields)
|
return db_utils.resource_fields(res, fields)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -388,6 +390,9 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
||||||
self._registry_notify(resources.SECURITY_GROUP_RULE,
|
self._registry_notify(resources.SECURITY_GROUP_RULE,
|
||||||
events.PRECOMMIT_CREATE,
|
events.PRECOMMIT_CREATE,
|
||||||
exc_cls=ext_sg.SecurityGroupConflict, **kwargs)
|
exc_cls=ext_sg.SecurityGroupConflict, **kwargs)
|
||||||
|
# fetch sg_rule from db to load the sg rules with sg model otherwise
|
||||||
|
# a DetachedInstanceError can occur for model extensions
|
||||||
|
sg_rule = sg_obj.SecurityGroupRule.get_object(context, id=sg_rule.id)
|
||||||
return self._make_security_group_rule_dict(sg_rule.db_obj)
|
return self._make_security_group_rule_dict(sg_rule.db_obj)
|
||||||
|
|
||||||
def _get_ip_proto_number(self, protocol):
|
def _get_ip_proto_number(self, protocol):
|
||||||
|
@ -640,7 +645,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
||||||
context, _pager=pager, validate_filters=False, **filters
|
context, _pager=pager, validate_filters=False, **filters
|
||||||
)
|
)
|
||||||
return [
|
return [
|
||||||
self._make_security_group_rule_dict(obj, fields)
|
self._make_security_group_rule_dict(obj.db_obj, fields)
|
||||||
for obj in rule_objs
|
for obj in rule_objs
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -653,7 +658,8 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
||||||
@db_api.retry_if_session_inactive()
|
@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(security_group_rule, fields)
|
return self._make_security_group_rule_dict(
|
||||||
|
security_group_rule.db_obj, fields)
|
||||||
|
|
||||||
def _get_security_group_rule(self, context, id):
|
def _get_security_group_rule(self, context, id):
|
||||||
sgr = sg_obj.SecurityGroupRule.get_object(context, id=id)
|
sgr = sg_obj.SecurityGroupRule.get_object(context, id=id)
|
||||||
|
@ -766,7 +772,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
||||||
if port_sg_missing:
|
if port_sg_missing:
|
||||||
raise ext_sg.SecurityGroupNotFound(id=', '.join(port_sg_missing))
|
raise ext_sg.SecurityGroupNotFound(id=', '.join(port_sg_missing))
|
||||||
|
|
||||||
return requested_groups
|
return list(requested_groups)
|
||||||
|
|
||||||
def _ensure_default_security_group_on_port(self, context, port):
|
def _ensure_default_security_group_on_port(self, context, port):
|
||||||
# we don't apply security groups for dhcp, router
|
# we don't apply security groups for dhcp, router
|
||||||
|
|
Loading…
Reference in New Issue