CLOUDSTACK-10242: Properly parse incoming rules to Sec Group (#2418)

With merge of PR #2028 the separator for lines to the Security Group
Python script changed from : to ; to support IPv6 addresses.

This broke certain situations where rules were parsed improperly. This
commit fixes the issue.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Wido den Hollander 2018-01-23 20:21:49 +01:00 committed by Rohit Yadav
parent 3b23d5af74
commit f80f00ebcb
1 changed files with 6 additions and 7 deletions

View File

@ -951,16 +951,15 @@ def parse_network_rules(rules):
if rules is None or len(rules) == 0:
return ret
lines = rules.split(';')[:-1]
lines = rules.split('NEXT;')[:-1]
for line in lines:
tokens = line.split(':', 4)
if len(tokens) != 5:
tokens = line.split(';', 3)
if len(tokens) != 4:
continue
ruletype = tokens[0]
protocol = tokens[1]
start = int(tokens[2])
end = int(tokens[3])
ruletype, protocol = tokens[0].split(':')
start = int(tokens[1])
end = int(tokens[2])
cidrs = tokens.pop();
ipv4 = []