def listen_for_checks(magpie): ''' If im not the leader, and im not listening, then listen ''' iperf = Iperf() iperf.listen() magpie.set_iperf_server_ready() set_state('iperf.listening')
def listen(*args): action_config = hookenv.action_get() cidr = action_config.get('network-cidr') listener_count = action_config.get('listener-count') or 1 magpie = reactive.relations.endpoint_from_flag('magpie.joined') iperf = Iperf() for port in range(IPERF_BASE_PORT, IPERF_BASE_PORT + int(listener_count)): iperf.listen(cidr=cidr, port=port) magpie.set_iperf_server_ready() reactive.set_state('iperf.listening')