Ejemplo n.º 1
0
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')
Ejemplo n.º 2
0
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')
Ejemplo n.º 3
0
def run_iperf(*args):
    action_config = hookenv.action_get()
    cidr = action_config.get('network-cidr')
    units = action_config.get('units', '').split()
    magpie = reactive.relations.endpoint_from_flag('magpie.joined')
    nodes = {
        ip: name
        for name, ip in magpie.get_nodes(cidr=cidr)
        if not units or name in units
    }
    iperf = Iperf()
    results = iperf.batch_hostcheck(
        nodes,
        action_config.get('total-run-time'),
        action_config.get('iperf-batch-time'),
        [int(i) for i in action_config.get('concurrency-progression').split()],
        tag=action_config.get('tag'))
    hookenv.action_set({"output": json.dumps(results)})
Ejemplo n.º 4
0
def install_iperf_pkg():
    if hookenv.config().get('check_iperf'):
        iperf = Iperf()
        iperf.install_iperf()
        set_state('iperf.installed')
Ejemplo n.º 5
0
def install_iperf_pkg():
    iperf = Iperf()
    iperf.install_iperf()
    set_state('iperf.installed')