5 from mininet.topo import Topo
6 from mininet.log import setLogLevel, info
9 Este precompilador transforma el lenguaje VSORC a la API de topologias de
18 #cmd = './cleaner.sh '+sys.argv[1]
19 cmd2 = './cleaner.sh data'
22 #document = open(sys.argv[1] + "_clean" ,"r+")
23 document = open("data" + "_clean" ,"r+")
24 links = document.readlines()
26 #"data" is the file with the topo vsorc script
28 #clean the \n in the colected data
30 for linkline in links:
31 links[a] = linkline.rstrip()
35 # get a list of non repeating devices
37 value_split = value.split(':')
38 devices.append(value_split[0])
39 devices.append(value_split[1])
40 devices = list(dict.fromkeys(devices))
43 class TopoFromCompiler(Topo):
44 #This class is for create the custom topology from the data collected.
45 #Here we also process the data to make the topo
47 for device in devices:
48 if device.startswith("h"):
50 host = self.addHost(host) #Create a host with the data collected from the list
53 elif device.startswith("s"):
55 switch = self.addSwitch(switch) #Create a switch
56 switches.append(switch)
58 print ("Devices: " + str(devices) + "\n" + "Links: " + str(links) + "\n" + "Hosts: " + str(hosts) + "\n" + "Switches: " + str(switches) + "\n")
62 split = pair.split(":")
63 self.addLink(split[0],split[1])