| splietker | 7b38ee1 | 2017-06-28 17:24:01 +0200 | [diff] [blame] | 1 | """ |
| peusterm | d7cbd21 | 2017-09-07 08:55:14 +0200 | [diff] [blame^] | 2 | Copyright (c) 2017 SONATA-NFV and Paderborn University |
| splietker | 7b38ee1 | 2017-06-28 17:24:01 +0200 | [diff] [blame] | 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 | |
| peusterm | d7cbd21 | 2017-09-07 08:55:14 +0200 | [diff] [blame^] | 17 | Neither the name of the SONATA-NFV, Paderborn University |
| splietker | 7b38ee1 | 2017-06-28 17:24:01 +0200 | [diff] [blame] | 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 | import logging |
| 29 | from mininet.log import setLogLevel |
| 30 | from emuvim.dcemulator.net import DCNetwork |
| peusterm | 7cef04b | 2017-08-29 19:41:13 +0200 | [diff] [blame] | 31 | from emuvim.api.rest.rest_api_endpoint import RestApiEndpoint |
| splietker | 7b38ee1 | 2017-06-28 17:24:01 +0200 | [diff] [blame] | 32 | from emuvim.api.openstack.openstack_api_endpoint import OpenstackApiEndpoint |
| 33 | |
| 34 | logging.basicConfig(level=logging.INFO) |
| peusterm | b668d69 | 2017-08-30 09:22:15 +0200 | [diff] [blame] | 35 | setLogLevel('info') # set Mininet loglevel |
| 36 | logging.getLogger('werkzeug').setLevel(logging.DEBUG) |
| 37 | logging.getLogger('api.openstack.base').setLevel(logging.DEBUG) |
| 38 | logging.getLogger('api.openstack.compute').setLevel(logging.DEBUG) |
| 39 | logging.getLogger('api.openstack.keystone').setLevel(logging.DEBUG) |
| 40 | logging.getLogger('api.openstack.nova').setLevel(logging.DEBUG) |
| 41 | logging.getLogger('api.openstack.neutron').setLevel(logging.DEBUG) |
| 42 | logging.getLogger('api.openstack.heat').setLevel(logging.DEBUG) |
| 43 | logging.getLogger('api.openstack.heat.parser').setLevel(logging.DEBUG) |
| 44 | logging.getLogger('api.openstack.glance').setLevel(logging.DEBUG) |
| 45 | logging.getLogger('api.openstack.helper').setLevel(logging.DEBUG) |
| splietker | 7b38ee1 | 2017-06-28 17:24:01 +0200 | [diff] [blame] | 46 | |
| 47 | |
| 48 | def create_topology(): |
| 49 | net = DCNetwork(monitor=False, enable_learning=False) |
| 50 | |
| 51 | dc1 = net.addDatacenter("dc1") |
| peusterm | 7cef04b | 2017-08-29 19:41:13 +0200 | [diff] [blame] | 52 | # add OpenStack-like APIs to the emulated DC |
| splietker | 7b38ee1 | 2017-06-28 17:24:01 +0200 | [diff] [blame] | 53 | api1 = OpenstackApiEndpoint("0.0.0.0", 6001) |
| 54 | api1.connect_datacenter(dc1) |
| 55 | api1.start() |
| 56 | api1.connect_dc_network(net) |
| peusterm | 7cef04b | 2017-08-29 19:41:13 +0200 | [diff] [blame] | 57 | # add the command line interface endpoint to the emulated DC (REST API) |
| 58 | rapi1 = RestApiEndpoint("0.0.0.0", 5001) |
| 59 | rapi1.connectDCNetwork(net) |
| 60 | rapi1.connectDatacenter(dc1) |
| 61 | rapi1.start() |
| splietker | 7b38ee1 | 2017-06-28 17:24:01 +0200 | [diff] [blame] | 62 | |
| 63 | net.start() |
| 64 | net.CLI() |
| 65 | # when the user types exit in the CLI, we stop the emulator |
| 66 | net.stop() |
| 67 | |
| 68 | |
| 69 | def main(): |
| splietker | 7b38ee1 | 2017-06-28 17:24:01 +0200 | [diff] [blame] | 70 | create_topology() |
| 71 | |
| 72 | |
| 73 | if __name__ == '__main__': |
| 74 | main() |