Commits (2)
......@@ -19,6 +19,7 @@
import add_routable_ipv6_addrs
import frr_configurator
import json
import ssh_helper
import sysctl_configurator
import topomap_parser
......@@ -26,6 +27,7 @@ import topomap_parser
import argparse
import getpass
from netdiff import NetJsonParser
import re
if __name__ == "__main__":
parser = argparse.ArgumentParser("Setup an Emulab experiment for Segment Routing")
......@@ -33,12 +35,16 @@ if __name__ == "__main__":
help="Path to the emulab topomap file to parse")
parser.add_argument("--netgraph-file", action='store', type=str, required=False,
help="Path to the NetJSON file to parse. Skips parsing the netgrap from the topomap-file")
parser.add_argument("--netgraph-write", action='store', type=str, required=False,
help="(Optional) Path to write the final NetJSON file")
parser.add_argument("--username", action='store', type=str, default=getpass.getuser(),
help="Username to use on all hosts. Defaults to current user's username")
parser.add_argument("--stop", action='store_true',
help="Stop all services (after writing config files)")
parser.add_argument("--ovs-prefix", action='store', type=str, default='ovs',
help="Prefix used in Emulab profile to distinguish OVS nodes (Default \"ovs\")")
parser.add_argument("--ovs-regex", action='store', type=str, default='.*ovs.*',
help="Regex to distinguish OVS nodes by label (Default \".*ovs.*\")")
parser.add_argument("--host-regex", action='store', type=str, default='.*host.*',
help="Regex to distinguish host nodes by label (Default \".*host.*\")")
args = parser.parse_args()
......@@ -57,16 +63,27 @@ if __name__ == "__main__":
add_routable_ipv6_addrs.add_ULAs_to_hosts(netgraph.graph, ULA_map)
add_routable_ipv6_addrs.add_interfaces_to_netgraph(netgraph.graph, ULA_map)
# Prepare a list of nodes which run OVS and should thus be ignore for router-related activites
ovs_nodes = []
for node in netgraph.graph.nodes:
node_name = netgraph.graph._node[node]['label']
if str.startswith(node_name, args.ovs_prefix):
if re.match(args.ovs_regex, node_name):
# TODO: Make frr_configurator ignore OVS nodes
frr_configurator.configure_nodes(netgraph.graph, ignore_nodes=ovs_nodes)
frr_configurator.start_frr_on_network(netgraph.graph, ignore_nodes=ovs_nodes)
# Prepare a list of nodes which are "consumer host nodes" and should thus be ignored for core network-related activities
host_nodes = []
for node in netgraph.graph.nodes:
node_name = netgraph.graph._node[node]['label']
if re.match(args.host_regex, node_name):
frr_configurator.configure_nodes(netgraph.graph, ignore_nodes=ovs_nodes + host_nodes)
frr_configurator.start_frr_on_network(netgraph.graph, ignore_nodes=ovs_nodes + host_nodes)
if args.netgraph_write:
with open(args.netgraph_write) as outfile:
json.dumps(netgraph.json(dict=True), outfile)