Added script for measuring impact of delay on OSM
[osm/vim-emu.git] / examples / tango_default_cli_topology_1_pop.py
1 # Copyright (c) 2018 SONATA-NFV, 5GTANGO and Paderborn University
2 # ALL RIGHTS RESERVED.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 # Neither the name of the SONATA-NFV, 5GTANGO, Paderborn University
17 # nor the names of its contributors may be used to endorse or promote
18 # products derived from this software without specific prior written
19 # permission.
20 #
21 # This work has also been performed in the framework of the 5GTANGO project,
22 # funded by the European Commission under Grant number 761493 through
23 # the Horizon 2020 and 5G-PPP programmes. The authors would like to
24 # acknowledge the contributions of their colleagues of the 5GTANGO
25 # partner consortium (www.5gtango.eu).
26 import logging
27 from mininet.log import setLogLevel
28 from emuvim.dcemulator.net import DCNetwork
29 from emuvim.api.rest.rest_api_endpoint import RestApiEndpoint
30 from emuvim.api.tango import TangoLLCMEndpoint
31
32 logging.basicConfig(level=logging.DEBUG)
33 setLogLevel('info') # set Mininet loglevel
34 logging.getLogger('werkzeug').setLevel(logging.DEBUG)
35 logging.getLogger('5gtango.llcm').setLevel(logging.DEBUG)
36
37
38 def create_topology():
39 net = DCNetwork(monitor=False, enable_learning=True)
40 # create two data centers
41 dc1 = net.addDatacenter("dc1")
42 # add the command line interface endpoint to the emulated DC (REST API)
43 rapi1 = RestApiEndpoint("0.0.0.0", 5001)
44 rapi1.connectDCNetwork(net)
45 rapi1.connectDatacenter(dc1)
46 rapi1.start()
47 # add the 5GTANGO lightweight life cycle manager (LLCM) to the topology
48 llcm1 = TangoLLCMEndpoint("0.0.0.0", 5000, deploy_sap=False)
49 llcm1.connectDatacenter(dc1)
50 # run the dummy gatekeeper (in another thread, don't block)
51 llcm1.start()
52 # start the emulation and enter interactive CLI
53 net.start()
54 net.CLI()
55 # when the user types exit in the CLI, we stop the emulator
56 net.stop()
57
58
59 def main():
60 create_topology()
61
62
63 if __name__ == '__main__':
64 main()