3 Written by: Oscar J. Rodriguez and Felix G. Tejada
5 This code is for precompile the VSORC language to Mininet topology API.
6 VSORC language is a topology languaje, for example:
12 This create a simple two switch topology with two host each one.
18 from mininet.topo import Topo
19 from mininet.log import setLogLevel, info
27 #cmd = './cleaner.sh '+sys.argv[1]
28 cmd2 = './cleaner.sh data'
31 #document = open(sys.argv[1] + "_clean" ,"r+")
32 document = open("data" + "_clean" ,"r+")
33 links = document.readlines()
35 #"data" is the file with the topo vsorc script
37 #clean the \n in the colected data
39 for linkline in links:
40 links[a] = linkline.rstrip()
44 # get a list of non repeating devices
46 value_split = value.split(':')
47 devices.append(value_split[0])
48 devices.append(value_split[1])
49 devices = list(dict.fromkeys(devices))
52 class TopoFromCompiler(Topo):
53 #This class is for create the custom topology from the data collected.
54 #Here we also process the data to make the topo
56 for device in devices:
57 if device.startswith("h"):
59 host = self.addHost(host) #Create a host with the data collected from the list
62 elif device.startswith("s"):
64 switch = self.addSwitch(switch) #Create a switch
65 switches.append(switch)
67 print ("Devices: " + str(devices) + "\n" + "Links: " + str(links) + "\n" + "Hosts: " + str(hosts) + "\n" + "Switches: " + str(switches) + "\n")
72 split = pair.split(":")
73 self.addLink(split[0],split[1])