Update and rename MantenerFIFO to MantenerFIFO.md
[vsorcdistro/.git] / scripts / clusterGRE.py
1 #!/usr/bin/python
2 """
3 Written by: Felix G. Tejada
4
5 This is the principal script to start the project.
6 You can start different topology, but by default is starting anything from the precompiler, from web.
7
8 If you want to start any other topology, just change the constructor MininetCluster with topology 
9 you want.
10 """
11 from precompiler import TopoFromCompiler
12 from topotest import MiTopo
13 from mininet.node import RemoteController
14 from mininet.examples.clustercli import ClusterCLI as CLI
15 from mininet.log import setLogLevel
16 from mininet.topolib import TreeTopo
17 from mininet.examples.cluster import MininetCluster, SwitchBinPlacer, RemoteGRELink
18 "clusterGRE.py: Mininet Raspberry Pi Cluster"
19
20
21 def inicia():
22     IPs = '/home/pi/scripts/iplist'
23     c = RemoteController('c1', ip='192.168.25.2', port=6633)
24     servers = readIPs(IPs)
25     #servers = ['192.168.25.2', '192.168.25.3', '192.168.25.4','192.168.25.5','192.168.25.6']
26     # topo1 = TreeTopo(depth=2, fanout=2) # Topologia basica
27     # topo2 = MiTopo() # Topologia desde el archivo topotest
28     topo3 = TopoFromCompiler()  # Topologia creada a partir del archivo data
29     # topo4 = TreeTopo(depth=4, fanout=4) # Topologia GRANDE en arbol
30     net = MininetCluster(topo=topo3, servers=servers,
31                          link=RemoteGRELink, placement=SwitchBinPlacer, controller=c)
32     net.start()
33     CLI(net)
34     net.stop()
35
36
37 def readIPs(path):
38     file = open(path, "r")  # abre el archivo en read
39     if file.mode == "r":
40         servers = file.read().splitlines()  # lee el archivo y lo divide por lineas
41     return servers
42
43
44 if __name__ == '__main__':
45     setLogLevel('info')
46     inicia()