2 Copyright (c) 2015 SONATA-NFV and Paderborn University
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
9 http://www.apache.org/licenses/LICENSE-2.0
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.
17 Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION]
18 nor the names of its contributors may be used to endorse or promote
19 products derived from this software without specific prior written
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).
29 This module implements a simple REST API that behaves like SONATA's gatekeeper.
31 It is only used to support the development of SONATA's SDK tools and to demonstrate
32 the year 1 version of the emulator until the integration with WP4's orchestrator is done.
37 import dummygatekeeper
as dgk
40 class SonataDummyGatekeeperEndpoint(object):
42 Creates and starts a REST API based on Flask in an
45 Can connect this API to data centers defined in an emulator
49 def __init__(self
, listenip
, port
, deploy_sap
=False):
53 dgk
.DEPLOY_SAP
= deploy_sap
54 logging
.debug("Created API endpoint %s" % self
)
57 return "%s(%s:%d)" % (self
.__class
__.__name
__, self
.ip
, self
.port
)
59 def connectDatacenter(self
, dc
):
60 self
.dcs
[dc
.label
] = dc
61 logging
.info("Connected DC(%s) to API endpoint %s" % (
65 thread
= threading
.Thread(target
=self
._api
_server
_thread
, args
=())
68 logging
.debug("Started API endpoint %s" % self
)
70 def _api_server_thread(self
):
71 dgk
.start_rest_api(self
.ip
, self
.port
, self
.dcs
)