Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87a5e40e3e | ||
|
|
bf7f831c42 | ||
|
|
f74a1a7076 | ||
|
|
6c9c0ffad2 | ||
|
|
4b1d75b1ba | ||
|
|
6f06f7d657 | ||
|
|
91c4928ec7 |
@@ -275,9 +275,9 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label for="survey-form-suggestions">
|
<label for="external_galleries">
|
||||||
Any Comments or Suggestions?
|
Any external galleries ?
|
||||||
<textarea id="survey-form-suggestions" maxlength="194"></textarea>
|
<textarea id="external_galleries" maxlength="194"></textarea>
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<button id="submit" type="submit" class="btn">Submit the form</button>
|
<button id="submit" type="submit" class="btn">Submit the form</button>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ from jinja2 import Environment, FileSystemLoader
|
|||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
from kubernetes import client, config
|
from kubernetes import client, config
|
||||||
|
|
||||||
#from django.template.loader import render_to_string
|
|
||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
import mimetypes
|
import mimetypes
|
||||||
@@ -22,130 +21,29 @@ def form(request):
|
|||||||
def handle_survey_form(request):
|
def handle_survey_form(request):
|
||||||
config.load_kube_config(config_file='/kubeconfig/config')
|
config.load_kube_config(config_file='/kubeconfig/config')
|
||||||
v1 = client.BatchV1Api()
|
v1 = client.BatchV1Api()
|
||||||
|
|
||||||
name = request.GET.get('name')
|
name = request.GET.get('name')
|
||||||
url = request.GET.get('url')
|
url = request.GET.get('url')
|
||||||
|
external_galleries = request.GET.get('external_galleries')
|
||||||
|
|
||||||
environment = Environment(loader=FileSystemLoader("django_code/stash_management/templates/"))
|
with open('django_code/stash_management/templates/template.stash-pornpics-dowloader.job.yml', 'r') as file:
|
||||||
template = environment.get_template("template.stash-pornpics-dowloader.job.yml")
|
#get the manifest in a variable template_manifest from the manifest file
|
||||||
pod_manifest_job = template.render(name=name, url=url)
|
template_manifest = yaml.safe_load(file)
|
||||||
|
|
||||||
api_response = v1.create_namespaced_job(body=pod_manifest_job)
|
#edit the container name
|
||||||
return HttpResponse(api_response)
|
template_manifest['metadata']['name'] ="stash-pornpics-dowloader"+name
|
||||||
|
template_manifest['spec']['template']['spec']['containers'][0]['name'] ="stash-pornpics-dowloader-"+name
|
||||||
|
|
||||||
# You can now process or store the data
|
#edit the command based on the input
|
||||||
#return HttpResponse(f"Received: {name}, {url}")
|
command=['bash', '/config/download.sh', '--http_proxy', 'http://gluetun-svc.gluetun.svc:8888', '--BASE_URL', url, '--pornstars', name,'--external_gallery', external_galleries]
|
||||||
#return HttpResponse(content)
|
template_manifest['spec']['template']['spec']['containers'][0]['command']=command
|
||||||
|
|
||||||
|
|
||||||
|
#execute based on the value
|
||||||
def scale_up(request,namespace_name,deploy_name):
|
api_response = v1.create_namespaced_job(body=template_manifest,namespace='stash')
|
||||||
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('<h1>Scaled up !</h1>')
|
|
||||||
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('<h1>Scaled down !</h1>')
|
|
||||||
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)
|
return HttpResponse(api_response)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user