moved example topology to examples folder.
[osm/vim-emu.git] / src / emuvim / examples / sonata_y1_demo_topology_1.py
1 """
2 A simple topology with two PoPs for the y1 demo story board.
3
4 (dc1) <<-->> s1 <<-->> (dc2)
5 """
6
7 import logging
8 from mininet.log import setLogLevel
9 from emuvim.dcemulator.net import DCNetwork
10 from emuvim.api.zerorpcapi import ZeroRpcApiEndpoint
11
12 logging.basicConfig(level=logging.INFO)
13
14
15 def create_topology1():
16 # create topology
17 net = DCNetwork()
18 dc1 = net.addDatacenter("dc1")
19 dc2 = net.addDatacenter("dc2")
20 s1 = net.addSwitch("s1")
21 net.addLink(dc1, s1)
22 net.addLink(dc2, s1)
23
24 # create a new instance of a endpoint implementation
25 zapi1 = ZeroRpcApiEndpoint("0.0.0.0", 4242)
26 # connect data centers to this endpoint
27 zapi1.connectDatacenter(dc1)
28 zapi1.connectDatacenter(dc2)
29 # run API endpoint server (in another thread, don't block)
30 zapi1.start()
31
32 # TODO add "fake gatekeeper" api endpoint and connect it to both dcs
33
34 # start the emulation platform
35 net.start()
36 net.CLI()
37 net.stop()
38
39
40 def main():
41 setLogLevel('info') # set Mininet loglevel
42 create_topology1()
43
44
45 if __name__ == '__main__':
46 main()