diff --git a/.gitignore b/.gitignore
index e7078d0..b84edbb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
*/__pycache__/*
+*/.idea
+venv/*
+*__pycache__*
diff --git a/django_code/dashboard/__pycache__/apps.cpython-312.pyc b/django_code/dashboard/__pycache__/apps.cpython-312.pyc
deleted file mode 100644
index 261f917..0000000
Binary files a/django_code/dashboard/__pycache__/apps.cpython-312.pyc and /dev/null differ
diff --git a/django_code/dashboard/__pycache__/apps.cpython-313.pyc b/django_code/dashboard/__pycache__/apps.cpython-313.pyc
deleted file mode 100644
index 42ce838..0000000
Binary files a/django_code/dashboard/__pycache__/apps.cpython-313.pyc and /dev/null differ
diff --git a/django_code/dashboard/templates/stash_form.html b/django_code/dashboard/templates/stash_form.html
new file mode 100644
index 0000000..346ad6e
--- /dev/null
+++ b/django_code/dashboard/templates/stash_form.html
@@ -0,0 +1,288 @@
+
+
+
+
+
+ Scaled up
+
+
+
+
+
+
+
+
+
+
+
+
Stash Form
+
Download form
+
+
+
+
+
+
diff --git a/django_code/django_code/__pycache__/__init__.cpython-312.pyc b/django_code/django_code/__pycache__/__init__.cpython-312.pyc
deleted file mode 100644
index 879bacb..0000000
Binary files a/django_code/django_code/__pycache__/__init__.cpython-312.pyc and /dev/null differ
diff --git a/django_code/django_code/__pycache__/__init__.cpython-313.pyc b/django_code/django_code/__pycache__/__init__.cpython-313.pyc
deleted file mode 100644
index 6b4367d..0000000
Binary files a/django_code/django_code/__pycache__/__init__.cpython-313.pyc and /dev/null differ
diff --git a/django_code/django_code/__pycache__/__init__.cpython-39.pyc b/django_code/django_code/__pycache__/__init__.cpython-39.pyc
deleted file mode 100644
index c7e95fe..0000000
Binary files a/django_code/django_code/__pycache__/__init__.cpython-39.pyc and /dev/null differ
diff --git a/django_code/django_code/__pycache__/settings.cpython-312.pyc b/django_code/django_code/__pycache__/settings.cpython-312.pyc
deleted file mode 100644
index 81c0f23..0000000
Binary files a/django_code/django_code/__pycache__/settings.cpython-312.pyc and /dev/null differ
diff --git a/django_code/django_code/__pycache__/settings.cpython-313.pyc b/django_code/django_code/__pycache__/settings.cpython-313.pyc
deleted file mode 100644
index d0fb2d9..0000000
Binary files a/django_code/django_code/__pycache__/settings.cpython-313.pyc and /dev/null differ
diff --git a/django_code/django_code/__pycache__/settings.cpython-39.pyc b/django_code/django_code/__pycache__/settings.cpython-39.pyc
deleted file mode 100644
index 23dd015..0000000
Binary files a/django_code/django_code/__pycache__/settings.cpython-39.pyc and /dev/null differ
diff --git a/django_code/django_code/__pycache__/urls.cpython-312.pyc b/django_code/django_code/__pycache__/urls.cpython-312.pyc
deleted file mode 100644
index 6448597..0000000
Binary files a/django_code/django_code/__pycache__/urls.cpython-312.pyc and /dev/null differ
diff --git a/django_code/django_code/__pycache__/urls.cpython-313.pyc b/django_code/django_code/__pycache__/urls.cpython-313.pyc
deleted file mode 100644
index 8d67fdf..0000000
Binary files a/django_code/django_code/__pycache__/urls.cpython-313.pyc and /dev/null differ
diff --git a/django_code/django_code/__pycache__/wsgi.cpython-312.pyc b/django_code/django_code/__pycache__/wsgi.cpython-312.pyc
deleted file mode 100644
index afc81f3..0000000
Binary files a/django_code/django_code/__pycache__/wsgi.cpython-312.pyc and /dev/null differ
diff --git a/django_code/django_code/__pycache__/wsgi.cpython-313.pyc b/django_code/django_code/__pycache__/wsgi.cpython-313.pyc
deleted file mode 100644
index 4c20920..0000000
Binary files a/django_code/django_code/__pycache__/wsgi.cpython-313.pyc and /dev/null differ
diff --git a/django_code/django_code/urls.py b/django_code/django_code/urls.py
index 86a8407..dea389e 100644
--- a/django_code/django_code/urls.py
+++ b/django_code/django_code/urls.py
@@ -23,6 +23,7 @@ from onenote import apps as onenote
from dashboard import apps as dashboardapp
from dashboard import views as dashboardview
from kubernetes_connection import apps as kubernetes_connection
+from stash_management import apps as stashapp
urlpatterns = [
# path('admin/', admin.site.urls),
@@ -57,6 +58,12 @@ urlpatterns = [
path('kubernetes_connection/scale_up//', kubernetes_connection.scale_up),
path('kubernetes_connection/scale_down//', kubernetes_connection.scale_down),
+################## kubernetes_connection#####
+ path('stash/hello/', stashapp.hello),
+ path('stash/form/', stashapp.form),
+ path('stash/submit-form/', stashapp.handle_survey_form, name='submit_form'),
+
+
# path('bookstack/', docker_connection.apps.hello),
# path('test/', docker_connection.apps.http_call_test),
# path('proxmox/', docker_connection.apps.proxmox),
diff --git a/django_code/docker_connection/__pycache__/__init__.cpython-312.pyc b/django_code/docker_connection/__pycache__/__init__.cpython-312.pyc
deleted file mode 100644
index 7e5ff04..0000000
Binary files a/django_code/docker_connection/__pycache__/__init__.cpython-312.pyc and /dev/null differ
diff --git a/django_code/docker_connection/__pycache__/apps.cpython-312.pyc b/django_code/docker_connection/__pycache__/apps.cpython-312.pyc
deleted file mode 100644
index ff91d2b..0000000
Binary files a/django_code/docker_connection/__pycache__/apps.cpython-312.pyc and /dev/null differ
diff --git a/django_code/docker_connection/__pycache__/views.cpython-312.pyc b/django_code/docker_connection/__pycache__/views.cpython-312.pyc
deleted file mode 100644
index e6faa35..0000000
Binary files a/django_code/docker_connection/__pycache__/views.cpython-312.pyc and /dev/null differ
diff --git a/django_code/kubernetes_connection/__pycache__/__init__.cpython-312.pyc b/django_code/kubernetes_connection/__pycache__/__init__.cpython-312.pyc
deleted file mode 100644
index 856820b..0000000
Binary files a/django_code/kubernetes_connection/__pycache__/__init__.cpython-312.pyc and /dev/null differ
diff --git a/django_code/kubernetes_connection/__pycache__/__init__.cpython-313.pyc b/django_code/kubernetes_connection/__pycache__/__init__.cpython-313.pyc
deleted file mode 100644
index 8744286..0000000
Binary files a/django_code/kubernetes_connection/__pycache__/__init__.cpython-313.pyc and /dev/null differ
diff --git a/django_code/kubernetes_connection/__pycache__/apps.cpython-312.pyc b/django_code/kubernetes_connection/__pycache__/apps.cpython-312.pyc
deleted file mode 100644
index 10af6a1..0000000
Binary files a/django_code/kubernetes_connection/__pycache__/apps.cpython-312.pyc and /dev/null differ
diff --git a/django_code/kubernetes_connection/__pycache__/apps.cpython-313.pyc b/django_code/kubernetes_connection/__pycache__/apps.cpython-313.pyc
deleted file mode 100644
index d61e4d8..0000000
Binary files a/django_code/kubernetes_connection/__pycache__/apps.cpython-313.pyc and /dev/null differ
diff --git a/django_code/kubernetes_connection/__pycache__/views.cpython-312.pyc b/django_code/kubernetes_connection/__pycache__/views.cpython-312.pyc
deleted file mode 100644
index e6faa35..0000000
Binary files a/django_code/kubernetes_connection/__pycache__/views.cpython-312.pyc and /dev/null differ
diff --git a/django_code/onenote/__pycache__/apps.cpython-312.pyc b/django_code/onenote/__pycache__/apps.cpython-312.pyc
deleted file mode 100644
index c91f9a3..0000000
Binary files a/django_code/onenote/__pycache__/apps.cpython-312.pyc and /dev/null differ
diff --git a/django_code/onenote/__pycache__/apps.cpython-313.pyc b/django_code/onenote/__pycache__/apps.cpython-313.pyc
deleted file mode 100644
index 0d0b2e5..0000000
Binary files a/django_code/onenote/__pycache__/apps.cpython-313.pyc and /dev/null differ
diff --git a/django_code/paperless_django/__pycache__/apps.cpython-312.pyc b/django_code/paperless_django/__pycache__/apps.cpython-312.pyc
deleted file mode 100644
index 350d9eb..0000000
Binary files a/django_code/paperless_django/__pycache__/apps.cpython-312.pyc and /dev/null differ
diff --git a/django_code/paperless_django/__pycache__/apps.cpython-313.pyc b/django_code/paperless_django/__pycache__/apps.cpython-313.pyc
deleted file mode 100644
index 7b4a4b4..0000000
Binary files a/django_code/paperless_django/__pycache__/apps.cpython-313.pyc and /dev/null differ
diff --git a/django_code/random_simpsons/__pycache__/__init__.cpython-312.pyc b/django_code/random_simpsons/__pycache__/__init__.cpython-312.pyc
deleted file mode 100644
index 0cd810f..0000000
Binary files a/django_code/random_simpsons/__pycache__/__init__.cpython-312.pyc and /dev/null differ
diff --git a/django_code/random_simpsons/__pycache__/__init__.cpython-313.pyc b/django_code/random_simpsons/__pycache__/__init__.cpython-313.pyc
deleted file mode 100644
index f0d463e..0000000
Binary files a/django_code/random_simpsons/__pycache__/__init__.cpython-313.pyc and /dev/null differ
diff --git a/django_code/random_simpsons/__pycache__/apps.cpython-312.pyc b/django_code/random_simpsons/__pycache__/apps.cpython-312.pyc
deleted file mode 100644
index f93589b..0000000
Binary files a/django_code/random_simpsons/__pycache__/apps.cpython-312.pyc and /dev/null differ
diff --git a/django_code/random_simpsons/__pycache__/apps.cpython-313.pyc b/django_code/random_simpsons/__pycache__/apps.cpython-313.pyc
deleted file mode 100644
index 2af6b28..0000000
Binary files a/django_code/random_simpsons/__pycache__/apps.cpython-313.pyc and /dev/null differ
diff --git a/django_code/random_simpsons/__pycache__/views.cpython-312.pyc b/django_code/random_simpsons/__pycache__/views.cpython-312.pyc
deleted file mode 100644
index e6faa35..0000000
Binary files a/django_code/random_simpsons/__pycache__/views.cpython-312.pyc and /dev/null differ
diff --git a/django_code/stash_management/__init__.py b/django_code/stash_management/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/django_code/stash_management/admin.py b/django_code/stash_management/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/django_code/stash_management/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/django_code/stash_management/apps.py b/django_code/stash_management/apps.py
new file mode 100644
index 0000000..6fa4669
--- /dev/null
+++ b/django_code/stash_management/apps.py
@@ -0,0 +1,151 @@
+from django.apps import AppConfig
+from django.http import HttpResponse
+from django.shortcuts import render
+from django.shortcuts import redirect
+from jinja2 import Environment, FileSystemLoader
+from django.core.files import File
+from kubernetes import client, config
+
+#from django.template.loader import render_to_string
+import time
+import random
+import mimetypes
+import ruamel.yaml
+import yaml
+import urllib.request
+
+def hello(request):
+ return HttpResponse('Hello stash! ')
+def form(request):
+ return render(request, 'stash_form.html',{})
+
+def handle_survey_form(request):
+ config.load_kube_config(config_file='/kubeconfig/config')
+ v1 = client.BatchV1Api()
+
+ name = request.GET.get('name')
+ url = request.GET.get('url')
+
+ environment = Environment(loader=FileSystemLoader("django_code/stash_management/templates/"))
+ template = environment.get_template("template.stash-pornpics-dowloader.job.yml")
+ pod_manifest_job = template.render(name=name, url=url)
+
+ api_response = v1.create_namespaced_job(body=pod_manifest_job)
+ return HttpResponse(api_response)
+
+ # You can now process or store the data
+ #return HttpResponse(f"Received: {name}, {url}")
+ #return HttpResponse(content)
+
+
+
+def scale_up(request,namespace_name,deploy_name):
+ config.load_kube_config(config_file='/kubeconfig/config')
+ api = client.AppsV1Api()
+ deployment = api.read_namespaced_deployment(name=deploy_name, namespace=namespace_name)
+ deployment.spec.replicas = 1
+ resp = api.patch_namespaced_deployment(
+ name=deploy_name, namespace=namespace_name, body=deployment);
+ #return HttpResponse('Scaled up ! ')
+ return render(request, 'start.html', {'namespace':namespace_name,'deployment': deploy_name, 'url': 'https://namespace.com'})
+
+
+def scale_down(request,namespace_name,deploy_name):
+ config.load_kube_config(config_file='/kubeconfig/config')
+ api = client.AppsV1Api()
+ deployment = api.read_namespaced_deployment(name=deploy_name, namespace=namespace_name)
+ deployment.spec.replicas = 0
+ resp = api.patch_namespaced_deployment(
+ name=deploy_name, namespace=namespace_name, body=deployment);
+ #return HttpResponse('Scaled down ! ')
+ return render(request, 'shutdown.html',
+ {'namespace': namespace_name, 'deployment': deploy_name, 'url': 'https://namespace.com'})
+
+def nodes(request):
+ config.load_kube_config(config_file='/code/kubeconfig')
+ v1 = client.CoreV1Api()
+# v1.list_node()
+ pod_manifest = {
+ 'apiVersion': 'v1',
+ 'kind': 'Pod',
+ 'metadata': {
+ 'labels': {
+ 'bot': 'current-bot'
+ },
+ 'name': 'podname',
+ 'namespace': 'echo-server'
+
+ },
+ 'spec': {
+
+ 'containers': [{
+ 'image': 'gitea.tryton.geeraert.eu/pi-ux-ce/bitwarden_cli:1.0.1',
+# 'pod-running-timeout': '5m0s',
+ 'name': 'testpython',
+ 'env': [
+ {'name': 'env_variable', 'value': 'env_value'},
+ ]
+ }],
+ 'restartPolicy': 'Always',
+# 'serviceAccountName': 'bots-service-account'
+ }
+ }
+
+# print(f'POD MANIFEST:\n{pod_manifest}')
+ api_response = v1.create_namespaced_pod(body=pod_manifest,namespace='echo-server')
+ return HttpResponse(api_response)
+
+def backup_job(request):
+ config.load_kube_config(config_file='/code/kubeconfig')
+ v1 = client.CoreV1Api()
+ #v1 = client.BatchV1Api()
+# v1.list_node()
+ pod_manifest_job = {
+ 'apiVersion': 'batch/v1',
+ 'kind': 'Job',
+ 'metadata': {
+ 'name': 'bitwarden-backup-django',
+ 'namespace': 'bwbackup'
+
+ },
+ 'spec': {
+ 'template': {
+ 'spec': {
+
+ 'containers': [{
+ 'image': 'gitea.tryton.geeraert.eu/pi-ux-ce/bitwarden_cli:1.0.1',
+ 'name': 'testpython',
+ 'command': ['/bin/sh -c /config/export_bitwarden.sh'],
+ 'env': [
+ {'name': 'env_variable', 'value': 'env_value'},
+ ],
+ 'volumeMounts': [
+ {'name': 'scripts', 'configMap': [{'name':'bitwarden-export-scripts'},]},
+ ]
+ }],
+ 'restartPolicy': 'Always',
+ }
+ }
+ }
+ }
+
+ api_response = v1.create_namespaced_job(body=pod_manifest_job)
+ return HttpResponse(api_response)
+
+
+#help with yaml import
+#https://github.com/kubernetes-client/python/issues/589
+
+def backup_job_yaml(request,sync_target):
+ config.load_kube_config(config_file='/code/kubeconfig')
+ v1 = client.BatchV1Api()
+
+ 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)
+
+ return HttpResponse(api_response)
diff --git a/django_code/stash_management/migrations/__init__.py b/django_code/stash_management/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/django_code/stash_management/models.py b/django_code/stash_management/models.py
new file mode 100644
index 0000000..71a8362
--- /dev/null
+++ b/django_code/stash_management/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/django_code/stash_management/templates/my_template.html b/django_code/stash_management/templates/my_template.html
new file mode 100644
index 0000000..9cec98d
--- /dev/null
+++ b/django_code/stash_management/templates/my_template.html
@@ -0,0 +1 @@
+Hello template!
diff --git a/django_code/stash_management/templates/template.stash-pornpics-dowloader.job.yml b/django_code/stash_management/templates/template.stash-pornpics-dowloader.job.yml
new file mode 100644
index 0000000..df95487
--- /dev/null
+++ b/django_code/stash_management/templates/template.stash-pornpics-dowloader.job.yml
@@ -0,0 +1,37 @@
+apiVersion: batch/v1
+kind: Job
+metadata:
+ name: stash-pornpics-dowloader-{{ name }}
+ namespace: stash
+spec:
+ template:
+ spec:
+ containers:
+ - name: stash-pornpics-dowloader-{{ name }}
+ image: bash
+ imagePullPolicy: Always
+ volumeMounts:
+ - mountPath: /config
+ name: scripts
+ - mountPath: /data
+ mountPropagation: None
+ name: data-pvc
+ command:
+ - bash
+ - /config/download.sh
+ - --http_proxy
+ - "http://gluetun-svc.gluetun.svc:8888"
+ - --BASE_URL
+ - "{{ url }}"
+ - --pornstars
+ - "{{ name }}"
+ restartPolicy: Never
+ volumes:
+ - configMap:
+ defaultMode: 0744
+ name: pornpic-dowloader
+ name: scripts
+ - name: data-pvc
+ persistentVolumeClaim:
+ claimName: data-pvc
+ backoffLimit: 4
\ No newline at end of file
diff --git a/django_code/stash_management/tests.py b/django_code/stash_management/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/django_code/stash_management/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/django_code/stash_management/views.py b/django_code/stash_management/views.py
new file mode 100644
index 0000000..dcf84f6
--- /dev/null
+++ b/django_code/stash_management/views.py
@@ -0,0 +1,8 @@
+from django.shortcuts import render
+
+# Create your views here.
+from django.http import HttpResponse
+from django.shortcuts import render
+
+def hello(request):
+ return HttpResponse('Hello Django! ')
diff --git a/requirements.txt b/requirements.txt
index 3923335..1501bd2 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,4 +5,5 @@ docker
kubernetes
ruamel.yaml
pyyaml
-django-bootstrap-v5
\ No newline at end of file
+django-bootstrap-v5
+jinja2
\ No newline at end of file