Matteo Scandolo | 9ce1825 | 2017-06-22 10:48:25 -0700 | [diff] [blame] | 1 | import os |
| 2 | from grpc_client.main import GRPC_Client |
| 3 | from tosca.generator import TOSCA_Generator |
| 4 | from web_server.main import TOSCA_WebServer |
Matteo Scandolo | 21dde41 | 2017-07-11 18:54:12 -0700 | [diff] [blame] | 5 | from twisted.internet import defer |
Matteo Scandolo | 9ce1825 | 2017-06-22 10:48:25 -0700 | [diff] [blame] | 6 | from xosconfig import Config |
| 7 | |
| 8 | current_dir = os.path.dirname(os.path.realpath(__file__)) |
| 9 | config_file = os.path.join(current_dir, './xos-tosca-config.yaml') |
| 10 | config_schema = os.path.join(current_dir, './xos-tosca-config-schema.yaml') |
| 11 | Config.init(config_file, config_schema) |
| 12 | |
| 13 | class Main: |
| 14 | |
| 15 | def __init__(self): |
| 16 | self.grpc_client = None |
| 17 | |
| 18 | def generate_tosca(self, client): |
| 19 | |
| 20 | deferred = defer.Deferred() |
| 21 | |
| 22 | TOSCA_Generator().generate(client) |
| 23 | |
Matteo Scandolo | 9ce1825 | 2017-06-22 10:48:25 -0700 | [diff] [blame] | 24 | |
| 25 | return deferred |
| 26 | |
| 27 | def start(self): |
| 28 | print "[XOS-TOSCA] Starting" |
| 29 | |
| 30 | grpc_setup = GRPC_Client().start() |
| 31 | grpc_setup.addCallback(self.generate_tosca) |
| 32 | |
Matteo Scandolo | 21dde41 | 2017-07-11 18:54:12 -0700 | [diff] [blame] | 33 | # NOTE that TOSCA_WebServer create a Klein app that call reactor.run() |
| 34 | TOSCA_WebServer() |
Matteo Scandolo | 9ce1825 | 2017-06-22 10:48:25 -0700 | [diff] [blame] | 35 | |
| 36 | |
| 37 | if __name__ == '__main__': |
| 38 | Main().start() |