in templates/http_load_balancer.py [0:0]
def GenerateFirewall(context):
"""Generates a firewall if prop[ADD_FIREWALL] is true."""
name = context.env['name']
prop = context.properties
src_ranges = prop[SRC_RANGES]
add_firewall = prop[ADD_FIREWALL]
instances = []
if add_firewall:
# pyformat: disable
instances.append({
'name': common.AutoName(name, default.FIREWALL),
'type': default.FIREWALL,
'properties': {
'sourceRanges': src_ranges,
'allowed': [{
'IPProtocol': prop[IP_PROTO],
'ports': [prop[PORT]],
}],
}
})
# pyformat: enable
return instances