From 6eb878db7de639148d52da9356b303fbdc995743 Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Sat, 20 Jan 2018 00:49:14 +0100 Subject: [PATCH] CLOUDSTACK-10242: Properly parse incoming rules to Sec Group 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 Signed-off-by: Rohit Yadav --- scripts/vm/network/security_group.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/vm/network/security_group.py b/scripts/vm/network/security_group.py index 9b8ac6424137..6a11057b237a 100755 --- a/scripts/vm/network/security_group.py +++ b/scripts/vm/network/security_group.py @@ -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 = []