| peusterm | cbcd4c2 | 2015-12-28 11:33:42 +0100 | [diff] [blame] | 1 | """ |
| 2 | This is an example topology for the distributed cloud emulator (dcemulator). |
| 3 | (c) 2015 by Manuel Peuster <manuel.peuster@upb.de> |
| 4 | |
| 5 | The original Mininet API has to be completely hidden and not be used by this |
| 6 | script. |
| 7 | """ |
| 8 | import logging |
| 9 | from dcemulator.net import DCNetwork |
| peusterm | 9c252b6 | 2016-01-06 16:59:53 +0100 | [diff] [blame^] | 10 | from api.zerorpcapi import ZeroRpcApiEndpoint |
| peusterm | cbcd4c2 | 2015-12-28 11:33:42 +0100 | [diff] [blame] | 11 | |
| 12 | logging.basicConfig(level=logging.DEBUG) |
| 13 | |
| 14 | |
| 15 | def create_topology1(): |
| peusterm | 9c252b6 | 2016-01-06 16:59:53 +0100 | [diff] [blame^] | 16 | # TODO add long comments to this example to show people how to use this |
| peusterm | cbcd4c2 | 2015-12-28 11:33:42 +0100 | [diff] [blame] | 17 | # initialize network |
| 18 | net = DCNetwork() |
| 19 | |
| 20 | # add data centers |
| 21 | dc1 = net.addDatacenter("dc1") |
| 22 | dc2 = net.addDatacenter("dc2") |
| 23 | dc3 = net.addDatacenter("dc3") |
| 24 | dc4 = net.addDatacenter("dc4") |
| 25 | # add additional SDN switches to our topology |
| 26 | s1 = net.addSwitch("s1") |
| 27 | # add links between data centers |
| 28 | net.addLink(dc1, dc2) |
| 29 | net.addLink("dc1", s1) |
| 30 | net.addLink(s1, "dc3") |
| 31 | net.addLink(s1, dc4) |
| peusterm | 9c252b6 | 2016-01-06 16:59:53 +0100 | [diff] [blame^] | 32 | |
| 33 | # create and start APIs (to access emulated cloud data centers) |
| 34 | zapi1 = ZeroRpcApiEndpoint("0.0.0.0", 4242) |
| 35 | zapi1.connectDatacenter(dc1) |
| 36 | zapi1.connectDatacenter(dc2) |
| 37 | zapi1.start() |
| 38 | # lets also create a second API endpoint on another port to |
| 39 | # demonstrate hat you can have one endpoint for each of |
| 40 | # your data centers |
| 41 | zapi2 = ZeroRpcApiEndpoint("0.0.0.0", 4343) |
| 42 | zapi2.connectDatacenter(dc3) |
| 43 | zapi2.connectDatacenter(dc4) |
| 44 | zapi2.start() |
| 45 | |
| peusterm | cbcd4c2 | 2015-12-28 11:33:42 +0100 | [diff] [blame] | 46 | # start network |
| 47 | net.start() |
| 48 | net.CLI() # TODO remove this when we integrate APIs? |
| 49 | net.stop() # TODO remove this when we integrate APIs? |
| peusterm | cbcd4c2 | 2015-12-28 11:33:42 +0100 | [diff] [blame] | 50 | |
| 51 | |
| 52 | def main(): |
| 53 | create_topology1() |
| 54 | |
| 55 | |
| 56 | if __name__ == '__main__': |
| 57 | main() |