#!/usr/bin/python
#
# Participant list generator for 'trace' test spec
#

import pscheduler
import sys

from validate import spec_is_valid

json = pscheduler.json_load(exit_on_error=True, max_schema=1)

null_reason = None

valid, message = spec_is_valid(json)

if not valid:
    pscheduler.fail(message)

source = json.get("source-node", json.get("source", None))
if source is None:
    null_reason = "No source specified"


######################################################################
# HACK: BWCTLBC
#Backward Compatibility Code: We can remove this once we drop BWCTL

# This was removed in #725 because there's no logical reason for the
# participant list to be anything other than the source.  The can-run
# method in the bwctltraceroute tool should reach out and touch the
# source end to see if it can do the job.

# Commentary left here to avert confusion when the hack is removed.

######################################################################

participants = [ source ]

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

pscheduler.succeed_json(result)
