aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/dcaegen2-services-slice-analysis-ms/slice-analysis-ms/configdb-sim.py
blob: bcda08d5aaf4a6eacfc8dd69da82b375252a7bf8 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import flask
import json
from flask import Flask, render_template
from flask import request
from flask import jsonify
import requests
import threading
import time

app = flask.Flask(__name__)
app.config["DEBUG"] = True


def get_du_list_for_nssai(snssai):
    if str(snssai) == '001-00110':
        with open('du_list_001_00110.json') as du_list:
            data = json.load(du_list)
    else:
        with open('du_list_001_010000.json') as du_list:
            data = json.load(du_list)
    if not data:
        return {"Error": "Unable to read file"}, 503
    return data, None


def get_du_cell_list_for_nssai(snssai):
    if str(snssai) == '001-00110':
        with open('du_cell_list_001_00110.json') as du_cell_list:
            data = json.load(du_cell_list)
    else:
        with open('du_cell_list_001_010000.json') as du_cell_list:
            data = json.load(du_cell_list)
    if not data:
        return {"Error": "Unable to read file"}, 503
    return data, None


def get_slice_config_for_nssai(snssai):
    if str(snssai) == '001-00110':
        with open('slice_config_001_00110.json') as slice_config:
            data = json.load(slice_config)
    else:
        with open('slice_config_001_010000.json') as slice_config:
            data = json.load(slice_config)
    if not data:
        return {"Error": "Unable to read file"}, 503
    return data, None


def get_profile_config_for_nssai(snssai):
    if str(snssai) == '001-00110':
        with open('profile_config_001_00110.json') as profile_config:
            data = json.load(profile_config)
    else:
        with open('profile_config_001_010000.json') as profile_config:
            data = json.load(profile_config)
    if not data:
        return {"Error": "Unable to read file"}, 503
    return data, None


def get_subscriber_details_for_nssai(snssai):
    if str(snssai) == '001-00110':
        with open('subscriber-details_001_00110.json') as subscriber_details:
            data = json.load(subscriber_details)
    else:
        with open('subscriber-details_001_010000.json') as subscriber_details:
            data = json.load(subscriber_details)
    if not data:
        return {"Error": "Unable to read file"}, 503
    return data, None


@app.route("/api/sdnc-config-db/v4/du-list/<snssai>", methods=["GET"])
def get_du_list(snssai):
    data, status = get_du_list_for_nssai(snssai)
    if not status:
        return jsonify(data)
    return data, 503


@app.route("/api/sdnc-config-db/v4/du-cell-list/<snssai>", methods=["GET"])
def get_du_cell_list(snssai):
    data, status = get_du_cell_list_for_nssai(snssai)
    if not status:
        return jsonify(data)
    return data, 503


@app.route("/api/sdnc-config-db/v4/slice-config/<snssai>", methods=["GET"])
def get_slice_config(snssai):
    data, status = get_slice_config_for_nssai(snssai)
    if not status:
        return jsonify(data)
    return data, 503


@app.route("/api/sdnc-config-db/v4/profile-config/<snssai>", methods=["GET"])
def get_profile_config(snssai):
    data, status = get_profile_config_for_nssai(snssai)
    if not status:
        return jsonify(data)
    return data, 503


@app.route("/api/sdnc-config-db/v4/subscriber-details/<snssai>",
           methods=["GET"])
def get_subscriber_details(snssai):
    data, status = get_subscriber_details_for_nssai(snssai)
    if not status:
        return jsonify(data)
    return data, 503


app.run(host='0.0.0.0')