#!/usr/bin/env python

# An example script using the rumba package

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

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

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

import rumba.log as log

log.set_logging_level('DEBUG')


n01 = UnicastLayer("n01")
n01.add_policy("routing", "ecmp")

e01 = EthDixLayer("e01")
e02 = EthDixLayer("e02")
e03 = EthDixLayer("e03")
e04 = EthDixLayer("e04")


a = Node("a",
         layers = [n01, e01, e02],
         registrations = {n01 : [e01, e02]})

b = Node("b",
         layers = [n01, e02, e03],
         registrations = {n01 : [e02, e03]})

c = Node("c",
         layers = [n01, e03, e04],
         registrations = {n01 : [e03, e04]})

d = Node("d",
         layers = [n01, e01, e04],
         registrations = {n01 : [e01, e04]})

tb = local.Testbed(exp_name = "square")

exp = our.Experiment(tb, nodes = [a, b, c, d])

print(exp)

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