Fixed issue in gce_net with firewall rules that have protocols that d… (#20528)

* Fixed issue in gce_net with firewall rules that have protocols that do not have ports.

* Fixed elif in gce_net to include check of the ports variable.
This commit is contained in:
Robert Simmons 2017-01-26 15:17:55 -06:00 committed by Ryan Brown
parent c2edc8a264
commit 0e7dd18650

View file

@ -208,7 +208,7 @@ def format_allowed_section(allowed):
return []
if ports.count(","):
ports = ports.split(",")
else:
elif ports:
ports = [ports]
return_val = {"IPProtocol": protocol}
if ports:
@ -231,7 +231,7 @@ def sorted_allowed_list(allowed_list):
# sort by protocol
allowed_by_protocol = sorted(allowed_list,key=lambda x: x['IPProtocol'])
# sort the ports list
return sorted(allowed_by_protocol, key=lambda y: y['ports'].sort())
return sorted(allowed_by_protocol, key=lambda y: y.get('ports', []).sort())
def main():