new scripts written
[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 "clusterGRE.py: Mininet Raspberry Pi Cluster"
12 from mininet.examples.cluster import MininetCluster, SwitchBinPlacer, RemoteGRELink
13 from mininet.topolib import TreeTopo
14 from mininet.log import setLogLevel
15 from mininet.examples.clustercli import ClusterCLI as CLI
16 from mininet.node import RemoteController
17 from topotest import MiTopo
18 from precompiler import TopoFromCompiler
19
20 def inicia():
21     IPs = '/home/pi/scripts/iplist'
22     c = RemoteController('c1', ip='192.168.25.2', port=6633)
23     servers = readIPs(IPs)
24     #servers = ['192.168.25.2', '192.168.25.3', '192.168.25.4','192.168.25.5','192.168.25.6']
25     topo1 = TreeTopo(depth=2, fanout=2) # Topologia basica
26     topo2 = MiTopo() # Topologia desde el archivo topotest
27     topo3 = TopoFromCompiler() # Topologia creada a partir del archivo data
28     topo4 = TreeTopo(depth=3, fanout=3) # Topologia grande en arbol
29     net = MininetCluster(topo=topo3, servers=servers, link=RemoteGRELink, placement=SwitchBinPlacer, controller=c)
30     net.start()
31     CLI(net)
32     net.stop()
33
34
35 def readIPs(path):
36     file = open(path, "r") #abre el archivo en read
37     if file.mode == "r":
38         servers = file.read().splitlines() #lee el archivo y lo divide por lineas
39     return servers
40
41
42 if __name__ == '__main__':
43     setLogLevel('info')
44     inicia()