#!/usr/bin/env python

# An example script using the rumba package

from rumba.model import *
from rumba.utils import *
from rumba.storyboard import *
from rumba.topologies import build_chain

# import testbed plugins
import rumba.testbeds.jfed as jfed
import rumba.log as log

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

import argparse
import sys


description = "Script to create a snake"

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 < 2):
    print("Snake must be longer than 2 nodes")
    sys.exit(-1)

nodes = build_chain(args.nodes, n01)

tb = jfed.Testbed(exp_name = "snake2",
                  cert_file = '/path/to/cert.pem',
                  authority = 'wall1.ilabt.iminds.be',
                  username = 'username',
                  exp_hours = '1',
                  proj_name='ouroborosrocks')

exp = our.Experiment(tb, nodes=nodes,
                     git_repo='https://codeberg.org/o7s/ouroboros',
                     git_branch='be',
                     build_options='-DCMAKE_BUILD_TYPE=Debug')

print(exp)

with ExperimentManager(exp, swap_out_strategy=PAUSE_SWAPOUT):
    exp.swap_in()
    exp.install_prototype()
    exp.bootstrap_prototype()
