Update the max NS groups criteria tags number dynamically
The limit of the NSX groups criteria tags should depend on the NSX backend limit. Change-Id: I8a56cde4fa1d64916b81f4f952bcd49002ab4e19
This commit is contained in:
parent
33b1a554ac
commit
d11e6a7370
|
@ -265,16 +265,19 @@ class TestNsxV3Utils(nsxlib_testcase.NsxClientTestCase):
|
|||
self.assertRaises(exceptions.NsxLibInvalidInput, func_to_fail, 99)
|
||||
self.assertEqual(max_retries, total_count['val'])
|
||||
|
||||
@mock.patch.object(utils, '_update_max_nsgroups_criteria_tags')
|
||||
@mock.patch.object(utils, '_update_max_tags')
|
||||
@mock.patch.object(utils, '_update_tag_length')
|
||||
@mock.patch.object(utils, '_update_resource_length')
|
||||
def test_update_limits(self, _update_resource_length,
|
||||
_update_tag_length, _update_max_tags):
|
||||
_update_tag_length, _update_max_tags,
|
||||
_update_msx_nsg_criteria):
|
||||
limits = utils.TagLimits(1, 2, 3)
|
||||
utils.update_tag_limits(limits)
|
||||
_update_resource_length.assert_called_with(1)
|
||||
_update_tag_length.assert_called_with(2)
|
||||
_update_max_tags.assert_called_with(3)
|
||||
_update_msx_nsg_criteria.assert_called_with(3)
|
||||
|
||||
|
||||
class NsxFeaturesTestCase(nsxlib_testcase.NsxLibTestCase):
|
||||
|
|
|
@ -32,7 +32,6 @@ from vmware_nsxlib.v3 import utils
|
|||
LOG = log.getLogger(__name__)
|
||||
|
||||
PORT_SG_SCOPE = 'os-security-group'
|
||||
MAX_NSGROUPS_CRITERIA_TAGS = 10
|
||||
|
||||
|
||||
class NsxLibNsGroup(utils.NsxLibApiBase):
|
||||
|
@ -83,9 +82,9 @@ class NsxLibNsGroup(utils.NsxLibApiBase):
|
|||
return '%(name)s - %(id)s' % security_group
|
||||
|
||||
def get_lport_tags(self, secgroups):
|
||||
if len(secgroups) > MAX_NSGROUPS_CRITERIA_TAGS:
|
||||
if len(secgroups) > utils.MAX_NSGROUPS_CRITERIA_TAGS:
|
||||
raise exceptions.NumberOfNsgroupCriteriaTagsReached(
|
||||
max_num=MAX_NSGROUPS_CRITERIA_TAGS)
|
||||
max_num=utils.MAX_NSGROUPS_CRITERIA_TAGS)
|
||||
tags = []
|
||||
for sg in secgroups:
|
||||
tags = utils.add_v3_tag(tags, PORT_SG_SCOPE, sg)
|
||||
|
|
|
@ -38,6 +38,7 @@ TagLimits = collections.namedtuple('TagLimits',
|
|||
MAX_RESOURCE_TYPE_LEN = 20
|
||||
MAX_TAG_LEN = 40
|
||||
MAX_TAGS = 15
|
||||
MAX_NSGROUPS_CRITERIA_TAGS = 10
|
||||
|
||||
DEFAULT_MAX_ATTEMPTS = 10
|
||||
DEFAULT_CACHE_AGE_SEC = 600
|
||||
|
@ -76,10 +77,16 @@ def _update_max_tags(max_tags):
|
|||
MAX_TAGS = max_tags
|
||||
|
||||
|
||||
def _update_max_nsgroups_criteria_tags(max_tags):
|
||||
global MAX_NSGROUPS_CRITERIA_TAGS
|
||||
MAX_NSGROUPS_CRITERIA_TAGS = max(10, max_tags - 5)
|
||||
|
||||
|
||||
def update_tag_limits(limits):
|
||||
_update_resource_length(limits.scope_length)
|
||||
_update_tag_length(limits.tag_length)
|
||||
_update_max_tags(limits.max_tags)
|
||||
_update_max_nsgroups_criteria_tags(limits.max_tags)
|
||||
|
||||
|
||||
def _validate_resource_type_length(resource_type):
|
||||
|
|
Loading…
Reference in New Issue