1 # Copyright (c) 2018 SONATA-NFV, 5GTANGO and Paderborn University
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
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
21 # This work has been performed in the framework of the SONATA project,
22 # funded by the European Commission under Grant number 671517 through
23 # the Horizon 2020 and 5G-PPP programmes. The authors would like to
24 # acknowledge the contributions of their colleagues of the SONATA
25 # partner consortium (www.sonata-nfv.eu).
27 # This work has also been performed in the framework of the 5GTANGO project,
28 # funded by the European Commission under Grant number 761493 through
29 # the Horizon 2020 and 5G-PPP programmes. The authors would like to
30 # acknowledge the contributions of their colleagues of the 5GTANGO
31 # partner consortium (www.5gtango.eu).
34 from emuvim
.api
.tango
import llcm
37 LOG
= logging
.getLogger("5gtango.llcm")
40 class TangoLLCMEndpoint(object):
42 Creates and starts the 5GTANGO lightweight life cycle manager to simply
43 deploy 5GTANGO service packages on the emulator.
44 The code is based on SONATA's dummygatekeeper.
47 def __init__(self
, listenip
, port
, deploy_sap
=False, docker_management
=False,
48 auto_deploy
=False, auto_delete
=False, sap_vnfd_path
=None,
49 placement_algorithm_obj
=None, env_conf_folder
=None):
53 llcm
.DEPLOY_SAP
= deploy_sap
54 llcm
.USE_DOCKER_MGMT
= docker_management
55 llcm
.AUTO_DEPLOY
= auto_deploy
56 llcm
.AUTO_DELETE
= auto_delete
57 llcm
.SAP_VNFD
= sap_vnfd_path
58 if placement_algorithm_obj
is None:
59 # Default placement is RR placement
60 placement_algorithm_obj
= llcm
.RoundRobinDcPlacement()
61 llcm
.PLACEMENT_ALGORITHM_OBJ
= placement_algorithm_obj
62 llcm
.PER_INSTANCE_ENV_CONFIGURATION_FOLDER
= env_conf_folder
63 LOG
.info("Created 5GTANGO LLCM API endpoint %s" % self
)
64 LOG
.info("Using placement algorithm: {}".format(
65 placement_algorithm_obj
))
68 return "%s(%s:%d)" % (self
.__class
__.__name
__, self
.ip
, self
.port
)
70 def connectDatacenter(self
, dc
):
71 self
.dcs
[dc
.label
] = dc
72 LOG
.debug("Connected DC(%s) to API endpoint %s" % (
76 thread
= threading
.Thread(target
=self
._api
_server
_thread
, args
=())
79 LOG
.info("Started API endpoint %s" % self
)
81 def _api_server_thread(self
):
82 llcm
.start_rest_api(self
.ip
, self
.port
, self
.dcs
)