#!/usr/bin/env python

# An example script using the rumba package

from rumba.model import *
from rumba.utils import ExperimentManager
from rumba.storyboard import *


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

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

import rumba.log as log

log.set_logging_level('DEBUG')


n1 = UnicastLayer("n1")
e1 = EthDixLayer("e1")
e2 = EthDixLayer("e2")

clientNode = Node("client",
         layers = [e1, n1],
         registrations = {n1 : [e1]})

routerNode = Node("router",
         layers = [e1, e2, n1],
         registrations = {n1 : [e1, e2]})

serverNode = Node("server",
         layers = [e2, n1],
         registrations = {n1 : [e2]})

tb = jfed.Testbed(exp_name = 'example',
                  cert_file = '/path/to/cert.pem',
                  authority = 'wall1.ilabt.iminds.be',
                  username = 'username',
                  exp_hours = '5',
                  proj_name='ouroboros')

exp = our.Experiment(tb, nodes=[clientNode, routerNode, serverNode],
                     git_repo="https://codeberg.org/o7s/ouroboros",
                     git_branch="be-fix")

with ExperimentManager(exp, swap_out_strategy=PAUSE_SWAPOUT):
    exp.swap_in()
    exp.install_prototype()
    exp.bootstrap_prototype()
    sb = StoryBoard(experiment=exp, duration=15, servers=[])
    sb.schedule_command(7.5, clientNode,
                        'echo "7.5 secs in. We are at $(hostname)"')
    sb.schedule_command(12, serverNode,
                        'echo "12 secs in. We are at $(hostname)"')
    sb.start()
