+ test_status_result = []
+
+ for si in r['result']['tests']:
+ c = exfo.call_remote_api(si['test_instance_class_uri']).json()['result']
+ service = c['service']
+ target = None
+ if 'target' in c:
+ target = c['target']
+ test_instance_class_result.append(c)
+ c = exfo.call_remote_api(si['test_status_uri']).json()['result']
+ test_status_result.append({'sla_name':sla_name, 'test_instance_id': si['test_instance_id'],\
+ 'service': service, 'target': target, \
+ 'type_type_name': si['test_type_name'],\
+ 'test_instance_class_id': si['test_instance_class_id'] , 'status': c, })
+
+ t['test_instance_class_result'] = test_instance_class_result
+ t['test_status_result'] = test_status_result
+ t['created'] = datetime.utcnow()
+ col.insert_one(t)
+
+ # pprint(temp)
+ #col.insert_many(temp)
+ results = col.find({})
+ data = dumps(list(results), indent=4)
+ return HttpResponse(data, content_type='application/json')
+
+
+@shared_task
+def dump_api_task():
+ from bson.json_util import dumps
+ from bson.json_util import loads
+ col = db['exfo_api']
+ # col.delete_many({})
+ sla = exfo.call_api("sla")
+ sla_json = sla.json()
+ temp = sla_json['result']
+ for t in temp:
+ sla_uri = t['ids']['sla_uri']
+ sla_name = t['ids']['sla_name']
+ r = exfo.call_remote_api(sla_uri).json()
+ t['sla_uri_result'] = r['result']
+ service_result = []
+ for si in r['result']['service_instances']:
+ c = exfo.call_remote_api(si['service_uri']).json()['result']
+ service_result.append(c)
+
+ test_instance_class_result = []
+ test_status_result = []
+
+ for si in r['result']['tests']:
+ c = exfo.call_remote_api(si['test_instance_class_uri']).json()['result']
+ service = c['service']
+ target = None
+ if 'target' in c:
+ target = c['target']
+ test_instance_class_result.append(c)
+ c = exfo.call_remote_api(si['test_status_uri']).json()['result']
+ test_status_result.append({'sla_name':sla_name, 'test_instance_id': si['test_instance_id'],\
+ 'service': service, 'target': target, \
+ 'type_type_name': si['test_type_name'],\
+ 'test_instance_class_id': si['test_instance_class_id'] , 'status': c, })
+
+ t['test_instance_class_result'] = test_instance_class_result
+ t['test_status_result'] = test_status_result
+ t['created'] = datetime.utcnow()
+ col.insert_one(t)
+
+ pprint("Dump API ... Finished")
+
+def print_table(request):
+ return render(request, 'backend/print_table.html')
+
+
|
|
||
| 1 |
|
1 |
|
| 2 |
|
2 |
|
| 3 |
|
3 |
|
|
4 |
|
|
|
5 |
|
|
| 4 |
|
6 |
|
| 5 |
|
7 |
|
| 6 |
|
8 |
|
|
|
||
| 46 |
|
48 |
|
| 47 |
|
49 |
|
| 48 |
|
50 |
|
| 49 |
|
|
|
|
51 |
|
|
| 50 |
|
52 |
|
| 51 |
|
53 |
|
| 52 |
|
54 |
|
|
|
||
|
1 |
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
||
| 24 |
|
24 |
|
| 25 |
|
25 |
|
| 26 |
|
26 |
|
| 27 |
|
|
|
|
27 |
|
|
| 28 |
|
28 |
|
| 29 |
|
29 |
|
| 30 |
|
30 |
|
|
|
||
| 192 |
|
192 |
|
| 193 |
|
193 |
|
| 194 |
|
194 |
|
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
|
||
| 1 |
|
1 |
|
| 2 |
|
|
|
|
2 |
|
|
| 3 |
|
3 |
|
|
|
||
| 7 |
|
7 |
|
| 8 |
|
8 |
|
| 9 |
|
9 |
|
| 10 |
|
|
|
|
10 |
|
|
| 11 |
|
11 |
|
| 12 |
|
12 |
|
| 13 |
|
13 |
|
|
|
||
| 42 |
|
42 |
|
| 43 |
|
43 |
|
| 44 |
|
44 |
|
| 45 |
|
|
|
|
45 |
|
|
| 46 |
|
46 |
|
| 47 |
|
47 |
|
| 48 |
|
48 |
|
|
|
||
| 53 |
|
53 |
|
| 54 |
|
54 |
|
| 55 |
|
55 |
|
| 56 |
|
|
|
|
56 |
|
|
| 57 |
|
57 |
|
| 58 |
|
58 |
|
| 59 |
|
59 |
|
| 60 |
|
|
|
| 61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
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
| 64 |
|
64 |
|
| 65 |
|
65 |
|
| 66 |
|
66 |
|
|
|
||
| 79 |
|
79 |
|
| 80 |
|
80 |
|
| 81 |
|
81 |
|
| 82 |
|
|
|
| 83 |
|
|
|
| 84 |
|
|
|
| 85 |
|
|
|
| 86 |
|
|
|
| 87 |
|
|
|
| 88 |
|
|
|
| 89 |
|
|
|
| 90 |
|
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
| 91 |
|
91 |
|
| 92 |
|
92 |
|
|
|
||
| 38 |
|
38 |
|
| 39 |
|
39 |
|
| 40 |
|
40 |
|
| 41 |
|
|
|
|
41 |
|
|
| 42 |
|
42 |
|
| 43 |
|
43 |
|
| 44 |
|
44 |
|