commit | author | age
|
b85b61
|
1 |
#!/usr/bin/python |
JR |
2 |
from flask import Flask, request, jsonify, make_response |
|
3 |
import requests |
|
4 |
import os.path |
|
5 |
import json |
|
6 |
|
|
7 |
application = Flask(__name__) |
|
8 |
|
|
9 |
@application.route('/api/provision/v1/healthz') |
|
10 |
def healthz(): |
|
11 |
return make_response(jsonify({"health": "ok"}), 200) |
|
12 |
|
|
13 |
@application.route('/api/provision/v1/status') |
|
14 |
def status(): |
|
15 |
|
|
16 |
if os.path.exists('/tmp/provision_report.json'): |
|
17 |
with open('/tmp/provision_report.json') as json_file: |
|
18 |
data = json.load(json_file) |
|
19 |
return make_response(jsonify(data), 200) |
|
20 |
|
|
21 |
return make_response(jsonify({"status": "unknown"}), 404) |
|
22 |
|
|
23 |
@application.route('/api/provision/v1/report', methods=['POST']) |
|
24 |
def report(): |
|
25 |
with open('/tmp/provision_report.json', 'w') as json_file: |
|
26 |
json.dump(request.json, json_file) |
|
27 |
|
|
28 |
return make_response("", 200) |
|
29 |
|
|
30 |
if __name__ == '__main__': |
|
31 |
application.run(host='127.0.0.1') |