summaryrefslogtreecommitdiffstats
path: root/src/telemetry/server/ceph_telemetry/app.py
blob: 0d2b5e1d7603eecbd753e9b553448b69eed40ed6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python3
import argparse
from flask_restful import Api
from flask import Flask
from ceph_telemetry.rest import Index, Report, Device


def create_app(name):
    app = Flask(name)
    api = Api(app, catch_all_404s=True)
    api.add_resource(Index, '/')
    api.add_resource(Report, '/report')
    api.add_resource(Device, '/device')
    return app


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Ceph Telemetry REST API')
    parser.add_argument("--host", action="store", dest="host",
                        default="::", help="Host/IP to bind on")
    parser.add_argument("--port", action="store", dest="port", type=int,
                        default=9000, help="Port to listen on")
    args = parser.parse_args()
    app = create_app(__name__)
    app.run(debug=True, host=args.host, port=args.port)