From 39e6a69a0843d03ff658fa78cf0cb79bf8116f48 Mon Sep 17 00:00:00 2001 From: Pierre Geeraert Date: Mon, 2 Jun 2025 10:58:21 +0100 Subject: [PATCH] fix the syntax error --- django_code/kubernetes_connection/apps.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/django_code/kubernetes_connection/apps.py b/django_code/kubernetes_connection/apps.py index 3b80b57..a04a900 100644 --- a/django_code/kubernetes_connection/apps.py +++ b/django_code/kubernetes_connection/apps.py @@ -111,15 +111,16 @@ def backup_job(request): #help with yaml import #https://github.com/kubernetes-client/python/issues/589 -def backup_job_yaml(request): +def backup_job_yaml(request,sync_target): config.load_kube_config(config_file='/code/kubeconfig') v1 = client.BatchV1Api() - with urllib.request.urlopen(https://gitea.tryton.geeraert.eu/pi-ux-ce/Backup_kube/raw/branch/main/Infrequent_access/pod.yaml") as manifest_url: + yaml_location = { + "synology" : "https://gitea.tryton.geeraert.eu/pi-ux-ce/Backup_kube/raw/branch/main/Infrequent_access/synology_pod.yaml", + "openmediavault":"https://gitea.tryton.geeraert.eu/pi-ux-ce/Backup_kube/raw/branch/main/Infrequent_access/openmediavault_pod.yaml" + } + print(yaml_location[sync_target]) + url_to_select=yaml_location[sync_target] + api_response = v1.create_namespaced_job(body=pod_manifest_job) -# with open('/code/pod.yaml') as : - job = yaml.safe_load(manifest_url) - v1.create_namespaced_job( - job['metadata']['namespace'], job, pretty=True -) - return HttpResponse(job['metadata']['namespace']) + return HttpResponse(api_response)