Ensure security group rule description is returned

The neutron standard-attr-description is not working with NSX
plugins for security group rules. It seems that when the extension
is loaded the relevant DB model class is not yet available.

To address this problem, this change explictly adds a resource
extender function for the NSX plugin to add the description field
to ecurity groups rule responses.

Change-Id: I4d8b2629660f9e33401ce6b011b1784a6ec66aac
This commit is contained in:
Salvatore Orlando 2021-11-26 06:03:19 -08:00 committed by Salvatore Orlando
parent 59da27e9f5
commit 7fb08e1558
1 changed files with 7 additions and 0 deletions

View File

@ -92,6 +92,13 @@ class ExtendedSecurityGroupRuleMixin(object):
else:
sg_rule_res[ext_local_ip.LOCAL_IP_PREFIX] = None
@staticmethod
@resource_extend.extends([ext_sg.SECURITYGROUPRULES])
def _extend_sg_rule_description(res, db_object):
if not hasattr(db_object, 'description'):
return
res['description'] = db_object.description
def _get_security_group_rule_local_ip(self, context, rule_id):
with db_api.CONTEXT_READER.using(context):
try: