Merge "NSX|V: add in security rule tags for 'project_id'"
This commit is contained in:
commit
51b446368b
@ -4210,7 +4210,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
services=services,
|
services=services,
|
||||||
flags=flags,
|
flags=flags,
|
||||||
action=action,
|
action=action,
|
||||||
logged=logged)
|
logged=logged,
|
||||||
|
tag='Project_%s' % rule['tenant_id'])
|
||||||
return nsx_rule
|
return nsx_rule
|
||||||
|
|
||||||
def create_security_group_rule(self, context, security_group_rule):
|
def create_security_group_rule(self, context, security_group_rule):
|
||||||
|
@ -60,7 +60,7 @@ class NsxSecurityGroupUtils(object):
|
|||||||
def get_rule_config(self, applied_to_ids, name, action='allow',
|
def get_rule_config(self, applied_to_ids, name, action='allow',
|
||||||
applied_to='SecurityGroup',
|
applied_to='SecurityGroup',
|
||||||
source=None, destination=None, services=None,
|
source=None, destination=None, services=None,
|
||||||
flags=None, logged=False):
|
flags=None, logged=False, tag=None):
|
||||||
"""Helper method to create a nsx rule dict."""
|
"""Helper method to create a nsx rule dict."""
|
||||||
ruleTag = et.Element('rule')
|
ruleTag = et.Element('rule')
|
||||||
ruleTag.attrib['logged'] = 'true' if logged else 'false'
|
ruleTag.attrib['logged'] = 'true' if logged else 'false'
|
||||||
@ -123,6 +123,9 @@ class NsxSecurityGroupUtils(object):
|
|||||||
if flags.get('direction') is not None:
|
if flags.get('direction') is not None:
|
||||||
dirTag = et.SubElement(ruleTag, 'direction')
|
dirTag = et.SubElement(ruleTag, 'direction')
|
||||||
dirTag.text = flags.get('direction')
|
dirTag.text = flags.get('direction')
|
||||||
|
if tag:
|
||||||
|
tagTag = et.SubElement(ruleTag, 'tag')
|
||||||
|
tagTag.text = tag
|
||||||
return ruleTag
|
return ruleTag
|
||||||
|
|
||||||
def get_rule_id_pair_from_section(self, resp):
|
def get_rule_id_pair_from_section(self, resp):
|
||||||
|
@ -110,7 +110,7 @@ class TestNsxVExtendedSGRule(test_nsxv_plugin.NsxVSecurityGroupsTestCase,
|
|||||||
plugin.nsx_sg_utils.get_rule_config.assert_called_with(
|
plugin.nsx_sg_utils.get_rule_config.assert_called_with(
|
||||||
source=mock.ANY, destination=dest, services=mock.ANY,
|
source=mock.ANY, destination=dest, services=mock.ANY,
|
||||||
name=mock.ANY, applied_to_ids=mock.ANY, flags=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,
|
class TestNSXv3ExtendedSGRule(test_nsxv3_plugin.NsxV3PluginTestCaseMixin,
|
||||||
|
Loading…
Reference in New Issue
Block a user