Revert "basic auth for so-monitoring"
[oom.git] / kubernetes / oof / charts / oof-cmso / charts / oof-cmso-service / resources / config / mock.py
1  # -------------------------------------------------------------------------
2  #   Copyright (c) 2019 AT&T Intellectual Property
3  #
4  #   Licensed under the Apache License, Version 2.0 (the "License");
5  #   you may not use this file except in compliance with the License.
6  #   You may obtain a copy of the License at
7  #
8  #       http://www.apache.org/licenses/LICENSE-2.0
9  #
10  #   Unless required by applicable law or agreed to in writing, software
11  #   distributed under the License is distributed on an "AS IS" BASIS,
12  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  #   See the License for the specific language governing permissions and
14  #   limitations under the License.
15  #
16  # -------------------------------------------------------------------------
17  #
18
19 from flask import Flask
20 from flask import request
21 from flask import Response
22 from flask import json
23 from flask import send_from_directory
24 import requests
25 from threading import Thread
26 import time
27
28 import os
29 import fnmatch
30 import re
31 import time
32 import datetime
33
34 app = Flask(__name__)
35 ROOT_MOCK_DIR = os.path.dirname(os.path.abspath(__file__))
36 DATA_DIR =   os.path.join(ROOT_MOCK_DIR, "data")
37 global requestNum
38 requestNum = 1
39
40 ########################################################################
41 ########################################################################
42 @app.route('/onap/so/infra/orchestrationRequests/v7/schedule/<VNFNAME>', methods=['GET', 'POST'])
43 def soSchedule(VNFNAME):
44     if request.method == 'POST':
45         testid = request.headers.environ["HTTP_X_TRANSACTIONID"]
46         response = {
47             "status" : "202",
48             "entity" : {
49                 "requestReferences" : {
50                     "requestId" : "000001"
51                     }
52                 }
53             }
54         resp = Response(json.dumps(response), 200, mimetype='application/json')
55         return resp
56
57
58     else :
59         return "Helloooooo!!!!"
60
61 ########################################################################
62 ########################################################################
63 @app.route('/onap/so/infra/orchestrationRequests/v7/<REQUESTID>', methods=['GET'])
64 def soStatus(REQUESTID):
65     response = {"request" : { "requestStatus" : {
66         "requestState" : "COMPLETE",
67         "statusMessage" : "Done.",
68         "percentProgress" : 100,
69         "finishTime" : ""
70         }}}
71     now = datetime.datetime.utcnow()
72     #response["finishTime"] = now.strftime("%Y-%m-%dT%H:%M:%SZ")
73     response["request"]["requestStatus"]["finishTime"] = now.strftime("%a, %d %b %Y %H:%M:%S GMT")
74     resp = Response(json.dumps(response), 200, mimetype='application/json')
75
76     return resp
77
78 ########################################################################
79 ########################################################################
80 if __name__ == "__main__":
81     app.run(host= '0.0.0.0',port=5000)
82     #app.run()
83