Skip None id when getting security_group_ids

When getting security_group_ids in securitygroup.py, a None id is
included into the list due to the remote group id is Null when the
security group rule direction is egress.
And this causes the calculation of the number of chunk_size is
1 more than the number it should be.
Then the request page size excess the MAX request page size
Then the RequestURITooLong exception happens again, and finally
the commend fails.

Co-Authored-By: Furukawa, Yushiro <y.furukawa_2@jp.fujitsu.com>
Change-Id: Ib671cf3ddc6827793c4a86d2d3c8a34957f5dfd3
Related-Bug: 1271462
Closes-Bug: 1415692
This commit is contained in:
watanabe.isao 2015-01-27 09:37:20 +09:00
parent 3e41128580
commit 59d7564202
2 changed files with 5 additions and 1 deletions

View File

@ -134,7 +134,7 @@ class ListSecurityGroupRule(neutronV20.ListCommand):
sec_group_ids = set()
for rule in data:
for key in self.replace_rules:
if key in rule:
if rule.get(key):
sec_group_ids.add(rule[key])
sec_group_ids = list(sec_group_ids)

View File

@ -259,6 +259,7 @@ class CLITestV20SecurityGroupsJSON(test_cli20.CLITestV20Base):
data = [{'name': 'default',
'remote_group_id': 'remgroupid%02d' % i}
for i in range(10)]
data.append({'name': 'default', 'remote_group_id': None})
self._test_extend_list(mox_calls, data)
def test_extend_list_exceed_max_uri_len(self):
@ -285,6 +286,9 @@ class CLITestV20SecurityGroupsJSON(test_cli20.CLITestV20Base):
'security_group_id': 'secgroupid%02d' % i,
'remote_group_id': 'remgroupid%02d' % i}
for i in range(10)]
data.append({'name': 'default',
'security_group_id': 'secgroupid10',
'remote_group_id': None})
self._test_extend_list(mox_calls, data)
def test_list_security_group_rules_pagination(self):