#!/usr/bin/env python3
#
# Participant list generator for 'throughput' task spec
#
# Input is a test spec, assumed to have been validated by spec-is-valid.
#
# Output is a list of hostnames or IPs that are participating.
#

import pscheduler
import sys

from validate import spec_is_valid


logger = pscheduler.Log(prefix='test-throughput', quiet=True)

json = pscheduler.json_load(exit_on_error=True)

valid, message = spec_is_valid(json)

if not valid:
    pscheduler.fail(message)


null_reason = None

#sender first participant, receiver the second
source = json.get('source-node', json.get('source', None))
if source is None:
    null_reason = "No source specified"

destination = json.get('dest-node', json.get('dest', None))
if destination is None:
    pscheduler.fail("Missing destination argument in spec")

participants = [ source ]

if ('single-ended' not in json) and ('loopback' not in json):
    participants.append(destination)

result = { "participants": participants }
if null_reason is not None:
    result["null-reason"] = null_reason

pscheduler.succeed_json(result)


