blob: 2040977a3bd2bbd8a7ece752822a939bf6154ed1 [file] [log] [blame]
Matteo Scandolo920e8fd2017-08-08 13:05:24 -07001
2# Copyright 2017-present Open Networking Foundation
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
Matteo Scandolo9ce18252017-06-22 10:48:25 -070017import os
18from grpc_client.main import GRPC_Client
19from tosca.generator import TOSCA_Generator
20from web_server.main import TOSCA_WebServer
Matteo Scandolo21dde412017-07-11 18:54:12 -070021from twisted.internet import defer
Matteo Scandolo9ce18252017-06-22 10:48:25 -070022from xosconfig import Config
23
24current_dir = os.path.dirname(os.path.realpath(__file__))
25config_file = os.path.join(current_dir, './xos-tosca-config.yaml')
26config_schema = os.path.join(current_dir, './xos-tosca-config-schema.yaml')
27Config.init(config_file, config_schema)
28
29class Main:
30
31 def __init__(self):
32 self.grpc_client = None
33
34 def generate_tosca(self, client):
35
36 deferred = defer.Deferred()
37
38 TOSCA_Generator().generate(client)
39
Matteo Scandolo9ce18252017-06-22 10:48:25 -070040
41 return deferred
42
43 def start(self):
44 print "[XOS-TOSCA] Starting"
45
46 grpc_setup = GRPC_Client().start()
47 grpc_setup.addCallback(self.generate_tosca)
48
Matteo Scandolo21dde412017-07-11 18:54:12 -070049 # NOTE that TOSCA_WebServer create a Klein app that call reactor.run()
50 TOSCA_WebServer()
Matteo Scandolo9ce18252017-06-22 10:48:25 -070051
52
53if __name__ == '__main__':
54 Main().start()