dbca-utils 3.0.10__tar.gz → 3.0.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/PKG-INFO +1 -1
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/pyproject.toml +1 -1
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/src/dbca_utils/healthcheck/healthcheck.py +58 -15
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/LICENSE +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/README.md +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/src/dbca_utils/__init__.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/src/dbca_utils/apps.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/src/dbca_utils/healthcheck/__init__.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/src/dbca_utils/healthcheck/urls.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/src/dbca_utils/middleware.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/src/dbca_utils/models.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/src/dbca_utils/utils.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/tests/__init__.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/tests/apps.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/tests/migrations/0001_initial.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/tests/migrations/__init__.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/tests/models.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/tests/settings.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/tests/templates/tests/test_model_list.html +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/tests/tests.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/tests/urls.py +0 -0
- {dbca_utils-3.0.10 → dbca_utils-3.0.11}/tests/views.py +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import importlib
|
|
3
|
+
from collections import OrderedDict
|
|
3
4
|
import logging
|
|
4
5
|
import psutil
|
|
5
6
|
import subprocess
|
|
@@ -565,19 +566,25 @@ def harvest_healthdata(request):
|
|
|
565
566
|
workloads_changed = True
|
|
566
567
|
elif res.status_code == 599:
|
|
567
568
|
#the server is in good health, add the health data to servers_res
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
569
|
+
try:
|
|
570
|
+
data = res.json()
|
|
571
|
+
if data["status"] == 401:
|
|
572
|
+
#authentication error, caused by different workload.
|
|
573
|
+
workloads_changed = True
|
|
574
|
+
unreached_servers.append(servername)
|
|
575
|
+
servers_res[servername] = (503,"{1}:{2},url={0}".format(url,data["status"],data["message"]))
|
|
576
|
+
else:
|
|
577
|
+
servers_res[servername] = (500,"{1}:{2}. url={0}".format(url,data["status"],data["message"]))
|
|
578
|
+
except:
|
|
571
579
|
workloads_changed = True
|
|
572
580
|
unreached_servers.append(servername)
|
|
573
|
-
servers_res[servername] = (
|
|
574
|
-
|
|
575
|
-
servers_res[servername] = (res.status_code,"{1}:{2}. url={0}".format(url,data["status"],data["message"]))
|
|
581
|
+
servers_res[servername] = (503,"Web server is offline.url={0}".format(url))
|
|
582
|
+
|
|
576
583
|
else:
|
|
577
584
|
#unexpected error, caused by different workload
|
|
578
585
|
workloads_changed = True
|
|
579
586
|
unreached_servers.append(servername)
|
|
580
|
-
servers_res[servername] = (
|
|
587
|
+
servers_res[servername] = (500,"{1}:{2},url={0}".format(url,res.status_code,res.text))
|
|
581
588
|
|
|
582
589
|
for servername in unreached_servers:
|
|
583
590
|
del workloads[servername]
|
|
@@ -589,7 +596,7 @@ def harvest_healthdata(request):
|
|
|
589
596
|
|
|
590
597
|
return (workloads,servers_res)
|
|
591
598
|
|
|
592
|
-
OFFLINE_STATUSCODE_LIST = (502,503,504,401,403,-1
|
|
599
|
+
OFFLINE_STATUSCODE_LIST = (502,503,504,401,403,-1)
|
|
593
600
|
if WORKLOADS > 0 and WORKLOAD_DEPLOYMENT:
|
|
594
601
|
#has a fixed number of workloads and it is a deployment
|
|
595
602
|
WORKLOADNAMES = [get_workloadname(index) for index in range(WORKLOADS)]
|
|
@@ -622,6 +629,7 @@ if WORKLOADS > 0 and WORKLOAD_DEPLOYMENT:
|
|
|
622
629
|
|
|
623
630
|
assignedworkloads_changed = False
|
|
624
631
|
if len(WORKLOADNAMES) != len(assignedworkloads):
|
|
632
|
+
#remove the unexisted workloads from assignedworkloads.
|
|
625
633
|
for key in [k for k in assignedworkloads.keys()]:
|
|
626
634
|
if key == item_version:
|
|
627
635
|
continue
|
|
@@ -643,7 +651,7 @@ if WORKLOADS > 0 and WORKLOAD_DEPLOYMENT:
|
|
|
643
651
|
#related server is online.no need to reassign
|
|
644
652
|
continue
|
|
645
653
|
elif step == 1:
|
|
646
|
-
#step 1 only reassign the assigned workloads
|
|
654
|
+
#step 1 only reassign the already assigned workloads
|
|
647
655
|
if workloadname not in assignedworkloads:
|
|
648
656
|
continue
|
|
649
657
|
replacedservername = None
|
|
@@ -678,13 +686,20 @@ if WORKLOADS > 0 and WORKLOAD_DEPLOYMENT:
|
|
|
678
686
|
save_assignedworkloads(assignedworkloads)
|
|
679
687
|
|
|
680
688
|
#map the healthdata result to workload. and remove status code
|
|
681
|
-
result =
|
|
689
|
+
result = OrderedDict()
|
|
682
690
|
for workloadname in WORKLOADNAMES:
|
|
683
691
|
servername = assignedworkloads.get(workloadname)
|
|
684
692
|
if not servername:
|
|
685
|
-
|
|
693
|
+
if settings.DEBUG:
|
|
694
|
+
result[workloadname] = "Can't find an available host for this non-assigned host.registered workloads: {0}, assigned workloads:{1}".format(str_workloads(workloads),assignedworkloads)
|
|
695
|
+
else:
|
|
696
|
+
result[workloadname] = "Can't find an available host for this non-assigned host."
|
|
686
697
|
elif servername not in datas:
|
|
687
|
-
|
|
698
|
+
if settings.DEBUG:
|
|
699
|
+
result[workloadname] = "Can't find an available host for this assigned offline host({2}).registered workloads: {0}, assigned workloads:{1}".format(str_workloads(workloads),assignedworkloads,servername)
|
|
700
|
+
else:
|
|
701
|
+
result[workloadname] = "Can't find an available host for this assigned offline host({0}).".format(servername)
|
|
702
|
+
|
|
688
703
|
elif datas[servername][0] == 200:
|
|
689
704
|
result[workloadname] = datas[servername][1]
|
|
690
705
|
result[workloadname]["hostname"] = servername
|
|
@@ -703,7 +718,7 @@ elif WORKLOADS > 0 and not WORKLOAD_DEPLOYMENT:
|
|
|
703
718
|
def healthdata_view(request):
|
|
704
719
|
workloads,servers_res = harvest_healthdata(request)
|
|
705
720
|
|
|
706
|
-
result =
|
|
721
|
+
result = OrderedDict()
|
|
707
722
|
for servername in WORKLOADNAMES:
|
|
708
723
|
if result in servers_res:
|
|
709
724
|
result[servername] = servers_res[servername][1]
|
|
@@ -713,17 +728,45 @@ elif WORKLOADS > 0 and not WORKLOAD_DEPLOYMENT:
|
|
|
713
728
|
populate_summary_data(result)
|
|
714
729
|
|
|
715
730
|
return JsonResponse(result)
|
|
716
|
-
|
|
731
|
+
elif WORKLOAD_DEPLOYMENT:
|
|
717
732
|
def healthdata_view(request):
|
|
718
733
|
workloads,servers_res = harvest_healthdata(request)
|
|
719
734
|
|
|
720
|
-
result =
|
|
735
|
+
result = OrderedDict()
|
|
721
736
|
for servername, serverdata in servers_res.items():
|
|
737
|
+
if serverdata[0] in OFFLINE_STATUSCODE_LIST:
|
|
738
|
+
continue
|
|
722
739
|
result[servername] = serverdata[1]
|
|
723
740
|
|
|
724
741
|
populate_summary_data(result)
|
|
725
742
|
|
|
726
743
|
return JsonResponse(result)
|
|
744
|
+
else:
|
|
745
|
+
def healthdata_view(request):
|
|
746
|
+
workloads,servers_res = harvest_healthdata(request)
|
|
747
|
+
|
|
748
|
+
#get all workload names
|
|
749
|
+
workloadnames = [k for k in workloads.keys() if k != item_version ]
|
|
750
|
+
|
|
751
|
+
#find the name of the last available workload
|
|
752
|
+
workloadnames.sort(key=lambda d:int(d[8:]))
|
|
753
|
+
last_workloadname = next((name for name in reversed(workloadnames) if servers_res.get(name,[503,"Workload is Offline"])[0] not in OFFLINE_STATUSCODE_LSIT ) ,None)
|
|
754
|
+
|
|
755
|
+
result = OrderedDict()
|
|
756
|
+
if last_workloadname:
|
|
757
|
+
#find the index of the last available workload
|
|
758
|
+
last_workloadindex = int(last_workloadname[8:])
|
|
759
|
+
|
|
760
|
+
#Return the healthdata of the workloads whose index is from 0 to last_workloadindex(include)
|
|
761
|
+
for i in range(last_workloadindex + 1):
|
|
762
|
+
servername = get_workloadname(i)
|
|
763
|
+
serverdata = servers_res.get(servername,[503,"Workload is offline"])
|
|
764
|
+
result[servername] = serverdata[1]
|
|
765
|
+
|
|
766
|
+
populate_summary_data(result)
|
|
767
|
+
|
|
768
|
+
return JsonResponse(result)
|
|
769
|
+
|
|
727
770
|
|
|
728
771
|
def workload_healthdata_view(request):
|
|
729
772
|
global secret
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|