Jim Rigsbee
2020-02-19 b85b617c82f35924483db96c2777c9f1f31aaea4
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
26
27
28
29
30
31
#!/usr/bin/python
from flask import Flask, request, jsonify, make_response
import requests
import os.path
import json
 
application = Flask(__name__)
 
@application.route('/api/provision/v1/healthz')
def healthz():
    return make_response(jsonify({"health": "ok"}), 200)
 
@application.route('/api/provision/v1/status')
def status():
 
    if os.path.exists('/tmp/provision_report.json'):
        with open('/tmp/provision_report.json') as json_file:
            data = json.load(json_file)
            return make_response(jsonify(data), 200)
 
    return make_response(jsonify({"status": "unknown"}), 404)
 
@application.route('/api/provision/v1/report', methods=['POST'])
def report():
    with open('/tmp/provision_report.json', 'w') as json_file:
        json.dump(request.json, json_file)
 
    return make_response("", 200)
 
if __name__ == '__main__':
     application.run(host='127.0.0.1')