adding new form #4
@@ -1 +1,4 @@
|
||||
*/__pycache__/*
|
||||
*/.idea
|
||||
venv/*
|
||||
*__pycache__*
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,288 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title>Scaled up</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
|
||||
<style>
|
||||
@charset "UTF-8";
|
||||
.m-b-xs {
|
||||
margin-bottom: 2%;
|
||||
}
|
||||
|
||||
.m-b-md {
|
||||
margin-bottom: 10%;
|
||||
}
|
||||
|
||||
.m-t-xs {
|
||||
margin-top: 2%;
|
||||
}
|
||||
|
||||
.m-t-sm {
|
||||
margin-top: 5%;
|
||||
}
|
||||
|
||||
* {
|
||||
outline: 0 !important;
|
||||
}
|
||||
|
||||
body {
|
||||
padding: 2% 0;
|
||||
background-color: #37404a;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family: "Roboto", sans-serif;
|
||||
font-size: 2.2em;
|
||||
font-weight: 300;
|
||||
color: #85ffc7;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
p {
|
||||
font-family: "Roboto", sans-serif;
|
||||
font-size: 1.1em;
|
||||
font-weight: 300;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #fff;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: none;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#survey-form label,
|
||||
#survey-form .labels {
|
||||
display: block;
|
||||
margin-bottom: 2%;
|
||||
font-family: "Roboto", sans-serif;
|
||||
font-size: 1.1em;
|
||||
font-weight: 300;
|
||||
color: #fff;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
#survey-form input::-webkit-input-placeholder {
|
||||
color: transparent !important;
|
||||
}
|
||||
#survey-form input::-moz-placeholder {
|
||||
color: transparent !important;
|
||||
}
|
||||
#survey-form input:-ms-input-placeholder {
|
||||
color: transparent !important;
|
||||
}
|
||||
#survey-form input:-moz-placeholder {
|
||||
color: transparent !important;
|
||||
}
|
||||
#survey-form input,
|
||||
#survey-form select {
|
||||
display: block;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
outline: none;
|
||||
border: 2px solid #333;
|
||||
}
|
||||
#survey-form input {
|
||||
margin-top: 1.5%;
|
||||
padding: 0 0 5px 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
outline: none;
|
||||
border-bottom: 2px solid #fff;
|
||||
font-size: 1.1em;
|
||||
font-weight: 300;
|
||||
color: #85ffc7;
|
||||
}
|
||||
#survey-form input:focus {
|
||||
border-color: #85ffc7;
|
||||
}
|
||||
#survey-form [type=checkbox],
|
||||
#survey-form [type=radio] {
|
||||
display: inline-block;
|
||||
width: auto;
|
||||
margin: 0px 10px 0 0;
|
||||
}
|
||||
#survey-form [type=checkbox],
|
||||
#survey-form [type=radio] {
|
||||
display: inline-block;
|
||||
margin: 0 10px 0 0 !important;
|
||||
position: relative;
|
||||
top: 5px;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
-o-appearance: none;
|
||||
appearance: none;
|
||||
height: 23px;
|
||||
width: 23px;
|
||||
transition: all 0.15s ease-out 0s;
|
||||
background: #37404a;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
z-index: 1000;
|
||||
border: 1px solid #fff;
|
||||
}
|
||||
#survey-form [type=checkbox]:hover,
|
||||
#survey-form [type=radio]:hover {
|
||||
border-color: #85ffc7;
|
||||
}
|
||||
#survey-form [type=checkbox]:checked:before,
|
||||
#survey-form [type=radio]:checked:before {
|
||||
display: inline-block;
|
||||
height: 21px;
|
||||
width: 21px;
|
||||
position: relative;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
content: "";
|
||||
text-align: center;
|
||||
font-family: "Glyphicons Halflings";
|
||||
line-height: 20px;
|
||||
font-size: 15px;
|
||||
color: #85ffc7;
|
||||
}
|
||||
#survey-form [type=checkbox]:focus,
|
||||
#survey-form [type=radio]:focus {
|
||||
outline: none;
|
||||
border-color: #fff;
|
||||
}
|
||||
#survey-form [type=radio] {
|
||||
border-radius: 50%;
|
||||
}
|
||||
#survey-form [type=radio]:after {
|
||||
border-radius: 50%;
|
||||
}
|
||||
#survey-form [type=number] {
|
||||
width: 45px;
|
||||
}
|
||||
#survey-form [type=number]::-webkit-inner-spin-button, #survey-form [type=number]::-webkit-outer-spin-button {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
#survey-form select {
|
||||
height: 40px;
|
||||
padding-left: 5px;
|
||||
background-color: #37404a;
|
||||
border: 2px solid #fff;
|
||||
color: #85ffc7;
|
||||
}
|
||||
#survey-form select option {
|
||||
padding: 5px 10px;
|
||||
font-weight: 300;
|
||||
cursor: pointer;
|
||||
}
|
||||
#survey-form select option:hover {
|
||||
background-color: #85ffc7;
|
||||
}
|
||||
#survey-form textarea {
|
||||
resize: none;
|
||||
margin-top: 2%;
|
||||
padding: 10px 10px 0px 20px;
|
||||
width: 100%;
|
||||
height: 90px;
|
||||
color: #85ffc7;
|
||||
background-color: #37404a;
|
||||
border: 2px solid #fff;
|
||||
}
|
||||
#survey-form .btn {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
margin: 3% 0 0 0;
|
||||
height: 45px;
|
||||
text-transform: uppercase;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
border: 3px solid #85ffc7;
|
||||
border-radius: 0;
|
||||
font-weight: 500;
|
||||
font-size: 1.2em;
|
||||
color: #85ffc7;
|
||||
text-align: center;
|
||||
background: none;
|
||||
transition: color 0.25s ease;
|
||||
}
|
||||
#survey-form .btn:after {
|
||||
position: absolute;
|
||||
content: "";
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 0;
|
||||
height: 100%;
|
||||
background-color: #85ffc7;
|
||||
transform-origin: left;
|
||||
transition: width 0.5s ease;
|
||||
z-index: -1;
|
||||
}
|
||||
#survey-form .btn:hover {
|
||||
color: #37404a;
|
||||
}
|
||||
#survey-form .btn:hover:after {
|
||||
width: 100%;
|
||||
}
|
||||
#survey-form fieldset {
|
||||
margin: 5% 0 0 0;
|
||||
}
|
||||
|
||||
.copyright {
|
||||
text-align: center;
|
||||
font-size: 10px;
|
||||
color: #fff;
|
||||
}
|
||||
.copyright i {
|
||||
color: #ef5350;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 600px) {
|
||||
body {
|
||||
padding: 8% 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<main id="main" class="container">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-lg-offset-3 col-lg-6">
|
||||
<div class="m-b-md text-center">
|
||||
<h1 id="title">Stash Form</h1>
|
||||
<p id="description" class="description" class="text-center">Download form</p>
|
||||
</div>
|
||||
<form method="GET" action="/stash/submit-form/" id="survey-form" name="survey-form">
|
||||
|
||||
<fieldset>
|
||||
<label for="name" id="name-label">
|
||||
Name *
|
||||
<input class="" type="text" id="name" name="name" placeholder="Enter your name (required)" required />
|
||||
</label>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<label for="url" id="url-label">
|
||||
URL *
|
||||
<input class="" type="url" id="url" name="url" placeholder="Enter the URL (required)" required />
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<label for="survey-form-suggestions">
|
||||
Any Comments or Suggestions?
|
||||
<textarea id="survey-form-suggestions" maxlength="194"></textarea>
|
||||
</label>
|
||||
</fieldset>
|
||||
<button id="submit" type="submit" class="btn">Submit the form</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</html>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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/<str:namespace_name>/<str:deploy_name>', kubernetes_connection.scale_up),
|
||||
path('kubernetes_connection/scale_down/<str:namespace_name>/<str:deploy_name>', 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),
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@@ -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('<h1>Hello stash!</h1>')
|
||||
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('<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)
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
@@ -0,0 +1 @@
|
||||
<h1>Hello template!</h1>
|
||||
@@ -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
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -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('<h1>Hello Django!</h1>')
|
||||
+2
-1
@@ -5,4 +5,5 @@ docker
|
||||
kubernetes
|
||||
ruamel.yaml
|
||||
pyyaml
|
||||
django-bootstrap-v5
|
||||
django-bootstrap-v5
|
||||
jinja2
|
||||
Reference in New Issue
Block a user