NSXv: Add SG rule description to NSX notes field

Populate the description field from OpenStack SG rule in NSX rule's note
field.

Change-Id: Ife3eb3fb2a2b3178cfd2bb522251b54681290c3b
This commit is contained in:
Kobi Samoray 2018-07-30 17:13:38 +03:00 committed by Adit Sarfaty
parent 04c0c6c74d
commit 1c5620ab41
3 changed files with 6 additions and 3 deletions

View File

@ -4455,7 +4455,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
flags=flags,
action=action,
logged=logged,
tag='Project_%s' % rule['tenant_id'])
tag='Project_%s' % rule['tenant_id'],
notes=rule.get('description'))
return nsx_rule
def create_security_group_rule(self, context, security_group_rule,

View File

@ -61,7 +61,7 @@ class NsxSecurityGroupUtils(object):
applied_to='SecurityGroup',
source=None, destination=None, services=None,
flags=None, logged=False, tag=None,
application_services=None):
application_services=None, notes=None):
"""Helper method to create a nsx rule dict."""
ruleTag = et.Element('rule')
ruleTag.attrib['logged'] = 'true' if logged else 'false'
@ -69,6 +69,8 @@ class NsxSecurityGroupUtils(object):
nameTag.text = name
actionTag = et.SubElement(ruleTag, 'action')
actionTag.text = action
notesTag = et.SubElement(ruleTag, 'notes')
notesTag.text = notes
apList = et.SubElement(ruleTag, 'appliedToList')
for applied_to_id in applied_to_ids:

View File

@ -110,7 +110,7 @@ class TestNsxVExtendedSGRule(test_nsxv_plugin.NsxVSecurityGroupsTestCase,
plugin.nsx_sg_utils.get_rule_config.assert_called_with(
source=mock.ANY, destination=dest, services=mock.ANY,
name=mock.ANY, applied_to_ids=mock.ANY, flags=mock.ANY,
logged=mock.ANY, action=mock.ANY, tag=mock.ANY)
logged=mock.ANY, action=mock.ANY, tag=mock.ANY, notes=mock.ANY)
class TestNSXv3ExtendedSGRule(test_nsxv3_plugin.NsxV3PluginTestCaseMixin,