44988d6ac8bb277a9a968ffcdcb2ab98be0496c1
1 # Copyright (c) 2015 SONATA-NFV 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, 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).
28 import dummygatekeeper
as dgk
31 class SonataDummyGatekeeperEndpoint(object):
33 Creates and starts a REST API based on Flask in an
36 Can connect this API to data centers defined in an emulator
40 def __init__(self
, listenip
, port
, deploy_sap
=False, docker_management
=False,
41 auto_deploy
=False, auto_delete
=False, sap_vnfd_path
=None):
45 dgk
.DEPLOY_SAP
= deploy_sap
46 dgk
.USE_DOCKER_MGMT
= docker_management
47 dgk
.AUTO_DEPLOY
= auto_deploy
48 dgk
.AUTO_DELETE
= auto_delete
49 dgk
.SAP_VNFD
= sap_vnfd_path
50 logging
.debug("Created API endpoint %s" % self
)
53 return "%s(%s:%d)" % (self
.__class
__.__name
__, self
.ip
, self
.port
)
55 def connectDatacenter(self
, dc
):
56 self
.dcs
[dc
.label
] = dc
57 logging
.info("Connected DC(%s) to API endpoint %s" % (
61 thread
= threading
.Thread(target
=self
._api
_server
_thread
, args
=())
64 logging
.debug("Started API endpoint %s" % self
)
66 def _api_server_thread(self
):
67 dgk
.start_rest_api(self
.ip
, self
.port
, self
.dcs
)