#!/usr/bin/env python

# An example script using the rumba package

from rumba.model import *
from rumba.utils import ExperimentManager
from rumba.topologies import build_ring

# import testbed plugins
import rumba.testbeds.dockertb as docker

# import prototype plugins
import rumba.prototypes.ouroboros as our

import argparse
import sys


description = "Script to create an ouroboros"

argparser = argparse.ArgumentParser(description = description)
argparser.add_argument('-n', '--nodes', type = int, default = '10',
                       help = "Total number of nodes")

args = argparser.parse_args()

log.set_logging_level('DEBUG')

n01 = UnicastLayer("n01")

if (args.nodes < 3):
    print("The ouroboros must be longer than 2 nodes")
    sys.exit(-1)

nodes = build_ring(args.nodes, n01)

tb = docker.Testbed(exp_name = "ouroboros")

exp = our.Experiment(tb, nodes = nodes)

print(exp)

with ExperimentManager(exp):
    exp.swap_in()
    exp.bootstrap_prototype()
