def forward_from_config_and_relation(relation): """Forward ports from config and relations if opened-ports relation is available""" services = relation.opened_ports cfg = json.loads(config()["port-forwards"]) if not sanity_check_cfg(cfg): return services.extend(cfg) update_port_forwards(services) services = relation.set_ready()
def forward_from_config(): """Only forward ports from config if no opened-ports relation is available""" try: cfg = json.loads(config()["port-forwards"]) except ValueError: hookenv.status_set( 'blocked', 'Failed to parse "port-forwards". Please make sure this is valid json.') exit() if not sanity_check_cfg(cfg): return update_port_forwards(cfg)
def configure_forwarders(): cfg = json.loads(config()["port-forwards"]) update_port_forwards(cfg)
def configure_port_forwards(relation): services = relation.opened_ports cfg = json.loads(config()["port-forwards"]) services.extend(cfg) update_port_forwards(services) services = relation.set_ready()