Added 5GTANGO lightweight lifecycle manager (LLCM).
[osm/vim-emu.git] / examples / tango_default_cli_topology_2_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 dc2 = net.addDatacenter("dc2")
43 # interconnect data centers
44 net.addLink(dc1, dc2, delay="20ms")
45 # add the command line interface endpoint to the emulated DC (REST API)
46 rapi1 = RestApiEndpoint("0.0.0.0", 5001)
47 rapi1.connectDCNetwork(net)
48 rapi1.connectDatacenter(dc1)
49 rapi1.connectDatacenter(dc2)
50 rapi1.start()
51 # add the 5GTANGO lightweight life cycle manager (LLCM) to the topology
52 llcm1 = TangoLLCMEndpoint("0.0.0.0", 5000, deploy_sap=False)
53 llcm1.connectDatacenter(dc1)
54 llcm1.connectDatacenter(dc2)
55 # run the dummy gatekeeper (in another thread, don't block)
56 llcm1.start()
57 # start the emulation and enter interactive CLI
58 net.start()
59 net.CLI()
60 # when the user types exit in the CLI, we stop the emulator
61 net.stop()
62
63
64 def main():
65 create_topology()
66
67
68 if __name__ == '__main__':
69 main()