Merge "NSX|V: add in security rule tags for 'project_id'"

This commit is contained in:
Zuul 2017-11-12 19:19:47 +00:00 committed by Gerrit Code Review
commit 51b446368b
3 changed files with 7 additions and 3 deletions

View File

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

View File

@ -60,7 +60,7 @@ class NsxSecurityGroupUtils(object):
def get_rule_config(self, applied_to_ids, name, action='allow',
applied_to='SecurityGroup',
source=None, destination=None, services=None,
flags=None, logged=False):
flags=None, logged=False, tag=None):
"""Helper method to create a nsx rule dict."""
ruleTag = et.Element('rule')
ruleTag.attrib['logged'] = 'true' if logged else 'false'
@ -123,6 +123,9 @@ class NsxSecurityGroupUtils(object):
if flags.get('direction') is not None:
dirTag = et.SubElement(ruleTag, 'direction')
dirTag.text = flags.get('direction')
if tag:
tagTag = et.SubElement(ruleTag, 'tag')
tagTag.text = tag
return ruleTag
def get_rule_id_pair_from_section(self, resp):

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)
logged=mock.ANY, action=mock.ANY, tag=mock.ANY)
class TestNSXv3ExtendedSGRule(test_nsxv3_plugin.NsxV3PluginTestCaseMixin,