Compare commits
84
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87a5e40e3e | ||
|
|
bf7f831c42 | ||
|
|
f74a1a7076 | ||
|
|
6c9c0ffad2 | ||
|
|
4b1d75b1ba | ||
|
|
6f06f7d657 | ||
|
|
91c4928ec7 | ||
|
|
9ce785014d | ||
|
|
e139dcea35 | ||
|
|
adb18644ee | ||
|
|
bccd344aa7 | ||
|
|
3315fbdb4f | ||
|
|
5bbe4c5c61 | ||
|
|
2366d0c2a8 | ||
|
|
a4d9f63568 | ||
|
|
496f2b3bfb | ||
|
|
cb7a010fb6 | ||
|
|
5b5093708d | ||
|
|
975252656f | ||
|
|
0b7da7a5c9 | ||
|
|
4e70e2d28d | ||
|
|
705db14521 | ||
|
|
5b5d62e4fa | ||
|
|
9afe770202 | ||
|
|
6a52ed2f66 | ||
|
|
279d59e376 | ||
|
|
a6d9f29f1a | ||
|
|
bb36edfca5 | ||
|
|
f451b8ff3b | ||
|
|
b837e1a952 | ||
|
|
aa1501214d | ||
|
|
246eff86a6 | ||
|
|
e2ea76c6c9 | ||
|
|
ad4fe6df26 | ||
|
|
43a000a9c1 | ||
|
|
32a0e65a68 | ||
|
|
b80be01a52 | ||
|
|
daa935bbef | ||
|
|
cb49bfba58 | ||
|
|
60af5e87ce | ||
|
|
aad687f630 | ||
|
|
6b30f381df | ||
|
|
5b03dc35b4 | ||
|
|
f9732160f0 | ||
|
|
8a84a8d42f | ||
|
|
39e6a69a08 | ||
|
|
c9d6d77931 | ||
|
|
2f30234edd | ||
|
|
cdd1dd0245 | ||
|
|
df9d6c93cc | ||
|
|
80a75a445e | ||
|
|
385d42d0be | ||
|
|
2514603962 | ||
|
|
d071b135e7 | ||
|
|
433185df3e | ||
|
|
ccad16f38c | ||
|
|
c7e5afc750 | ||
|
|
80877663a9 | ||
|
|
ceaf0f0ef6 | ||
|
|
d6135402c2 | ||
|
|
fa365f956e | ||
|
|
82ed5d12e1 | ||
|
|
a9b6c92864 | ||
|
|
cc2d9e1b14 | ||
|
|
3dd8fdb7ca | ||
|
|
db20b291e3 | ||
|
|
096a71a7fc | ||
|
|
83d346b632 | ||
|
|
202797aed5 | ||
|
|
0cb583de09 | ||
|
|
bf19250116 | ||
|
|
e59e7b439d | ||
|
|
83e2ba5be2 | ||
|
|
7cc8891533 | ||
|
|
8a0cd24d69 | ||
|
|
1cb49c3127 | ||
|
|
a4a704305a | ||
|
|
f21877877b | ||
|
|
ff48f982f5 | ||
|
|
f661ac26c8 | ||
|
|
1100043b2f | ||
|
|
1d031088a9 | ||
|
|
056104a553 | ||
|
|
87185595e2 |
@@ -0,0 +1,58 @@
|
|||||||
|
name: Gitea Actions Demo
|
||||||
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
issue_comment:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Explore-Gitea-Actions:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||||
|
- name: List files in the repository
|
||||||
|
run: |
|
||||||
|
ls ${{ gitea.workspace }}
|
||||||
|
|
||||||
|
- name: Cache pip
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: /root/.cache/pip
|
||||||
|
key: pip
|
||||||
|
restore-keys: pip
|
||||||
|
|
||||||
|
- name: inject cache into docker
|
||||||
|
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
|
||||||
|
with:
|
||||||
|
cache-source: /root/.cache/pip
|
||||||
|
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to gitea
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: gitea.tryton.geeraert.eu
|
||||||
|
username: ${{ secrets.USERNAME_GITEA }}
|
||||||
|
password: ${{ secrets.PASSWORD_GITEA }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
#build-contexts: pip_cache=${{steps.vars.outputs.pip-dir}}
|
||||||
|
tags: gitea.tryton.geeraert.eu/pi-ux-ce/django-python:latest
|
||||||
|
cache-from: type=registry,ref=gitea.tryton.geeraert.eu/pi-ux-ce/django-python:buildcache
|
||||||
|
cache-to: type=registry,ref=gitea.tryton.geeraert.eu/pi-ux-ce/django-python:buildcache,mode=max
|
||||||
|
|
||||||
|
- name: drop the pod to force pulling the new image
|
||||||
|
uses: actions-hub/kubectl@master
|
||||||
|
env:
|
||||||
|
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
|
||||||
|
with:
|
||||||
|
args: rollout restart deployment django -n django
|
||||||
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
name: Gitea Actions Demo
|
||||||
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "*"
|
||||||
|
paths:
|
||||||
|
- '*.yaml'
|
||||||
|
tags-ignore:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Explore-Gitea-Actions:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||||
|
- name: List files in the repository
|
||||||
|
run: |
|
||||||
|
ls ${{ gitea.workspace }}
|
||||||
|
|
||||||
|
- name: Perform kubectl tasks
|
||||||
|
uses: actions-hub/kubectl@master
|
||||||
|
env:
|
||||||
|
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
|
||||||
|
with:
|
||||||
|
args: apply -f .
|
||||||
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
*/__pycache__/*
|
||||||
|
*/.idea
|
||||||
|
venv/*
|
||||||
|
*__pycache__*
|
||||||
@@ -20,22 +20,37 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: django-python
|
- name: django-python
|
||||||
image: localhost:31795/django-python
|
image: gitea.tryton.geeraert.eu/pi-ux-ce/django-python:latest
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8000
|
- containerPort: 8000
|
||||||
name: webserver-port
|
name: webserver-port
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: django-python-code
|
## - name: django-python-code
|
||||||
mountPath: /code
|
# mountPath: /code
|
||||||
|
- name: servarr-data
|
||||||
|
mountPath: /data
|
||||||
|
readOnly: true
|
||||||
|
- name: secret-kubeconfig
|
||||||
|
mountPath: /kubeconfig
|
||||||
|
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: 100m
|
cpu: 100m
|
||||||
memory: 50Mi
|
memory: 200Mi
|
||||||
volumes:
|
volumes:
|
||||||
- name: django-python-code
|
- name: django-python-code
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: django-python-code
|
claimName: django-python-code
|
||||||
|
- name: servarr-data
|
||||||
|
hostPath:
|
||||||
|
path: /data
|
||||||
|
- name: secret-kubeconfig
|
||||||
|
secret:
|
||||||
|
defaultMode: 420
|
||||||
|
secretName: kubeconfig
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
=======
|
=======
|
||||||
# Django_kube
|
# Django_kube
|
||||||
|
test
|
||||||
|
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.shortcuts import render
|
||||||
|
from django.shortcuts import redirect
|
||||||
|
import time
|
||||||
|
import random
|
||||||
|
|
||||||
|
def hello(request):
|
||||||
|
return HttpResponse('<h1>Hello dashboard h1>')
|
||||||
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{% block title %}{% endblock %}</title>
|
||||||
|
{% load bootstrap5 %}
|
||||||
|
{% bootstrap_css %}
|
||||||
|
{% bootstrap_javascript %}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1 class="display-1">Welcome to my website!</h1>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="list-group">
|
||||||
|
{% if thislist %}
|
||||||
|
<ul>
|
||||||
|
{% for question in thislist %}
|
||||||
|
<a href="#" class="list-group-item">{{ question }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<p>No polls are available.</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>My Website</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Welcome to my website!</h1>
|
||||||
|
{% if thislist %}
|
||||||
|
<ul>
|
||||||
|
{% for question in thislist %}
|
||||||
|
<h1>{{ question }}</h1>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<p>No polls are available.</p>
|
||||||
|
{% endif %}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
<!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 down</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">
|
||||||
|
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Varela Round', sans-serif;
|
||||||
|
}
|
||||||
|
.modal-confirm {
|
||||||
|
color: #636363;
|
||||||
|
width: 325px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.modal-confirm .modal-content {
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
.modal-confirm .modal-header {
|
||||||
|
border-bottom: none;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.modal-confirm h4 {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 26px;
|
||||||
|
margin: 30px 0 -15px;
|
||||||
|
}
|
||||||
|
.modal-confirm .form-control, .modal-confirm .btn {
|
||||||
|
min-height: 40px;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
.modal-confirm .close {
|
||||||
|
position: absolute;
|
||||||
|
top: -5px;
|
||||||
|
right: -5px;
|
||||||
|
}
|
||||||
|
.modal-confirm .modal-footer {
|
||||||
|
border: none;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
.modal-confirm .icon-box {
|
||||||
|
color: #fff;
|
||||||
|
position: absolute;
|
||||||
|
margin: 0 auto;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: -70px;
|
||||||
|
width: 105px;
|
||||||
|
height: 105px;
|
||||||
|
border-radius: 50%;
|
||||||
|
z-index: 9;
|
||||||
|
/*background: #82ce34;*/
|
||||||
|
background: #a80505;
|
||||||
|
padding: 15px;
|
||||||
|
text-align: center;
|
||||||
|
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
.modal-confirm .icon-box i {
|
||||||
|
font-size: 58px;
|
||||||
|
position: relative;
|
||||||
|
top: 0px;
|
||||||
|
}
|
||||||
|
.modal-confirm .icon-box:hover,.modal-confirm .icon-box:focus {
|
||||||
|
background: #6fb32b;
|
||||||
|
/*background: #a80505;*/
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.modal-confirm.modal-dialog {
|
||||||
|
margin-top: 80px;
|
||||||
|
}
|
||||||
|
.modal-confirm .btn {
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 4px;
|
||||||
|
/*background: #82ce34;*/
|
||||||
|
background: #a80505;
|
||||||
|
text-decoration: none;
|
||||||
|
transition: all 0.4s;
|
||||||
|
line-height: normal;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
.modal-confirm .btn:hover, .modal-confirm .btn:focus {
|
||||||
|
background: #800404;
|
||||||
|
/*background: #a80505;*/
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.trigger-btn {
|
||||||
|
display: inline-block;
|
||||||
|
margin: 100px auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="text-center">
|
||||||
|
<!-- Button HTML (to Trigger Modal) -->
|
||||||
|
<!--<a href="#myModal" class="trigger-btn" data-toggle="modal">Click to Open Confirm Modal</a> -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Modal HTML -->
|
||||||
|
<!--<div id="myModal" class="modal fade">-->
|
||||||
|
<div class="modal-dialog modal-confirm">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<div class="icon-box" onclick="window.location='/kubernetes_connection/scale_up/{{namespace}}/{{deployment}}';">
|
||||||
|
<!--<i class="material-icons"></i>-->
|
||||||
|
<i class="material-icons">×</i>
|
||||||
|
</div>
|
||||||
|
<h4 class="modal-title w-100">Too bad!</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p class="text-center">{{ deployment }} deployment from namespace {{ namespace }} is now scaled down.</p>
|
||||||
|
<p class="text-center">Current URL {{ url }}.</p>
|
||||||
|
<p class="text-center">base URL {{ baseurl }}.</p>
|
||||||
|
</div>
|
||||||
|
<div href={{ url }} class="modal-footer">
|
||||||
|
<!--<button href={{ url }} class="btn btn-success btn-block" data-dismiss="modal">Redirect</button>-->
|
||||||
|
<a href="https://google.fr" class="btn btn-success btn-block" data-dismiss="modal">Redirect</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
<!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">
|
||||||
|
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Varela Round', sans-serif;
|
||||||
|
}
|
||||||
|
.modal-confirm {
|
||||||
|
color: #636363;
|
||||||
|
width: 325px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.modal-confirm .modal-content {
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
.modal-confirm .modal-header {
|
||||||
|
border-bottom: none;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.modal-confirm h4 {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 26px;
|
||||||
|
margin: 30px 0 -15px;
|
||||||
|
}
|
||||||
|
.modal-confirm .form-control, .modal-confirm .btn {
|
||||||
|
min-height: 40px;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
.modal-confirm .close {
|
||||||
|
position: absolute;
|
||||||
|
top: -5px;
|
||||||
|
right: -5px;
|
||||||
|
}
|
||||||
|
.modal-confirm .modal-footer {
|
||||||
|
border: none;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
.modal-confirm .icon-box {
|
||||||
|
color: #fff;
|
||||||
|
position: absolute;
|
||||||
|
margin: 0 auto;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: -70px;
|
||||||
|
width: 95px;
|
||||||
|
height: 95px;
|
||||||
|
border-radius: 50%;
|
||||||
|
z-index: 9;
|
||||||
|
background: #82ce34;
|
||||||
|
padding: 15px;
|
||||||
|
text-align: center;
|
||||||
|
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
.modal-confirm .icon-box i {
|
||||||
|
font-size: 58px;
|
||||||
|
position: relative;
|
||||||
|
top: 3px;
|
||||||
|
}
|
||||||
|
.modal-confirm .icon-box:hover,.modal-confirm .icon-box:focus {
|
||||||
|
/*background: #6fb32b;*/
|
||||||
|
background: #a80505;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.modal-confirm.modal-dialog {
|
||||||
|
margin-top: 80px;
|
||||||
|
}
|
||||||
|
.modal-confirm .btn {
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 4px;
|
||||||
|
background: #82ce34;
|
||||||
|
text-decoration: none;
|
||||||
|
transition: all 0.4s;
|
||||||
|
line-height: normal;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
.modal-confirm .btn:hover, .modal-confirm .btn:focus {
|
||||||
|
background: #6fb32b;
|
||||||
|
/*background: #a80505;*/
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.trigger-btn {
|
||||||
|
display: inline-block;
|
||||||
|
margin: 100px auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="text-center">
|
||||||
|
<!-- Button HTML (to Trigger Modal) -->
|
||||||
|
<!--<a href="#myModal" class="trigger-btn" data-toggle="modal">Click to Open Confirm Modal</a> -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Modal HTML -->
|
||||||
|
<!--<div id="myModal" class="modal fade">-->
|
||||||
|
<div class="modal-dialog modal-confirm">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<div class="icon-box" onclick="window.location='/kubernetes_connection/scale_down/{{namespace}}/{{deployment}}';">
|
||||||
|
<!--<i class="material-icons"></i>-->
|
||||||
|
<i class="material-icons"></i>
|
||||||
|
</div>
|
||||||
|
<h4 class="modal-title w-100">Awesome!</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p class="text-center">{{ deployment }} deployment from namespace {{ namespace }} is now scaled up.</p>
|
||||||
|
<p class="text-center">Current URL {{ url }}.</p>
|
||||||
|
<p class="text-center">base URL {{ baseurl }}.</p>
|
||||||
|
</div>
|
||||||
|
<div href={{ url }} class="modal-footer">
|
||||||
|
<!--<button href={{ url }} class="btn btn-success btn-block" data-dismiss="modal">Redirect</button>-->
|
||||||
|
|
||||||
|
<a href="https://google.fr" class="btn btn-success btn-block" data-dismiss="modal">Redirect</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -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="external_galleries">
|
||||||
|
Any external galleries ?
|
||||||
|
<textarea id="external_galleries" maxlength="194"></textarea>
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
<button id="submit" type="submit" class="btn">Submit the form</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
|
||||||
|
def home(request):
|
||||||
|
thislist = ["apple", "banana", "cherry"]
|
||||||
|
return render(request, 'home.html',{'thislist': thislist})
|
||||||
|
|
||||||
|
def about(request):
|
||||||
|
thislist = ["apple", "banana", "cherry"]
|
||||||
|
return render(request, 'about.html',{'thislist': thislist})
|
||||||
|
|
||||||
|
def success(request):
|
||||||
|
return render(request, 'start.html',{'deployment': 'django','url':'https://google.com'})
|
||||||
|
|
||||||
|
def scale_up(request,namespace_name,deploy_name):
|
||||||
|
baseurl = "{0}://{1}{2}".format(request.scheme, request.get_host(), request.path)
|
||||||
|
return render(request, 'start.html', {'namespace':namespace_name,'deployment': deploy_name, 'url': 'https://namespace.com','baseurl': baseurl})
|
||||||
|
|
||||||
|
def scale_down(request,namespace_name,deploy_name):
|
||||||
|
baseurl = "{0}://{1}{2}".format(request.scheme, request.get_host(), request.path)
|
||||||
|
return render(request, 'shutdown.html', {'namespace':namespace_name,'deployment': deploy_name, 'url': 'https://namespace.com','baseurl': baseurl})
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -25,7 +25,7 @@ SECRET_KEY = 'django-insecure-71%)_#e#o9-dl2o^6mfud-*rw+4+8vy-nd*bzeier&(34ap-p9
|
|||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['reverse.tryton.geeraert.eu','192.168.4.100','django.tryton.geeraert.eu']
|
ALLOWED_HOSTS = ['reverse.tryton.geeraert.eu','192.168.4.100','django.tryton.geeraert.eu','localhost']
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
@@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'bootstrap5',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
@@ -54,7 +55,8 @@ ROOT_URLCONF = 'django_code.urls'
|
|||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [],
|
#'DIRS': ["/code/django_code/templates","/code/django_code/dashboard/templates/"],
|
||||||
|
'DIRS': [BASE_DIR / "templates","django_code/dashboard/templates/"],
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'context_processors': [
|
'context_processors': [
|
||||||
@@ -121,3 +123,4 @@ STATIC_URL = 'static/'
|
|||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
#
|
||||||
|
|||||||
@@ -18,16 +18,56 @@ from django.contrib import admin
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
#from docker_connection import views, apps
|
#from docker_connection import views, apps
|
||||||
from random_simpsons import apps as random_simpsons
|
from random_simpsons import apps as random_simpsons
|
||||||
|
from paperless_django import apps as paperless_django
|
||||||
|
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 = [
|
urlpatterns = [
|
||||||
# path('admin/', admin.site.urls),
|
# path('admin/', admin.site.urls),
|
||||||
path('hello/', random_simpsons.hello),
|
|
||||||
# path('bookstack/', docker_connection.apps.hello),
|
|
||||||
# path('test/', docker_connection.apps.http_call_test),
|
|
||||||
# path('proxmox/', docker_connection.apps.proxmox),
|
|
||||||
# path('simpsons/', random_simpsons.hello),
|
|
||||||
path('simpsons/', random_simpsons.simpsons),
|
|
||||||
|
|
||||||
|
################### Simpsons ###################
|
||||||
|
path('hello/', random_simpsons.hello),
|
||||||
|
path('simpsons/', random_simpsons.simpsons),
|
||||||
|
path('download_file/', random_simpsons.download_file),
|
||||||
|
|
||||||
|
################### paperless ###################
|
||||||
|
path('paperless/hello/', paperless_django.hello),
|
||||||
|
# path('simpsons/', random_simpsons.simpsons),
|
||||||
|
|
||||||
|
################### onenote ###################
|
||||||
|
path('onenote/hello/', onenote.hello),
|
||||||
|
|
||||||
|
################### onenote ###################
|
||||||
|
path('dashboard/hello/', dashboardapp.hello),
|
||||||
|
path('dashboard/view/about', dashboardview.about),
|
||||||
|
path('dashboard/view/home', dashboardview.home),
|
||||||
|
path('dashboard/view/success', dashboardview.success),
|
||||||
|
path('dashboard/scale_up/<str:namespace_name>/<str:deploy_name>', dashboardview.scale_up),
|
||||||
|
path('dashboard/scale_down/<str:namespace_name>/<str:deploy_name>', dashboardview.scale_down),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
################## kubernetes_connection#####
|
||||||
|
path('kubernetes_connection/hello/', kubernetes_connection.hello),
|
||||||
|
path('kubernetes_connection/nodes/', kubernetes_connection.nodes),
|
||||||
|
path('kubernetes_connection/backup_job/', kubernetes_connection.backup_job),
|
||||||
|
path('kubernetes_connection/backup_job_yaml/', kubernetes_connection.backup_job_yaml),
|
||||||
|
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),
|
||||||
|
# path('simpsons/', random_simpsons.hello),
|
||||||
# path('docker/<str:action>/<str:id_docker>', docker_connection.apps.docker_call),
|
# path('docker/<str:action>/<str:id_docker>', docker_connection.apps.docker_call),
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,129 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.shortcuts import render
|
||||||
|
from django.shortcuts import redirect
|
||||||
|
|
||||||
|
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 k8s!</h1>')
|
||||||
|
|
||||||
|
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 @@
|
|||||||
|
<h1>Hello template!</h1>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.shortcuts import render
|
||||||
|
from django.shortcuts import redirect
|
||||||
|
#from django.template.loader import render_to_string
|
||||||
|
from django.template import loader
|
||||||
|
#import time
|
||||||
|
#import random
|
||||||
|
|
||||||
|
def hello(request):
|
||||||
|
# htmlContent = '
|
||||||
|
#<!DOCTYPE html>
|
||||||
|
#<html lang="en">
|
||||||
|
#<body>
|
||||||
|
#<strong>Hello World from const</strong>
|
||||||
|
#</body>
|
||||||
|
#</html>
|
||||||
|
#'
|
||||||
|
# response = "coucou"
|
||||||
|
# context = {'response': HttpResponse(response)}
|
||||||
|
# return HttpResponse(htmlContent)
|
||||||
|
# return HttpResponse('<h1>Hello onenote! <h1>')
|
||||||
|
# return render(request, 'hello.html', context)
|
||||||
|
|
||||||
|
template = loader.get_template('onenote/hello.html')
|
||||||
|
# template = loader.get_template('onenote/Roser.mht')
|
||||||
|
return HttpResponse(template.render())
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<body>
|
||||||
|
<strong>Hello World</strong>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.shortcuts import render
|
||||||
|
from django.shortcuts import redirect
|
||||||
|
import time
|
||||||
|
import random
|
||||||
|
|
||||||
|
def hello(request):
|
||||||
|
return HttpResponse('<h1>Hello paperless! <h1>')
|
||||||
|
|
||||||
|
def redirect_authenticated(request):
|
||||||
|
|
||||||
|
final_url = "https://paperless.tryton.geeraert.eu/"
|
||||||
|
print(final_url)
|
||||||
|
|
||||||
|
return redirect(str(final_url))
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,33 +2,111 @@ from django.apps import AppConfig
|
|||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
|
|
||||||
|
from django.core.files import File
|
||||||
|
|
||||||
|
#from django.template.loader import render_to_string
|
||||||
import time
|
import time
|
||||||
|
import psycopg2
|
||||||
import random
|
import random
|
||||||
|
import mimetypes
|
||||||
|
|
||||||
|
def DB_generation(host_in,port_in,user_in,password_in,db_in):
|
||||||
|
#db = pymysql.connect(host=host_in, port=port_in, user=user_in, passwd=password_in,db=db_in)
|
||||||
|
db = psycopg2.connect(host=host_in, port=port_in, user=user_in, password=password_in,database=db_in)
|
||||||
|
return db
|
||||||
|
|
||||||
|
def Launch_sql_query(sql,db):
|
||||||
|
#sql query with 1 object returned
|
||||||
|
cursor = db.cursor()
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Execute the SQL command
|
||||||
|
cursor.execute(sql)
|
||||||
|
# Fetch all the rows in a list of lists.
|
||||||
|
results = cursor.fetchall()
|
||||||
|
for row in results:
|
||||||
|
return row[0]
|
||||||
|
|
||||||
|
except:
|
||||||
|
print ("Error: unable to fetch data from the query:")
|
||||||
|
print (sql)
|
||||||
|
print("---")
|
||||||
|
cursor.close()
|
||||||
|
|
||||||
|
|
||||||
def hello(request):
|
def hello(request):
|
||||||
return HttpResponse('<h1>Hello Simpsons!</h1>')
|
return HttpResponse('<h1>Hello Simpsons!</h1>')
|
||||||
|
#<h1>href="{{ STATIC_URL }}/files/somefile</h1>)
|
||||||
|
|
||||||
|
|
||||||
|
def download_file(request):
|
||||||
|
# fill these variables with real values
|
||||||
|
fl_path = '/data/download/sonarr'
|
||||||
|
filename = 'The.Boys.2019.S04E05.2160p.HDR10Plus.WEBRip.6CH.x265.HEVC-PSA.mkv'
|
||||||
|
|
||||||
|
# fl = open(fl_path, 'r')
|
||||||
|
# mime_type, _ = mimetypes.guess_type(fl_path)
|
||||||
|
|
||||||
|
# response = HttpResponse(fl, content_type=mime_type)
|
||||||
|
# response['Content-Disposition'] = "attachment; filename=%s" % filename
|
||||||
|
some_file = open('/data/kubernetes/Backup/nextcloud/notes/2024-07-28/Course.md', "r")
|
||||||
|
django_file = File(some_file)
|
||||||
|
return HttpResponse("<h1>Hello download!</h1><h1><a href='{{ MEDIA_URL }}{{ django_file.relative_path }}'>{{ django_file.name }}</a></h1><h1>bye download!</h1>")
|
||||||
|
# return response
|
||||||
|
|
||||||
|
def download_mo(request,file):
|
||||||
|
path_to_file = os.path.realpath(file)
|
||||||
|
response = FileResponse(open(path_to_file, 'rb'))
|
||||||
|
file_name = file[5:]
|
||||||
|
response['Content-Disposition'] = 'inline; filename=' + file_name
|
||||||
|
return response
|
||||||
|
|
||||||
|
#def template(request):
|
||||||
|
# rendered = render_to_string("my_template.html", {"foo": "bar"})
|
||||||
|
#return HttpResponse('<h1>Hello !</h1>')
|
||||||
|
|
||||||
def simpsons(request):
|
def simpsons(request):
|
||||||
simpsons_url = "https://www1.kisscartoon.online/episode/the-simpsons-season-";
|
#dev settings
|
||||||
number_of_seasons = 35
|
#generated_db = DB_generation("192.168.88.50",32345, "django_username", "Suffrage-Moneybags-Illusion7","django")
|
||||||
seasons_maximum_number = [13,22,24,22,22,25,25,25,25,23,22,21,22,22,22,21,22,22,20,21,23,22,22,22,22,22,22,22,21,23,22,22,22,22,18]
|
#production settings
|
||||||
|
generated_db = DB_generation("django-db-svc",5432, "django_username", "Suffrage-Moneybags-Illusion7","django")
|
||||||
|
|
||||||
#print(simpsons_url)
|
cursor = generated_db.cursor()
|
||||||
|
|
||||||
random_seasons = random.randint(1, number_of_seasons)
|
#get max number of season
|
||||||
print("random seasons: "+ str(random_seasons))
|
maximum_number_of_seasons = Launch_sql_query("SELECT COUNT(DISTINCT season) as result FROM episodes;",generated_db)
|
||||||
|
|
||||||
#random_seasons-1 because list start at index 0
|
boolean_restart = True;
|
||||||
print("maximum of episode for this season: "+str(seasons_maximum_number[random_seasons-1]))
|
while (boolean_restart):
|
||||||
|
|
||||||
random_episode = random.randint(1, seasons_maximum_number[random_seasons-1])
|
random_seasons = random.randint(1, maximum_number_of_seasons)
|
||||||
|
print("random season: " + str(random_seasons))
|
||||||
print("random episode: "+ str(random_episode))
|
|
||||||
|
|
||||||
|
|
||||||
final_url = simpsons_url+str(random_seasons)+ "-episode-"+str(random_episode)#
|
#get max number of epiosde for this season
|
||||||
print(final_url)
|
maximum_number_of_episodes_query = "SELECT COUNT(url) as result FROM episodes WHERE season = " + str(random_seasons) + ";"
|
||||||
|
|
||||||
# return HttpResponse(str(final_url))
|
maximum_number_of_episodes = Launch_sql_query(maximum_number_of_episodes_query,generated_db)
|
||||||
# time.sleep(10)
|
|
||||||
return redirect(str(final_url))
|
random_episode = random.randint(1, maximum_number_of_episodes)
|
||||||
|
print("random episode: " + str(random_episode))
|
||||||
|
|
||||||
|
#check if the episode was already seen
|
||||||
|
check_if_already_seen_query = "select seen from episodes where season="+ str(random_seasons) +" and episode = "+ str(random_episode) +";"
|
||||||
|
if not Launch_sql_query(check_if_already_seen_query, generated_db):
|
||||||
|
boolean_restart = False
|
||||||
|
else:
|
||||||
|
print("episode "+str(random_episode)+" from season "+str(random_seasons)+" already seen")
|
||||||
|
|
||||||
|
url_from_episode_season_query = "select url from episodes where season="+ str(random_seasons) +" and episode = "+ str(random_episode) +";"
|
||||||
|
generated_url = Launch_sql_query(url_from_episode_season_query,generated_db)
|
||||||
|
|
||||||
|
#mark as seen
|
||||||
|
url_from_episode_season_query = "update episodes set seen = True where season=" + str(random_seasons) + " and episode = " + str(random_episode) + ";"
|
||||||
|
Launch_sql_query(url_from_episode_season_query, generated_db)
|
||||||
|
|
||||||
|
generated_db.commit()
|
||||||
|
generated_db.close()
|
||||||
|
#return HttpResponse(str(generated_url))
|
||||||
|
return redirect(str(generated_url))
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<h1>Hello template!</h1>
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
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')
|
||||||
|
external_galleries = request.GET.get('external_galleries')
|
||||||
|
|
||||||
|
with open('django_code/stash_management/templates/template.stash-pornpics-dowloader.job.yml', 'r') as file:
|
||||||
|
#get the manifest in a variable template_manifest from the manifest file
|
||||||
|
template_manifest = yaml.safe_load(file)
|
||||||
|
|
||||||
|
#edit the container name
|
||||||
|
template_manifest['metadata']['name'] ="stash-pornpics-dowloader"+name
|
||||||
|
template_manifest['spec']['template']['spec']['containers'][0]['name'] ="stash-pornpics-dowloader-"+name
|
||||||
|
|
||||||
|
#edit the command based on the input
|
||||||
|
command=['bash', '/config/download.sh', '--http_proxy', 'http://gluetun-svc.gluetun.svc:8888', '--BASE_URL', url, '--pornstars', name,'--external_gallery', external_galleries]
|
||||||
|
template_manifest['spec']['template']['spec']['containers'][0]['command']=command
|
||||||
|
|
||||||
|
|
||||||
|
#execute based on the value
|
||||||
|
api_response = v1.create_namespaced_job(body=template_manifest,namespace='stash')
|
||||||
|
|
||||||
|
return HttpResponse(api_response)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<body>
|
||||||
|
<strong>Hello World template</strong>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+3
-1
@@ -5,7 +5,9 @@ WORKDIR /code/
|
|||||||
COPY requirements.txt ./
|
COPY requirements.txt ./
|
||||||
COPY django_code ./
|
COPY django_code ./
|
||||||
|
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN --mount=type=cache,target=/root/.cache/pip pip install --upgrade pip
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/pip pip install --no-cache-dir -r requirements.txt
|
||||||
COPY . .
|
COPY . .
|
||||||
|
RUN python django_code/manage.py migrate
|
||||||
|
|
||||||
CMD [ "python","django_code/manage.py","runserver","0.0.0.0:8000" ]
|
CMD [ "python","django_code/manage.py","runserver","0.0.0.0:8000" ]
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,16 +0,0 @@
|
|||||||
"""
|
|
||||||
ASGI config for Django_reverse_proxy project.
|
|
||||||
|
|
||||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from django.core.asgi import get_asgi_application
|
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Django_reverse_proxy.settings')
|
|
||||||
|
|
||||||
application = get_asgi_application()
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
"""
|
|
||||||
Django settings for Django_reverse_proxy project.
|
|
||||||
|
|
||||||
Generated by 'django-admin startproject' using Django 4.2.5.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/4.2/topics/settings/
|
|
||||||
|
|
||||||
For the full list of settings and their values, see
|
|
||||||
https://docs.djangoproject.com/en/4.2/ref/settings/
|
|
||||||
"""
|
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
||||||
|
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
|
||||||
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
|
||||||
SECRET_KEY = 'django-insecure-cdzm0zn@rzk#ix9mj9q3-ov%r^)-$u#met(_48s(x2we41+0!o'
|
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
|
||||||
DEBUG = True
|
|
||||||
|
|
||||||
ALLOWED_HOSTS = []
|
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
|
||||||
'django.contrib.admin',
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
]
|
|
||||||
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'Django_reverse_proxy.urls'
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [],
|
|
||||||
'APP_DIRS': True,
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
WSGI_APPLICATION = 'Django_reverse_proxy.wsgi.application'
|
|
||||||
|
|
||||||
|
|
||||||
# Database
|
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
|
||||||
'NAME': BASE_DIR / 'db.sqlite3',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
|
||||||
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# Internationalization
|
|
||||||
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
|
||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
|
||||||
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
|
||||||
|
|
||||||
STATIC_URL = 'static/'
|
|
||||||
|
|
||||||
# Default primary key field type
|
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
"""
|
|
||||||
URL configuration for Django_reverse_proxy project.
|
|
||||||
|
|
||||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
|
||||||
https://docs.djangoproject.com/en/4.2/topics/http/urls/
|
|
||||||
Examples:
|
|
||||||
Function views
|
|
||||||
1. Add an import: from my_app import views
|
|
||||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
|
||||||
Class-based views
|
|
||||||
1. Add an import: from other_app.views import Home
|
|
||||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
|
||||||
Including another URLconf
|
|
||||||
1. Import the include() function: from django.urls import include, path
|
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
|
||||||
"""
|
|
||||||
from django.contrib import admin
|
|
||||||
from django.urls import path
|
|
||||||
#from .. import frontend
|
|
||||||
|
|
||||||
urlpatterns = [
|
|
||||||
path('admin/', admin.site.urls),
|
|
||||||
# path('/', frontend.site.urls),
|
|
||||||
]
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
"""
|
|
||||||
WSGI config for Django_reverse_proxy project.
|
|
||||||
|
|
||||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Django_reverse_proxy.settings')
|
|
||||||
|
|
||||||
application = get_wsgi_application()
|
|
||||||
Binary file not shown.
@@ -1,6 +0,0 @@
|
|||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class FrontendConfig(AppConfig):
|
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
|
||||||
name = 'frontend'
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Django's command-line utility for administrative tasks."""
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
"""Run administrative tasks."""
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Django_reverse_proxy.settings')
|
|
||||||
try:
|
|
||||||
from django.core.management import execute_from_command_line
|
|
||||||
except ImportError as exc:
|
|
||||||
raise ImportError(
|
|
||||||
"Couldn't import Django. Are you sure it's installed and "
|
|
||||||
"available on your PYTHONPATH environment variable? Did you "
|
|
||||||
"forget to activate a virtual environment?"
|
|
||||||
) from exc
|
|
||||||
execute_from_command_line(sys.argv)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,40 +0,0 @@
|
|||||||
from django.apps import AppConfig
|
|
||||||
from django.http import HttpResponse
|
|
||||||
from django.shortcuts import render
|
|
||||||
import requests
|
|
||||||
from proxmoxer import ProxmoxAPI
|
|
||||||
import docker
|
|
||||||
|
|
||||||
class BackofficeConfig(AppConfig):
|
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
|
||||||
name = 'backoffice'
|
|
||||||
|
|
||||||
def hello(request):
|
|
||||||
return HttpResponse('<h1>Start bookstack!</h1>')
|
|
||||||
|
|
||||||
def http_call_test(request):
|
|
||||||
url = 'http://portainer.zeus.geeraert.eu/api/auth/'
|
|
||||||
myobj = {'Username': 'admin','Password':'Xtm78*CX3mJ54g'}
|
|
||||||
|
|
||||||
x = requests.post(url, json = myobj)
|
|
||||||
|
|
||||||
print(x.text)
|
|
||||||
return HttpResponse(x.text)
|
|
||||||
|
|
||||||
def proxmox(request):
|
|
||||||
proxmox = ProxmoxAPI("proxmox.zeus.geeraert.eu", user="root@pam", password="dinner_sl@v3", verify_ssl=False)
|
|
||||||
return HttpResponse(proxmox)
|
|
||||||
|
|
||||||
def docker_call(request,action,id_docker):
|
|
||||||
print(action)
|
|
||||||
print(id_docker)
|
|
||||||
client = docker.from_env()
|
|
||||||
if action == "start":
|
|
||||||
print("nous allons start")
|
|
||||||
client.containers.get(id_docker).start()
|
|
||||||
if action == "stop":
|
|
||||||
print("nous allons stop")
|
|
||||||
client.containers.get(id_docker).stop()
|
|
||||||
|
|
||||||
return HttpResponse(client.containers.get(id_docker).status)
|
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,16 +0,0 @@
|
|||||||
"""
|
|
||||||
ASGI config for eboutique project.
|
|
||||||
|
|
||||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from django.core.asgi import get_asgi_application
|
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'eboutique.settings')
|
|
||||||
|
|
||||||
application = get_asgi_application()
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
"""
|
|
||||||
Django settings for eboutique project.
|
|
||||||
|
|
||||||
Generated by 'django-admin startproject' using Django 4.2.5.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/4.2/topics/settings/
|
|
||||||
|
|
||||||
For the full list of settings and their values, see
|
|
||||||
https://docs.djangoproject.com/en/4.2/ref/settings/
|
|
||||||
"""
|
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
||||||
|
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
|
||||||
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
|
||||||
SECRET_KEY = 'django-insecure-g--8(!mq=_qs3)iipm%vs8bu0j8upir2i*&*gw&0)v26%lq=2!'
|
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
|
||||||
DEBUG = True
|
|
||||||
|
|
||||||
ALLOWED_HOSTS = []
|
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
|
||||||
'django.contrib.admin',
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'django.contrib.sessions',
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'backoffice',
|
|
||||||
]
|
|
||||||
|
|
||||||
MIDDLEWARE = [
|
|
||||||
'django.middleware.security.SecurityMiddleware',
|
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
|
||||||
'django.middleware.common.CommonMiddleware',
|
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
|
||||||
]
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'eboutique.urls'
|
|
||||||
|
|
||||||
TEMPLATES = [
|
|
||||||
{
|
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
||||||
'DIRS': [],
|
|
||||||
'APP_DIRS': True,
|
|
||||||
'OPTIONS': {
|
|
||||||
'context_processors': [
|
|
||||||
'django.template.context_processors.debug',
|
|
||||||
'django.template.context_processors.request',
|
|
||||||
'django.contrib.auth.context_processors.auth',
|
|
||||||
'django.contrib.messages.context_processors.messages',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
WSGI_APPLICATION = 'eboutique.wsgi.application'
|
|
||||||
|
|
||||||
|
|
||||||
# Database
|
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
|
||||||
'NAME': BASE_DIR / 'db.sqlite3',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
|
||||||
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# Internationalization
|
|
||||||
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
|
||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
|
||||||
|
|
||||||
TIME_ZONE = 'UTC'
|
|
||||||
|
|
||||||
USE_I18N = True
|
|
||||||
|
|
||||||
USE_TZ = True
|
|
||||||
|
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
|
||||||
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
|
||||||
|
|
||||||
STATIC_URL = 'static/'
|
|
||||||
|
|
||||||
# Default primary key field type
|
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
"""
|
|
||||||
URL configuration for Django_reverse_proxy project.
|
|
||||||
|
|
||||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
|
||||||
https://docs.djangoproject.com/en/4.2/topics/http/urls/
|
|
||||||
Examples:
|
|
||||||
Function views
|
|
||||||
1. Add an import: from my_app import views
|
|
||||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
|
||||||
Class-based views
|
|
||||||
1. Add an import: from other_app.views import Home
|
|
||||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
|
||||||
Including another URLconf
|
|
||||||
1. Import the include() function: from django.urls import include, path
|
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
|
||||||
"""
|
|
||||||
from django.contrib import admin
|
|
||||||
from django.urls import path
|
|
||||||
from backoffice import views, apps
|
|
||||||
urlpatterns = [
|
|
||||||
path('admin/', admin.site.urls),
|
|
||||||
path('hello/', views.hello),
|
|
||||||
path('bookstack/', apps.hello),
|
|
||||||
path('test/', apps.http_call_test),
|
|
||||||
path('proxmox/', apps.proxmox),
|
|
||||||
path('docker/<str:action>/<str:id_docker>', apps.docker_call),
|
|
||||||
|
|
||||||
|
|
||||||
]
|
|
||||||
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
"""
|
|
||||||
WSGI config for eboutique project.
|
|
||||||
|
|
||||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'eboutique.settings')
|
|
||||||
|
|
||||||
application = get_wsgi_application()
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Django's command-line utility for administrative tasks."""
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
"""Run administrative tasks."""
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'eboutique.settings')
|
|
||||||
try:
|
|
||||||
from django.core.management import execute_from_command_line
|
|
||||||
except ImportError as exc:
|
|
||||||
raise ImportError(
|
|
||||||
"Couldn't import Django. Are you sure it's installed and "
|
|
||||||
"available on your PYTHONPATH environment variable? Did you "
|
|
||||||
"forget to activate a virtual environment?"
|
|
||||||
) from exc
|
|
||||||
execute_from_command_line(sys.argv)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
@@ -1,4 +1,10 @@
|
|||||||
django
|
django
|
||||||
|
psycopg2
|
||||||
requests
|
requests
|
||||||
proxmoxer
|
proxmoxer
|
||||||
docker
|
docker
|
||||||
|
kubernetes
|
||||||
|
ruamel.yaml
|
||||||
|
pyyaml
|
||||||
|
django-bootstrap-v5
|
||||||
|
jinja2
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
# Register your models here.
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
from django.apps import AppConfig
|
|
||||||
from django.http import HttpResponse
|
|
||||||
from django.shortcuts import render
|
|
||||||
import requests
|
|
||||||
from proxmoxer import ProxmoxAPI
|
|
||||||
import docker
|
|
||||||
|
|
||||||
class BackofficeConfig(AppConfig):
|
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
|
||||||
name = 'backoffice'
|
|
||||||
|
|
||||||
def hello(request):
|
|
||||||
return HttpResponse('<h1>Start bookstack!</h1>')
|
|
||||||
|
|
||||||
def http_call_test(request):
|
|
||||||
url = 'http://portainer.zeus.geeraert.eu/api/auth/'
|
|
||||||
myobj = {'Username': 'admin','Password':'Xtm78*CX3mJ54g'}
|
|
||||||
|
|
||||||
x = requests.post(url, json = myobj)
|
|
||||||
|
|
||||||
print(x.text)
|
|
||||||
return HttpResponse(x.text)
|
|
||||||
|
|
||||||
def proxmox(request):
|
|
||||||
proxmox = ProxmoxAPI("proxmox.zeus.geeraert.eu", user="root@pam", password="dinner_sl@v3", verify_ssl=False)
|
|
||||||
return HttpResponse(proxmox)
|
|
||||||
|
|
||||||
def docker_call(request,action,id_docker):
|
|
||||||
print(action)
|
|
||||||
print(id_docker)
|
|
||||||
client = docker.from_env()
|
|
||||||
if action == "start":
|
|
||||||
print("nous allons start")
|
|
||||||
client.containers.get(id_docker).start()
|
|
||||||
if action == "stop":
|
|
||||||
print("nous allons stop")
|
|
||||||
client.containers.get(id_docker).stop()
|
|
||||||
|
|
||||||
return HttpResponse(client.containers.get(id_docker).status)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
|
|
||||||
# Create your models here.
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
"""Django's command-line utility for administrative tasks."""
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
"""Run administrative tasks."""
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'reverse_proxy.settings')
|
|
||||||
try:
|
|
||||||
from django.core.management import execute_from_command_line
|
|
||||||
except ImportError as exc:
|
|
||||||
raise ImportError(
|
|
||||||
"Couldn't import Django. Are you sure it's installed and "
|
|
||||||
"available on your PYTHONPATH environment variable? Did you "
|
|
||||||
"forget to activate a virtual environment?"
|
|
||||||
) from exc
|
|
||||||
execute_from_command_line(sys.argv)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,16 +0,0 @@
|
|||||||
"""
|
|
||||||
ASGI config for reverse_proxy project.
|
|
||||||
|
|
||||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
|
||||||
|
|
||||||
For more information on this file, see
|
|
||||||
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from django.core.asgi import get_asgi_application
|
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'reverse_proxy.settings')
|
|
||||||
|
|
||||||
application = get_asgi_application()
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user