blob: 6f0db8da71e8c0581de5b8920224e4f4c94def7a [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__))
Matteo Scandolo89c1f562017-10-19 19:09:45 +020025config_file = os.path.join(current_dir, 'xos-tosca.config.yaml')
26config_schema = os.path.join(current_dir, 'xos-tosca-config-schema.yaml')
27
Matteo Scandolo9ce18252017-06-22 10:48:25 -070028Config.init(config_file, config_schema)
29
30class Main:
31
32 def __init__(self):
33 self.grpc_client = None
34
35 def generate_tosca(self, client):
36
37 deferred = defer.Deferred()
38
39 TOSCA_Generator().generate(client)
40
Matteo Scandolo9ce18252017-06-22 10:48:25 -070041 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()