| stevenvanrossem | 3df73e8 | 2017-04-22 19:37:29 +0200 | [diff] [blame] | 1 | """ |
| 2 | Copyright (c) 2015 SONATA-NFV |
| 3 | ALL RIGHTS RESERVED. |
| 4 | |
| 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | you may not use this file except in compliance with the License. |
| 7 | You may obtain a copy of the License at |
| 8 | |
| 9 | http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 11 | Unless required by applicable law or agreed to in writing, software |
| 12 | distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | See the License for the specific language governing permissions and |
| 15 | limitations under the License. |
| 16 | |
| 17 | Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION] |
| 18 | nor the names of its contributors may be used to endorse or promote |
| 19 | products derived from this software without specific prior written |
| 20 | permission. |
| 21 | |
| 22 | This work has been performed in the framework of the SONATA project, |
| 23 | funded by the European Commission under Grant number 671517 through |
| 24 | the Horizon 2020 and 5G-PPP programmes. The authors would like to |
| 25 | acknowledge the contributions of their colleagues of the SONATA |
| 26 | partner consortium (www.sonata-nfv.eu). |
| 27 | """ |
| 28 | """ |
| 29 | A simple topology with two PoPs for the y1 demo story board. |
| 30 | |
| 31 | (dc1) <<-->> s1 <<-->> (dc2) |
| 32 | |
| 33 | - SAP deployment enabled |
| 34 | - learning switch enabled |
| 35 | """ |
| 36 | |
| 37 | import logging |
| 38 | from mininet.log import setLogLevel |
| 39 | from emuvim.dcemulator.net import DCNetwork |
| 40 | from emuvim.api.rest.rest_api_endpoint import RestApiEndpoint |
| 41 | from emuvim.api.sonata import SonataDummyGatekeeperEndpoint |
| 42 | from mininet.node import RemoteController |
| 43 | import os |
| 44 | |
| 45 | logging.basicConfig(level=logging.INFO) |
| 46 | |
| 47 | |
| 48 | def create_topology1(): |
| 49 | # create topology |
| 50 | net = DCNetwork(controller=RemoteController, monitor=False, enable_learning=True) |
| 51 | dc1 = net.addDatacenter("dc1") |
| stevenvanrossem | ba51a81 | 2017-04-23 01:22:59 +0200 | [diff] [blame] | 52 | dc2 = net.addDatacenter("dc2") |
| 53 | dc3 = net.addDatacenter("dc3") |
| 54 | s1 = net.addSwitch("s1") |
| 55 | net.addLink(dc1, s1) |
| 56 | net.addLink(dc2, s1) |
| 57 | net.addLink(dc3, s1) |
| stevenvanrossem | 3df73e8 | 2017-04-22 19:37:29 +0200 | [diff] [blame] | 58 | |
| 59 | # add the command line interface endpoint to each DC (REST API) |
| 60 | rapi1 = RestApiEndpoint("0.0.0.0", 5001) |
| 61 | rapi1.connectDCNetwork(net) |
| 62 | rapi1.connectDatacenter(dc1) |
| stevenvanrossem | ba51a81 | 2017-04-23 01:22:59 +0200 | [diff] [blame] | 63 | rapi1.connectDatacenter(dc2) |
| 64 | rapi1.connectDatacenter(dc3) |
| stevenvanrossem | 3df73e8 | 2017-04-22 19:37:29 +0200 | [diff] [blame] | 65 | # run API endpoint server (in another thread, don't block) |
| 66 | rapi1.start() |
| 67 | |
| 68 | |
| 69 | # specify a vnfd file to be deployed as internal SAP: |
| stevenvanrossem | 412c7ff | 2017-05-05 11:33:25 +0200 | [diff] [blame] | 70 | sap_vnfd = 'custom_sap_vnfd.yml' |
| stevenvanrossem | 3df73e8 | 2017-04-22 19:37:29 +0200 | [diff] [blame] | 71 | dir_path = os.path.dirname(__file__) |
| 72 | sap_vnfd_path = os.path.join(dir_path, sap_vnfd) |
| 73 | # sap_vnfd_path = None |
| 74 | # add the SONATA dummy gatekeeper to each DC |
| 75 | sdkg1 = SonataDummyGatekeeperEndpoint("0.0.0.0", 5000, deploy_sap=True, auto_deploy=True, |
| 76 | docker_management=True, auto_delete=True, |
| 77 | sap_vnfd_path=sap_vnfd_path) |
| 78 | sdkg1.connectDatacenter(dc1) |
| stevenvanrossem | ba51a81 | 2017-04-23 01:22:59 +0200 | [diff] [blame] | 79 | sdkg1.connectDatacenter(dc2) |
| 80 | sdkg1.connectDatacenter(dc3) |
| stevenvanrossem | 3df73e8 | 2017-04-22 19:37:29 +0200 | [diff] [blame] | 81 | # run the dummy gatekeeper (in another thread, don't block) |
| 82 | sdkg1.start() |
| 83 | |
| 84 | # start the emulation platform |
| 85 | net.start() |
| 86 | net.CLI() |
| 87 | net.stop() |
| 88 | |
| 89 | |
| 90 | def main(): |
| 91 | setLogLevel('info') # set Mininet loglevel |
| 92 | create_topology1() |
| 93 | |
| 94 | |
| 95 | if __name__ == '__main__': |
| 96 | main() |