lastview
This commit is contained in:
parent
a39d256d62
commit
3224e5ad61
1 changed files with 4 additions and 5 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
import json
|
import json
|
||||||
import base64
|
import base64
|
||||||
import requests
|
import requests
|
||||||
import traceback
|
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
from django.views.generic import TemplateView, View
|
from django.views.generic import TemplateView, View
|
||||||
|
|
||||||
|
|
@ -12,8 +11,8 @@ class ClusterGraphDataView(View):
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
repo_name = request.GET.get("repo", "boday_tf")
|
repo_name = request.GET.get("repo", "boday_tf")
|
||||||
# DIE RETTUNG: Nutzt das Docker-Host-Gateway, damit der K3s-Pod Consul auf dem Host erreicht!
|
# ENTERPRISE RESOLUTION: Nutzt wieder das native Docker-DNS im gemeinsamen Netzwerk!
|
||||||
consul_url = f"http://172.17.0{repo_name}"
|
consul_url = f"http://consul:8500/v1/kv/terraform/states/{repo_name}"
|
||||||
|
|
||||||
response = requests.get(consul_url, timeout=5)
|
response = requests.get(consul_url, timeout=5)
|
||||||
if response.status_code == 404:
|
if response.status_code == 404:
|
||||||
|
|
@ -30,7 +29,7 @@ class ClusterGraphDataView(View):
|
||||||
raw_value = consul_data.get("Value")
|
raw_value = consul_data.get("Value")
|
||||||
|
|
||||||
if not raw_value:
|
if not raw_value:
|
||||||
return JsonResponse({"name": f"Key '{repo_name}' geladen, aber Value ist leer.", "type": "Root", "children": []})
|
return JsonResponse({"name": f"Key '{repo_name}' leer.", "type": "Root", "children": []})
|
||||||
|
|
||||||
state_json = json.loads(base64.b64decode(raw_value).decode('utf-8'))
|
state_json = json.loads(base64.b64decode(raw_value).decode('utf-8'))
|
||||||
resources = state_json.get("resources", [])
|
resources = state_json.get("resources", [])
|
||||||
|
|
@ -67,7 +66,7 @@ class ClusterGraphDataView(View):
|
||||||
deployments[actual_name] = {"name": actual_name, "type": "Deployment"}
|
deployments[actual_name] = {"name": actual_name, "type": "Deployment"}
|
||||||
|
|
||||||
root_node = {
|
root_node = {
|
||||||
"name": f"Consul Storage: {repo_name}",
|
"name": f"Consul: {repo_name}",
|
||||||
"type": "Root",
|
"type": "Root",
|
||||||
"children": []
|
"children": []
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue