1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from __future__ import absolute_import
13 from six.moves import filter
15 from flasgger import Swagger
16 from flask import Flask
17 from flask_restful import Api
19 from api.database import Base
20 from api.database import db_session
21 from api.database import engine
22 from api.database import models
23 from api.urls import urlpatterns
24 from yardstick import _init_logging
26 logger = logging.getLogger(__name__)
36 def shutdown_session(exception=None):
41 api.add_resource(u.resource, u.url, endpoint=u.endpoint)
47 if issubclass(a[1], Base):
53 subclses = filter(func, inspect.getmembers(models, inspect.isclass))
54 logger.debug('Import models: %s', [a[1] for a in subclses])
55 Base.metadata.create_all(bind=engine)
58 def app_wrapper(*args, **kwargs):
60 return app(*args, **kwargs)
63 if __name__ == '__main__':
65 logger.setLevel(logging.DEBUG)
66 logger.info('Starting server')
68 app.run(host='0.0.0.0')