Compare commits
353
Commits
view
..
b5c3aa1bdb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5c3aa1bdb | ||
|
|
623bc9b74e | ||
|
|
6a6b0a0167 | ||
|
|
ad9c6c7a2a | ||
|
|
25b602a3b8 | ||
|
|
ed70f03a83 | ||
|
|
e76fb6684c | ||
|
|
2454d77ce8 | ||
|
|
5432647293 | ||
|
|
14d2e869bb | ||
|
|
ce9072124d | ||
|
|
f78ffcc595 | ||
|
|
57d2559ad3 | ||
|
|
024736c887 | ||
|
|
73f57871b4 | ||
|
|
cf0c355416 | ||
|
|
54c53d4510 | ||
|
|
5e247e831c | ||
|
|
ecaa988b5f | ||
|
|
73c89d8d93 | ||
|
|
1a41a01dfa | ||
|
|
5d26a4dd05 | ||
|
|
956e7fc1d0 | ||
|
|
73101d8cb9 | ||
|
|
78cc6cbad3 | ||
|
|
ec5eadac06 | ||
|
|
f22a33ad1a | ||
|
|
f28a9096f7 | ||
|
|
0216a9f1e1 | ||
|
|
bb642c781a | ||
|
|
0af676ec39 | ||
|
|
e93f00321e | ||
|
|
565a381977 | ||
|
|
914e1c691f | ||
|
|
e153be4b58 | ||
|
|
6cacd1a2cf | ||
|
|
eecdb55ba0 | ||
|
|
4de2cbf1bc | ||
|
|
aff4debd79 | ||
|
|
022ad01ace | ||
|
|
cda89ea243 | ||
|
|
aa0939be6d | ||
|
|
e74b659b45 | ||
|
|
f522b69a68 | ||
|
|
ef7b47b0c5 | ||
|
|
3d8fc1d848 | ||
|
|
5820be065c | ||
|
|
5ee60c8324 | ||
|
|
4918d968b7 | ||
|
|
75e172c7c0 | ||
|
|
9ad042b371 | ||
|
|
ed240d3cd0 | ||
|
|
2da9e9390d | ||
|
|
47bf1d40f9 | ||
|
|
256cc8cd71 | ||
|
|
51769fb08a | ||
|
|
555b222d6b | ||
|
|
cf26fa90d3 | ||
|
|
0cce30b7d2 | ||
|
|
200fea731c | ||
|
|
0eca15a19b | ||
|
|
fbe38faf59 | ||
|
|
0015e105f9 | ||
|
|
3dc8cce37a | ||
|
|
090eeccf8c | ||
|
|
17a7e173fe | ||
|
|
8d52c43e68 | ||
|
|
3eb7fd44e5 | ||
|
|
8c09ab3c6e | ||
|
|
19665ea0b7 | ||
|
|
7d4a1897f7 | ||
|
|
72ab577431 | ||
|
|
535617594f | ||
|
|
1230cac914 | ||
|
|
a3d5c16484 | ||
|
|
29ea329ed5 | ||
|
|
d719af498c | ||
|
|
b118391dc6 | ||
|
|
17d2f3544c | ||
|
|
25ba693bbd | ||
|
|
e5406b6549 | ||
|
|
5fa8ad286f | ||
|
|
d3061eddaf | ||
|
|
883e028cae | ||
|
|
2f4b93d11c | ||
|
|
57d7e8feee | ||
|
|
dd3b0b7731 | ||
|
|
c86301c9b2 | ||
|
|
3079df9072 | ||
|
|
1c04605dc7 | ||
|
|
2b8a4ed46f | ||
|
|
622f2c8758 | ||
|
|
4e6637aba9 | ||
|
|
c6784759cd | ||
|
|
55f27433f9 | ||
|
|
2dd02f0632 | ||
|
|
5d4bc9e93b | ||
|
|
ccb69a43d2 | ||
|
|
36755ccfb0 | ||
|
|
27dff192f2 | ||
|
|
e9dad6bfe5 | ||
|
|
69d161c19b | ||
|
|
103dcc919e | ||
|
|
3eea2ea4a2 | ||
|
|
d0a948e93f | ||
|
|
2a3c71f939 | ||
|
|
8caa778ee0 | ||
|
|
5521b70e46 | ||
|
|
c8d784ae2b | ||
|
|
910170b594 | ||
|
|
4dee3442b0 | ||
|
|
b38f2a8b2f | ||
|
|
1e8afcbc44 | ||
|
|
9e2b51de60 | ||
|
|
eb0f467aad | ||
|
|
da4b86f4d3 | ||
|
|
b5ef38bc0d | ||
|
|
c5b7e9dcde | ||
|
|
b611d41e8a | ||
|
|
c3ba43b0fa | ||
|
|
dc0e006e0f | ||
|
|
0b66858969 | ||
|
|
16c8fba623 | ||
|
|
852fccd95c | ||
|
|
316d07db61 | ||
|
|
bf99f618f6 | ||
|
|
534f0cb7cb | ||
|
|
974f6820d4 | ||
|
|
6ccf910e29 | ||
|
|
aaf1ced21c | ||
|
|
d05a3e2dc6 | ||
|
|
8be8b44584 | ||
|
|
4a028c04c9 | ||
|
|
1f1d7ab75d | ||
|
|
e0e5d9e290 | ||
|
|
181eb67501 | ||
|
|
8af976c528 | ||
|
|
beba1f16b4 | ||
|
|
76d0cbdb8d | ||
|
|
6ff0bb31d3 | ||
|
|
e78825b99f | ||
|
|
33a9d6fec7 | ||
|
|
b01145e6bd | ||
|
|
06024c82c1 | ||
|
|
ce4a4838f1 | ||
|
|
f80cfbeba7 | ||
|
|
61e5966083 | ||
|
|
f49a606693 | ||
|
|
2b866b32bb | ||
|
|
97896b5170 | ||
|
|
3647ff15e1 | ||
|
|
267f753452 | ||
|
|
c33e463e09 | ||
|
|
40cfc3c9f5 | ||
|
|
632ba5257e | ||
|
|
7127effdaf | ||
|
|
ca3f7e964e | ||
|
|
904e779b59 | ||
|
|
63054b4a3a | ||
|
|
871f3c5ba8 | ||
|
|
9c706bb9b1 | ||
|
|
06c57ca837 | ||
|
|
39a3ec055b | ||
|
|
401cf8e1a7 | ||
|
|
f50d624d22 | ||
|
|
4aeee1acb5 | ||
|
|
b6a9cfed19 | ||
|
|
a67dcf763b | ||
|
|
0f58c2dcae | ||
|
|
9cb1418b0d | ||
|
|
f62e6ca651 | ||
|
|
0c6ddd4904 | ||
|
|
14d4dbfe97 | ||
|
|
50d0c2cd4d | ||
|
|
4fe45169c3 | ||
|
|
78d93a16eb | ||
|
|
b94bf528be | ||
|
|
11ad57bce4 | ||
|
|
495a55f8c1 | ||
|
|
c611360c04 | ||
|
|
ada418374b | ||
|
|
3bf7f2a195 | ||
|
|
2d22cab6e7 | ||
|
|
96dcbe1798 | ||
|
|
ac6dc5b426 | ||
|
|
b4f22ffeea | ||
|
|
ca3ed630ed | ||
|
|
e2d3868a9e | ||
|
|
47314620be | ||
|
|
f26f3f2665 | ||
|
|
938b37e920 | ||
|
|
2c5a989306 | ||
|
|
88a6dd9316 | ||
|
|
77742c1d6f | ||
|
|
ba16c6475a | ||
|
|
1735098b3a | ||
|
|
2fdaaa47ab | ||
|
|
bd4e4aed27 | ||
|
|
94a8240ad4 | ||
|
|
be03af61ea | ||
|
|
4da34c98f3 | ||
|
|
12253f0621 | ||
|
|
369954f5d2 | ||
|
|
4eee702dce | ||
|
|
e90daa2e61 | ||
|
|
cc8570d02f | ||
|
|
98e5ea965c | ||
|
|
7a98ab1c6d | ||
|
|
70973a63fb | ||
|
|
ad82f73c1d | ||
|
|
e08016c103 | ||
|
|
a65e99b199 | ||
|
|
4853150f07 | ||
|
|
a341e66c13 | ||
|
|
874779d230 | ||
|
|
779e8a8b0f | ||
|
|
8f35e88ce4 | ||
|
|
71e874cfb4 | ||
|
|
622b8942b5 | ||
|
|
7aeb7d094c | ||
|
|
4ee80f8b7e | ||
|
|
4859fa6877 | ||
|
|
a1d831cdf2 | ||
|
|
a3ee639d77 | ||
|
|
cd274aea81 | ||
|
|
aaa548eb21 | ||
|
|
99f05a055d | ||
|
|
e614d50f9c | ||
|
|
20526c829c | ||
|
|
c9ed33f108 | ||
|
|
4d728c8e68 | ||
|
|
ef3aed4ba2 | ||
|
|
8f30fdb88c | ||
|
|
d4b67906cd | ||
|
|
075fa32ea2 | ||
|
|
f71f678662 | ||
|
|
457857df32 | ||
|
|
49adc84f5c | ||
|
|
a2a9a8c3a0 | ||
|
|
a62db898aa | ||
|
|
a2a6e5c5fe | ||
|
|
b9307efba2 | ||
|
|
52ccff4086 | ||
|
|
7f59856da3 | ||
|
|
10dc913080 | ||
|
|
1d2f190459 | ||
|
|
859ab9cfaf | ||
|
|
924d3dabb9 | ||
|
|
b227337ced | ||
|
|
717ffb4b8a | ||
|
|
08121fc701 | ||
|
|
460f18d85a | ||
|
|
6c34d510e5 | ||
|
|
789fc8bcbc | ||
|
|
31e72f28b0 | ||
|
|
3d0b87998d | ||
|
|
6c7b9a4ad8 | ||
|
|
f4379b07ca | ||
|
|
55364da10b | ||
|
|
e28b34b49b | ||
|
|
7ce3167d57 | ||
|
|
b0b9ae068a | ||
|
|
54349b4e8a | ||
|
|
2483e71d98 | ||
|
|
6b46873009 | ||
|
|
685a76bdd1 | ||
|
|
933a8bf3c8 | ||
|
|
e228d20d0b | ||
|
|
19ec49778e | ||
|
|
17dbe04c4b | ||
|
|
e5404fa1b9 | ||
|
|
f6506aeeca | ||
|
|
795720dcd2 | ||
|
|
85962b11a6 | ||
|
|
c1229b348e | ||
|
|
06358c4c07 | ||
|
|
fffde38fed | ||
|
|
13bfc40c6a | ||
|
|
9024a1eab6 | ||
|
|
aa851a7779 | ||
|
|
ac3d20d072 | ||
|
|
02f16516f1 | ||
|
|
c8301113e5 | ||
|
|
73fd35ad40 | ||
|
|
996ed3d776 | ||
|
|
05feced28f | ||
|
|
fe844437fb | ||
|
|
3de05c08bc | ||
|
|
e6509e0932 | ||
|
|
ce95ed4854 | ||
|
|
3bf2d553c8 | ||
|
|
b3fb490c16 | ||
|
|
5e8c2c73fd | ||
|
|
a75aabbec6 | ||
|
|
583522a422 | ||
|
|
a9b4a95e0c | ||
|
|
8b68d52be0 | ||
|
|
8f52aca2b4 | ||
|
|
744f920854 | ||
|
|
fe43d274cb | ||
|
|
53f4c17a08 | ||
|
|
f728cdafb4 | ||
|
|
21b4b9b7fb | ||
|
|
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 |
@@ -3,23 +3,72 @@ run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "*"
|
||||
paths:
|
||||
- 'dockerfile'
|
||||
tags-ignore:
|
||||
- '*'
|
||||
- main
|
||||
paths-ignore:
|
||||
- 'django_testing/dockerfile'
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
Explore-Gitea-Actions:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
DEBUG: True
|
||||
ALLOWED_HOSTS: "django.tryton.geeraert.eu"
|
||||
container:
|
||||
image: gitea.tryton.geeraert.eu/pi-ux-ce/custom-runner-debian-slim:1.0.6
|
||||
volumes:
|
||||
- act-toolcache:/opt/hostedtoolcache # this is where Runner store their cache default
|
||||
runs-on: host-runner
|
||||
steps:
|
||||
|
||||
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||
|
||||
- name: restore git folder if exist
|
||||
run: if [ -d "/opt/hostedtoolcache/${{ github.event.repository.name }}/" ]; then cp -r /opt/hostedtoolcache/${{ github.event.repository.name }}/ ${{ gitea.workspace }}; fi
|
||||
|
||||
- name: Check Docker Version
|
||||
run: whereis docker
|
||||
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
clean: false
|
||||
fetch-depth: 1
|
||||
ref: 'main'
|
||||
|
||||
# - name: Manually check out repository code
|
||||
# run: cd ${{ gitea.workspace }} ; git pull origin main
|
||||
|
||||
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||
|
||||
- name: List files in the repository
|
||||
run: |
|
||||
ls ${{ gitea.workspace }}
|
||||
|
||||
- name: Compute next version
|
||||
id: versioning
|
||||
run: |
|
||||
latest="${{ vars.VERSION }}"
|
||||
next_version=$(echo "$latest" | awk -F. -v OFS=. '{$NF += 1 ; print}')
|
||||
echo "next_version=$next_version" >> $GITHUB_ENV
|
||||
echo "Variables used :"
|
||||
echo "------------------------------------------------"
|
||||
echo "Next version: $next_version"
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: /opt/hostedtoolcache/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
|
||||
- name: inject cache into docker
|
||||
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
|
||||
with:
|
||||
cache-source: /opt/hostedtoolcache/pip
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
@@ -34,7 +83,41 @@ jobs:
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: true
|
||||
tags: gitea.tryton.geeraert.eu/pi-ux-ce/django-python:latest
|
||||
build-args: |
|
||||
ALLOWED_HOSTS='django.tryton.geeraert.eu'
|
||||
DEBUG='True'
|
||||
tags: |
|
||||
gitea.tryton.geeraert.eu/pi-ux-ce/django-python:latest
|
||||
gitea.tryton.geeraert.eu/pi-ux-ce/django-python:${{ env.next_version }}
|
||||
cache-from: type=local,src=/opt/hostedtoolcache/.buildx-cache
|
||||
cache-to: type=local,dest=/opt/hostedtoolcache/.buildx-cache-new,mode=max
|
||||
|
||||
- name: Move cache
|
||||
run: |
|
||||
rm -rf /opt/hostedtoolcache/.buildx-cache
|
||||
mv /opt/hostedtoolcache/.buildx-cache-new /opt/hostedtoolcache/.buildx-cache
|
||||
|
||||
- name: Rollout Django 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
|
||||
|
||||
- name: Rollout Celery worker to force pulling the new image
|
||||
uses: actions-hub/kubectl@master
|
||||
env:
|
||||
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
|
||||
with:
|
||||
args: rollout restart deployment celery-worker -n django
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
|
||||
- name: update version in the variable
|
||||
run: |
|
||||
curl -X PUT -H "Content-Type: application/json" \
|
||||
--user ${{ secrets.USERNAME_GITEA }}:${{ secrets.PASSWORD_GITEA }} \
|
||||
https://gitea.tryton.geeraert.eu/api/v1/repos/pi-ux-ce/${{ github.event.repository.name }}/actions/variables/VERSION \
|
||||
-d "{\"Value\":\"$next_version\"}"
|
||||
|
||||
- name: backup git for future use
|
||||
run: cp -r ${{ gitea.workspace }} /opt/hostedtoolcache/${{ github.event.repository.name }}/
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
name: Gitea Actions Demo
|
||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "testing"
|
||||
paths:
|
||||
- 'django_testing/dockerfile'
|
||||
tags-ignore:
|
||||
- '*'
|
||||
workflow_dispatch: # Enables the manual run UI button
|
||||
|
||||
|
||||
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: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Compute next version
|
||||
id: versioning
|
||||
run: |
|
||||
latest="${{ vars.VERSION_TESTING }}"
|
||||
next_version=$(echo "$latest" | awk -F. -v OFS=. '{$NF += 1 ; print}')
|
||||
echo "next_version=$next_version" >> $GITHUB_ENV
|
||||
echo "Variables used :"
|
||||
echo "------------------------------------------------"
|
||||
echo "Next version: $next_version"
|
||||
|
||||
|
||||
- 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:
|
||||
context: django_testing/
|
||||
push: true
|
||||
build-args: |
|
||||
ALLOWED_HOSTS='django-testing.tryton.geeraert.eu'
|
||||
DEBUG='True'
|
||||
tags: |
|
||||
gitea.tryton.geeraert.eu/pi-ux-ce/django-testing:latest
|
||||
gitea.tryton.geeraert.eu/pi-ux-ce/django-testing:${{ env.next_version }}
|
||||
cache-from: type=registry,ref=gitea.tryton.geeraert.eu/pi-ux-ce/django-testing:buildcache
|
||||
cache-to: type=registry,ref=gitea.tryton.geeraert.eu/pi-ux-ce/django-testing:buildcache,mode=max
|
||||
|
||||
- name: update version in the variable
|
||||
run: |
|
||||
curl -X PUT -H "Content-Type: application/json" \
|
||||
--user ${{ secrets.USERNAME_GITEA }}:${{ secrets.PASSWORD_GITEA }} \
|
||||
https://gitea.tryton.geeraert.eu/api/v1/repos/pi-ux-ce/${{ github.event.repository.name }}/actions/variables/VERSION_TESTING \
|
||||
-d "{\"Value\":\"$next_version\"}"
|
||||
|
||||
- name: Rollout Django to force pulling the new image
|
||||
uses: actions-hub/kubectl@master
|
||||
env:
|
||||
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
|
||||
with:
|
||||
args: rollout restart deployment django-testing -n django-testing
|
||||
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
@@ -1,6 +1,13 @@
|
||||
name: Gitea Actions Demo
|
||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||
on: [push]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "*"
|
||||
paths:
|
||||
- '*.yaml'
|
||||
tags-ignore:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
Explore-Gitea-Actions:
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
name: Gitea Actions Demo
|
||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "testing"
|
||||
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: Rollout Django to force pulling the new image
|
||||
uses: actions-hub/kubectl@master
|
||||
env:
|
||||
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
|
||||
with:
|
||||
args: rollout restart deployment django-testing -n django-testing
|
||||
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
+228
@@ -1 +1,229 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[codz]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py.cover
|
||||
*.lcov
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
# Pipfile.lock
|
||||
|
||||
# UV
|
||||
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# uv.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
# poetry.lock
|
||||
# poetry.toml
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
||||
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
||||
# pdm.lock
|
||||
# pdm.toml
|
||||
.pdm-python
|
||||
.pdm-build/
|
||||
|
||||
# pixi
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
||||
# pixi.lock
|
||||
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
||||
# in the .venv directory. It is recommended not to include this directory in version control.
|
||||
.pixi/*
|
||||
!.pixi/config.toml
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule*
|
||||
celerybeat.pid
|
||||
|
||||
# Redis
|
||||
*.rdb
|
||||
*.aof
|
||||
*.pid
|
||||
|
||||
# RabbitMQ
|
||||
mnesia/
|
||||
rabbitmq/
|
||||
rabbitmq-data/
|
||||
|
||||
# ActiveMQ
|
||||
activemq-data/
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.envrc
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
# .idea/
|
||||
|
||||
# Abstra
|
||||
# Abstra is an AI-powered process automation framework.
|
||||
# Ignore directories containing user credentials, local state, and settings.
|
||||
# Learn more at https://abstra.io/docs
|
||||
.abstra/
|
||||
|
||||
# Visual Studio Code
|
||||
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
||||
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
||||
# you could uncomment the following to ignore the entire vscode folder
|
||||
# .vscode/
|
||||
# Temporary file for partial code execution
|
||||
tempCodeRunnerFile.py
|
||||
|
||||
# Ruff stuff:
|
||||
.ruff_cache/
|
||||
|
||||
# PyPI configuration file
|
||||
.pypirc
|
||||
|
||||
# Marimo
|
||||
marimo/_static/
|
||||
marimo/_lsp/
|
||||
__marimo__/
|
||||
|
||||
# Streamlit
|
||||
.streamlit/secrets.toml
|
||||
|
||||
*/__pycache__/*
|
||||
*/.idea/*
|
||||
*/venv/*
|
||||
*/.env/*
|
||||
Webcal-python/*
|
||||
.idea/*
|
||||
django_code/db.sqlite3
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: django-python
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: django-webserver
|
||||
namespace: django-python
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: django-python
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: django-python
|
||||
spec:
|
||||
containers:
|
||||
- name: django-python
|
||||
image: gitea.tryton.geeraert.eu/pi-ux-ce/django-python:latest
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 8000
|
||||
name: webserver-port
|
||||
volumeMounts:
|
||||
- name: django-python-code
|
||||
mountPath: /code
|
||||
- name: servarr-data
|
||||
mountPath: /data
|
||||
readOnly: true
|
||||
|
||||
resources:
|
||||
limits:
|
||||
cpu: 100m
|
||||
memory: 200Mi
|
||||
volumes:
|
||||
- name: django-python-code
|
||||
persistentVolumeClaim:
|
||||
claimName: django-python-code
|
||||
- name: servarr-data
|
||||
hostPath:
|
||||
path: /data
|
||||
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: webserver
|
||||
namespace: django-python
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 8000
|
||||
protocol: TCP
|
||||
selector:
|
||||
app: django-python
|
||||
@@ -1,13 +1,54 @@
|
||||
=======
|
||||
# Django_kube
|
||||
test
|
||||
|
||||
|
||||
## Getting started
|
||||
### Database migration
|
||||
|
||||
```
|
||||
python django_code/manage.py makemigrations
|
||||
python django_code/manage.py makemigrations redirect
|
||||
python django_code/manage.py makemigrations cloudmanager
|
||||
python django_code/manage.py makemigrations simpsons
|
||||
python django_code/manage.py makemigrations job
|
||||
|
||||
python django_code/manage.py migrate
|
||||
python django_code/manage.py migrate --database=cloudmanager_db
|
||||
python django_code/manage.py migrate --database=simpsons_db
|
||||
python django_code/manage.py migrate --database=redirect_db
|
||||
python django_code/manage.py migrate --database=job_db
|
||||
```
|
||||
### Database debug
|
||||
|
||||
```
|
||||
create database django;
|
||||
create database simpsons;
|
||||
create database cloudmanager;
|
||||
create database redirect;
|
||||
|
||||
drop database django;
|
||||
drop database simpsons;
|
||||
drop database cloudmanager;
|
||||
drop database redirect;
|
||||
```
|
||||
|
||||
|
||||
### Setup virtualenv variables
|
||||
edit venv/bin/activate or .env/bin/activate
|
||||
|
||||
and add the following code
|
||||
```
|
||||
export DB_HOST=localhost
|
||||
export DB_PORT=5432
|
||||
export DB_USERNAME=postgres
|
||||
export DB_PASSWORD=example
|
||||
export DB_DATABASE=cloudmanager
|
||||
export CUSTOM_DB_DATABASE=cloudmanager
|
||||
export ALLOWED_HOSTS="0.0.0.0,localhost,127.0.0.1"
|
||||
export DEBUG=true
|
||||
export bitwarden_access_token="PROVIDED IN BITWARDEN ADMIN INTERFACE"
|
||||
export bitwarden_organization_id=""
|
||||
```
|
||||
|
||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||
|
||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||
|
||||
## Add your files
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import requests
|
||||
import hashlib
|
||||
from apps.bitwarden.utils import bitwardenUtils
|
||||
import os
|
||||
|
||||
class betaserieUtils():
|
||||
url = "https://api.betaseries.com/members/auth"
|
||||
|
||||
username_UID="7bc7ebd2-9c95-487f-9ba2-b47301591ef0"
|
||||
password_UID="262c3246-203b-44e0-854b-b47301599730"
|
||||
token_UID="2cf4be0f-f26f-473f-b8f1-b473016139e4"
|
||||
|
||||
#Adding __ to make the variable private and can't be access outside the class,
|
||||
# only by the class itself ot the subclass
|
||||
|
||||
__bitwarden_access_token = os.environ.get('bitwarden_access_token')
|
||||
__bitwarden_organization_id = os.environ.get('bitwarden_organization_id')
|
||||
|
||||
bw = bitwardenUtils(__bitwarden_access_token,__bitwarden_organization_id)
|
||||
|
||||
__betaserie_username = bw.read_value_secret(username_UID)
|
||||
__betaserie_md5_password = bw.read_value_secret(password_UID)
|
||||
__betaserie_apikey = bw.read_value_secret(token_UID)
|
||||
|
||||
payload = {
|
||||
'login': __betaserie_username, # username or email
|
||||
'password': __betaserie_md5_password # MD5 hashed password
|
||||
}
|
||||
|
||||
headers = {
|
||||
'X-BetaSeries-Key': __betaserie_apikey,
|
||||
}
|
||||
response = requests.post(url, headers=headers, data=payload)
|
||||
|
||||
#now set with the correct value
|
||||
__betaserie_token = response.json()['token']
|
||||
|
||||
#set the __betaserie_token to the doct headers now
|
||||
headers.update({'X-BetaSeries-Token': __betaserie_token})
|
||||
|
||||
def status_code(self):
|
||||
print("Status code:", self.response.status_code)
|
||||
print("Response:", self.response.json())
|
||||
|
||||
|
||||
def identify_serie(self,serie_name,verbose=False):
|
||||
#
|
||||
# Usage
|
||||
# show_id = beta.identify_serie("The simpsons")
|
||||
# show_id = beta.identify_serie("The simpsons",verbose=True)
|
||||
#
|
||||
url = "https://api.betaseries.com/shows/search?title="+serie_name
|
||||
|
||||
response = requests.request("GET", url, headers=self.headers, data=self.payload)
|
||||
if verbose:
|
||||
print("Url request: "+str(url))
|
||||
print(response.text)
|
||||
|
||||
show_id = response.json()['shows'][0]['id']
|
||||
|
||||
return show_id
|
||||
|
||||
def identify_episode(self,show_id,episode_number,verbose=False):
|
||||
#
|
||||
# Usage
|
||||
# episode_id = beta.identify_episode(show_id,"S01E01",True)
|
||||
#
|
||||
url = "https://api.betaseries.com/episodes/search?show_id="+str(show_id)+"&number="+str(episode_number)
|
||||
|
||||
response = requests.request("GET", url, headers=self.headers, data=self.payload)
|
||||
|
||||
episode_id = response.json()['episode']['id']
|
||||
if verbose:
|
||||
print("Url request: "+str(url))
|
||||
print(response.text)
|
||||
|
||||
return episode_id
|
||||
|
||||
def mark_episodes_watched(self,episode_id,verbose=False):
|
||||
#
|
||||
# Usage
|
||||
# response = beta.mark_episodes_watched(episode_id,True)
|
||||
#
|
||||
url = "https://api.betaseries.com/episodes/watched?id="+str(episode_id)+"&bulk=false"
|
||||
|
||||
response = requests.request("POST", url, headers=self.headers, data=self.payload)
|
||||
if verbose:
|
||||
print("Url request: "+str(url))
|
||||
print(response.text)
|
||||
|
||||
return response.status_code
|
||||
|
||||
def unmark_episodes_watched(self,episode_id,verbose=False):
|
||||
#
|
||||
# Usage
|
||||
# response = beta.unmark_episodes_watched(episode_id,True)
|
||||
#
|
||||
url = "https://api.betaseries.com/episodes/watched?id="+str(episode_id)
|
||||
|
||||
response = requests.request("DELETE", url, headers=self.headers, data=self.payload)
|
||||
|
||||
if verbose:
|
||||
print("Url request: "+str(url))
|
||||
print(response.text)
|
||||
|
||||
return response.status_code
|
||||
@@ -0,0 +1,87 @@
|
||||
import logging
|
||||
import os
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from bitwarden_sdk import BitwardenClient, DeviceType, client_settings_from_dict
|
||||
|
||||
|
||||
class bitwardenUtils():
|
||||
#documentation
|
||||
#https://github.com/external-secrets/bitwarden-sdk-server
|
||||
state_path = "/tmp/state_file.txt"
|
||||
client = BitwardenClient(
|
||||
client_settings_from_dict(
|
||||
{
|
||||
"apiUrl": os.getenv("API_URL", "https://bitwarden.tryton.geeraert.eu/api"),
|
||||
"deviceType": DeviceType.SDK,
|
||||
"identityUrl": os.getenv("IDENTITY_URL", "https://bitwarden.tryton.geeraert.eu/identity"),
|
||||
"userAgent": "Python",
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
def verbose(self):
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
|
||||
def __init__(self, __access_token, __organization_id):
|
||||
self.__access_token = __access_token
|
||||
self.__organization_id = __organization_id
|
||||
self.client.auth().login_access_token(self.__access_token, self.state_path)
|
||||
|
||||
def create_project(self,project_name):
|
||||
project = self.client.projects().create(self.__organization_id, project_name)
|
||||
return project.data.id
|
||||
|
||||
def generate_strong_password(self):
|
||||
# Note: using the generator does not require authentication with a server
|
||||
return self.client.generators().generate() # using default params
|
||||
|
||||
def create_secret(self,project_id,secret_name,secret_value,description="description"):
|
||||
secret = self.client.secrets().create(
|
||||
self.__organization_id,
|
||||
secret_name,
|
||||
secret_value,
|
||||
description,
|
||||
[project_id],
|
||||
)
|
||||
return secret.data.id
|
||||
|
||||
|
||||
def read_value_secret(self,secret_id):
|
||||
return self.client.secrets().get_by_ids([secret_id]).data.data[0].value
|
||||
|
||||
def read_value_secrets(self,list_secret_id):
|
||||
if not(isinstance(list_secret_id, list)):
|
||||
print("this is not a list")
|
||||
return 1
|
||||
list_secret_value = []
|
||||
for secret_value in self.client.secrets().get_by_ids(list_secret_id).data.data:
|
||||
list_secret_value.append(secret_value.value)
|
||||
return list_secret_value
|
||||
|
||||
def delete_secrets(self,list_secret_id):
|
||||
if not(isinstance(list_secret_id, list)):
|
||||
print("this is not a list")
|
||||
return 1
|
||||
try:
|
||||
self.client.secrets().delete(list_secret_id)
|
||||
status=0
|
||||
except:
|
||||
print("Cannot delete the secrets")
|
||||
status=1
|
||||
return status
|
||||
|
||||
def delete_projects(self,list_project_id):
|
||||
if not(isinstance(list_project_id, list)):
|
||||
print("this is not a list")
|
||||
return 1
|
||||
try:
|
||||
self.client.projects().delete(list_project_id)
|
||||
status=0
|
||||
except:
|
||||
print("Cannot delete the project")
|
||||
status=1
|
||||
return status
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
from django.contrib import admin,messages
|
||||
from django.utils.translation import ngettext
|
||||
from .models import Deployment_Data,Schedule_Day_Data,Schedule_Week_Data,Namespace_Data,namespace_cmm_data_object
|
||||
from .utils import import_namespace
|
||||
from apps.kubernetes_connection.utils import scale_up,scale_down
|
||||
|
||||
DB = 'cloudmanager_db'
|
||||
|
||||
|
||||
@admin.action(description="scale up")
|
||||
def scale_up_deploy(modeladmin, request, queryset):
|
||||
for query in queryset.values():
|
||||
scale_up(namespace_name=query['namespace'],deploy_name=query['name'],replicas=query['replicas'])
|
||||
modeladmin.message_user(
|
||||
request,
|
||||
ngettext(
|
||||
"%d server was successfully scaled up.",
|
||||
"%d servers were successfully scaled up.",
|
||||
queryset.values().count(),
|
||||
)
|
||||
% queryset.values().count(),
|
||||
messages.SUCCESS,
|
||||
)
|
||||
|
||||
|
||||
@admin.action(description="scale down")
|
||||
def scale_down_deploy(modeladmin, request, queryset):
|
||||
for query in queryset.values():
|
||||
scale_down(namespace_name=query['namespace'],deploy_name=query['name'])
|
||||
modeladmin.message_user(
|
||||
request,
|
||||
ngettext(
|
||||
"%d server was successfully scaled down.",
|
||||
"%d servers were successfully scaled down.",
|
||||
queryset.values().count(),
|
||||
)
|
||||
% queryset.values().count(),
|
||||
messages.SUCCESS,
|
||||
)
|
||||
|
||||
@admin.action(description="create_entry")
|
||||
def create_entry(modeladmin, request, queryset):
|
||||
print("simpsons_data_object.create(season=2, episode=3, url='google.com'', seen=True)")
|
||||
#call function to trigger refresh of all deploy
|
||||
|
||||
@admin.action(description="import namespace")
|
||||
def import_namespace_admin(modeladmin, request, queryset):
|
||||
#
|
||||
#
|
||||
#
|
||||
# don't forgot to clear thge quyeryset before running this
|
||||
#
|
||||
import_namespace(namespace_cmm_data_object)
|
||||
print("simpsons_data_object.create(season=2, episode=3, url='google.com'', seen=True)")
|
||||
#call function to trigger refresh of all deploy
|
||||
|
||||
|
||||
class ActiveAtHourFilter(admin.SimpleListFilter):
|
||||
title = 'Active at hour'
|
||||
parameter_name = 'active_at_hour'
|
||||
|
||||
def lookups(self, request, model_admin):
|
||||
return [(str(h), f'{h:02d}:00') for h in range(24)]
|
||||
|
||||
def queryset(self, request, queryset):
|
||||
if self.value() is not None:
|
||||
hour = self.value()
|
||||
return queryset.filter(**{f'schedule_day__state_at_{hour}': True})
|
||||
return queryset
|
||||
|
||||
|
||||
class MultiDBModelAdmin(admin.ModelAdmin):
|
||||
"""Base class that pins all admin operations to DB."""
|
||||
db = DB
|
||||
|
||||
def get_queryset(self, request):
|
||||
return super().get_queryset(request).using(self.db)
|
||||
|
||||
def save_model(self, request, obj, form, change):
|
||||
obj.save(using=self.db)
|
||||
|
||||
def delete_model(self, request, obj):
|
||||
obj.delete(using=self.db)
|
||||
|
||||
def delete_queryset(self, request, queryset):
|
||||
queryset.using(self.db).delete()
|
||||
|
||||
|
||||
@admin.register(Deployment_Data)
|
||||
class DeploymentDataAdmin(MultiDBModelAdmin):
|
||||
list_display = ('name', 'namespace', 'schedule_week', 'schedule_day', 'replicas')
|
||||
list_filter = (ActiveAtHourFilter,)
|
||||
actions = [scale_up_deploy,scale_down_deploy]
|
||||
|
||||
|
||||
@admin.register(Schedule_Day_Data)
|
||||
class ScheduleDayAdmin(MultiDBModelAdmin):
|
||||
list_display = ['name_schedule'] + [f'state_at_{h}' for h in range(24)]
|
||||
|
||||
|
||||
@admin.register(Schedule_Week_Data)
|
||||
class ScheduleWeekAdmin(MultiDBModelAdmin):
|
||||
list_display = (
|
||||
'name_schedule',
|
||||
'state_Monday', 'state_Tuesday', 'state_Wednesday',
|
||||
'state_Thursday', 'state_Friday', 'state_Saturday', 'state_Sunday',
|
||||
)
|
||||
|
||||
@admin.register(Namespace_Data)
|
||||
class NamespaceAdmin(MultiDBModelAdmin):
|
||||
list_display = ('namespace',)
|
||||
actions = [import_namespace_admin]
|
||||
@@ -0,0 +1,37 @@
|
||||
from django.apps import AppConfig
|
||||
from django.http import HttpResponse
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import render
|
||||
import os
|
||||
import psycopg2
|
||||
from apps.cloudmanager.db_interaction import DB_generation,Check_server_supposed_XXX,Give_current_weekday,Give_current_hour
|
||||
|
||||
|
||||
class CloudmanagerConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'apps.cloudmanager'
|
||||
label = 'cloudmanager'
|
||||
|
||||
def coucou(request):
|
||||
return HttpResponse('<h1>Hello cmm!</h1>')
|
||||
|
||||
def hello(request):
|
||||
list_schedule = ['schedule1','schedule2']
|
||||
list_servers_up = [['wiki', 'wikijs', 2], ['book', 'bookstack-db', 1]]
|
||||
return render(request, 'cloudmanager/index.html', {'list_schedule':list_schedule,'list_servers_up':list_servers_up})
|
||||
|
||||
def redirect(request):
|
||||
db_host = os.environ.get('DB_HOST')
|
||||
db_port = os.environ.get('DB_PORT')
|
||||
db_user = os.environ.get('DB_USERNAME')
|
||||
db_password = os.environ.get('DB_PASSWORD')
|
||||
db_name = os.environ.get('CUSTOM_DB_DATABASE',os.environ.get('DB_DATABASE'))
|
||||
|
||||
generated_db = DB_generation(db_host, db_port, db_user, db_password,db_name)
|
||||
##operation:
|
||||
## Server(s) supposed to be UP
|
||||
|
||||
list_servers_up = Check_server_supposed_XXX(generated_db, "up", Give_current_hour(),Give_current_weekday())
|
||||
print(list_servers_up)
|
||||
return render(request, 'cloudmanager/cmm_blank_page.html', {'list_servers_up':list_servers_up})
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
class sql:
|
||||
url = 'localhost'
|
||||
port = 5432
|
||||
user = 'postgres'
|
||||
password = 'example'
|
||||
database = 'cloudmanager'
|
||||
@@ -0,0 +1,167 @@
|
||||
import psycopg2
|
||||
from django.http import HttpResponse
|
||||
from django.views.decorators.http import require_POST
|
||||
from apps.kubernetes_connection import apps as kubernetes_connection
|
||||
import datetime
|
||||
from apps.cloudmanager import credentials
|
||||
import os
|
||||
|
||||
def hello(request):
|
||||
kubernetes_connection.echoHello();
|
||||
return HttpResponse('<h1>Hello cmm !</h1>')
|
||||
|
||||
def DB_generation(host_in,port_in,user_in,password_in,db_in):
|
||||
db = psycopg2.connect(host=host_in, port=port_in, user=user_in, password=password_in,database=db_in)
|
||||
return db
|
||||
|
||||
@require_POST
|
||||
def change_schedule(request):
|
||||
# HTMX sends these via standard POST data
|
||||
schedule_id = request.POST.get('schedule_id')
|
||||
server_name = request.POST.get('server_name')
|
||||
|
||||
if not schedule_id or not server_name:
|
||||
return HttpResponse("<span style='color: red;'>Missing parameters.</span>", status=400)
|
||||
|
||||
try:
|
||||
# --- Your Core Logic Here ---
|
||||
# e.g., Server.objects.filter(name=server_name).update(schedule_id=schedule_id)
|
||||
print(f"Updating {server_name} to schedule profile {schedule_id}")
|
||||
|
||||
# Return a success message that will instantly inject into the server's status div
|
||||
return HttpResponse("<span style='color: green;'>✓ Updated successfully!</span>")
|
||||
|
||||
except Exception as e:
|
||||
return HttpResponse(f"<span style='color: red;'>Error: {str(e)}</span>", status=500)
|
||||
|
||||
def Launch_sql_query(sql,db):
|
||||
# prepare a cursor object using cursor() method
|
||||
cursor = db.cursor()
|
||||
|
||||
try:
|
||||
# Execute the SQL command
|
||||
cursor.execute(sql)
|
||||
# Fetch all the rows in a list of lists.
|
||||
results = cursor.fetchall()
|
||||
result_machine = []
|
||||
#result_machine_type = []
|
||||
for row in results:
|
||||
result_machine_type = []
|
||||
namespace = row[0]
|
||||
name = row[1]
|
||||
replicas = row[2]
|
||||
|
||||
result_machine_type.append(namespace)
|
||||
result_machine_type.append(name)
|
||||
result_machine_type.append(replicas)
|
||||
result_machine.append(result_machine_type)
|
||||
return result_machine
|
||||
|
||||
except:
|
||||
print ("Error: unable to fetch data")
|
||||
|
||||
|
||||
#Return the day of the week as an integer, where Monday is 0 and Sunday is 6.
|
||||
def Give_current_weekday():
|
||||
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday','Saturday', 'Sunday']
|
||||
weekday = days[datetime.datetime.today().weekday()]
|
||||
return weekday
|
||||
|
||||
def Give_current_hour():
|
||||
now = datetime.datetime.now()
|
||||
return now.hour
|
||||
|
||||
|
||||
def Check_server_supposed_XXX(generated_db_in,wanted_status,Wanted_hour,Wanted_day):
|
||||
sql_in=""
|
||||
if wanted_status == "up":
|
||||
sql_in = "select machine.namespace, machine.name, machine.replicas from scenario_hour,machine ,scenario_day_of_week where state_at_" + str(Wanted_hour) + "='1' and state_" + str(Wanted_day) + "='1' and machine.hour_behaviour_id=scenario_hour.id_scenario and machine.day_behaviour_id=scenario_day_of_week.id_scenario;"
|
||||
elif wanted_status == "down":
|
||||
sql_in = "select machine.namespace, machine.name, machine.replicas from scenario_hour,machine ,scenario_day_of_week where not(state_at_" + str(Wanted_hour) + "='1' and state_" + str(Wanted_day) + "='1') and machine.hour_behaviour_id=scenario_hour.id_scenario and machine.day_behaviour_id=scenario_day_of_week.id_scenario;"
|
||||
else:
|
||||
print("error value")
|
||||
print(sql_in)
|
||||
return_value = Launch_sql_query(sql_in, generated_db_in)
|
||||
return return_value
|
||||
|
||||
def Is_the_server_already_wanted_state(id_machine, wanted_state,instance_type):
|
||||
#stopped/running
|
||||
bool_result = ""
|
||||
proxmox = function.proxmox_connection(credentials.proxmox.zeus.url_proxmox,credentials.proxmox.zeus.user,credentials.proxmox.zeus.password)
|
||||
if str(function.check_state_mix(id_machine,wanted_state,proxmox,instance_type)) == str(wanted_state):
|
||||
bool_result = True
|
||||
else:
|
||||
bool_result = False
|
||||
return bool_result
|
||||
|
||||
def all_operations(request,wanted_state,list_machine):
|
||||
for machine_target in list_machine:
|
||||
print(machine_target[1])
|
||||
|
||||
info_to_display = ""
|
||||
if wanted_state == "up":
|
||||
kubernetes_connection.scale_up(request,namespace_name=machine_target[0],deploy_name=machine_target[1],replicas=machine_target[2]);
|
||||
elif wanted_state == "down":
|
||||
kubernetes_connection.scale_down(request,namespace_name=machine_target[0],deploy_name=machine_target[1]);
|
||||
else:
|
||||
print("Incorrect wanted state")
|
||||
|
||||
|
||||
|
||||
# if not(Is_the_server_already_wanted_state(machine_target[0], wanted_state,machine_target[1])):
|
||||
# function.action(False,machine_target[0],operation_to_perform,machine_target[1])
|
||||
# print(str(machine_target[0])+" is now "+str(wanted_state))
|
||||
# elif Is_the_server_already_wanted_state(machine_target[0], wanted_state,machine_target[1]):
|
||||
# info_to_display = "operation already performed for "+machine_target[2]
|
||||
# print(info_to_display)
|
||||
#return info_to_display
|
||||
return ""
|
||||
|
||||
def main(request):
|
||||
|
||||
#get credentials from the env
|
||||
db_host = os.environ.get('DB_HOST')
|
||||
db_port = os.environ.get('DB_PORT')
|
||||
db_user = os.environ.get('DB_USERNAME')
|
||||
db_password = os.environ.get('DB_PASSWORD')
|
||||
db_name = os.environ.get('CUSTOM_DB_DATABASE',os.environ.get('DB_DATABASE'))
|
||||
|
||||
generated_db = DB_generation(db_host, db_port, db_user, db_password,db_name)
|
||||
##operation:
|
||||
## Server(s) supposed to be UP
|
||||
|
||||
list_servers_up = Check_server_supposed_XXX(generated_db, "up", Give_current_hour(),Give_current_weekday())
|
||||
print("------------------------------------------")
|
||||
print("-----------------UP-----------------------")
|
||||
print("------------------------------------------")
|
||||
print(list_servers_up)
|
||||
print(all_operations(request,"up", list_servers_up))
|
||||
|
||||
|
||||
## Server(s) supposed to be DOWN
|
||||
list_servers_down = Check_server_supposed_XXX(generated_db, "down", Give_current_hour(),Give_current_weekday())
|
||||
|
||||
print("------------------------------------------")
|
||||
print("----------------DOWN----------------------")
|
||||
print("------------------------------------------")
|
||||
print(list_servers_down)
|
||||
print(all_operations(request,"down",list_servers_down))
|
||||
|
||||
|
||||
# disconnect from server
|
||||
generated_db.close()
|
||||
|
||||
#print(Is_the_server_already_wanted_state(112, "stopped"))
|
||||
return HttpResponse('<h1>CMM executed!</h1>')
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
"""
|
||||
TO DO:
|
||||
EXTRACT TYPE OF MACHINE
|
||||
CREATE FUNCTION TO CHECK IF A MACHINE IS ALREADY DOWN OR NOT
|
||||
ADD FIELD IN SQL WITH PROJECT AND PUT DESCRIPTION -> ATTACH MACHINE TO PROJECT
|
||||
|
||||
"""
|
||||
@@ -0,0 +1,90 @@
|
||||
# Generated by Django 4.2.29 on 2026-06-22 20:21
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Namespace_Data',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('namespace', models.CharField(max_length=100)),
|
||||
],
|
||||
options={
|
||||
'db_table': 'namespace',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Schedule_Day_Data',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name_schedule', models.CharField(max_length=100, unique=True)),
|
||||
('state_at_0', models.BooleanField()),
|
||||
('state_at_1', models.BooleanField()),
|
||||
('state_at_2', models.BooleanField()),
|
||||
('state_at_3', models.BooleanField()),
|
||||
('state_at_4', models.BooleanField()),
|
||||
('state_at_5', models.BooleanField()),
|
||||
('state_at_6', models.BooleanField()),
|
||||
('state_at_7', models.BooleanField()),
|
||||
('state_at_8', models.BooleanField()),
|
||||
('state_at_9', models.BooleanField()),
|
||||
('state_at_10', models.BooleanField()),
|
||||
('state_at_11', models.BooleanField()),
|
||||
('state_at_12', models.BooleanField()),
|
||||
('state_at_13', models.BooleanField()),
|
||||
('state_at_14', models.BooleanField()),
|
||||
('state_at_15', models.BooleanField()),
|
||||
('state_at_16', models.BooleanField()),
|
||||
('state_at_17', models.BooleanField()),
|
||||
('state_at_18', models.BooleanField()),
|
||||
('state_at_19', models.BooleanField()),
|
||||
('state_at_20', models.BooleanField()),
|
||||
('state_at_21', models.BooleanField()),
|
||||
('state_at_22', models.BooleanField()),
|
||||
('state_at_23', models.BooleanField()),
|
||||
],
|
||||
options={
|
||||
'db_table': 'schedule_day',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Schedule_Week_Data',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name_schedule', models.CharField(max_length=100, unique=True)),
|
||||
('state_Monday', models.BooleanField()),
|
||||
('state_Tuesday', models.BooleanField()),
|
||||
('state_Wednesday', models.BooleanField()),
|
||||
('state_Thursday', models.BooleanField()),
|
||||
('state_Friday', models.BooleanField()),
|
||||
('state_Saturday', models.BooleanField()),
|
||||
('state_Sunday', models.BooleanField()),
|
||||
],
|
||||
options={
|
||||
'db_table': 'schedule_week',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Deployment_Data',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('namespace', models.CharField(max_length=100)),
|
||||
('replicas', models.IntegerField()),
|
||||
('schedule_day', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='cloudmanager.schedule_day_data')),
|
||||
('schedule_week', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='cloudmanager.schedule_week_data')),
|
||||
],
|
||||
options={
|
||||
'db_table': 'machine',
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,65 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
|
||||
class Schedule_Week_Data(models.Model):
|
||||
name_schedule = models.CharField(max_length=100,unique=True)
|
||||
state_Monday = models.BooleanField()
|
||||
state_Tuesday = models.BooleanField()
|
||||
state_Wednesday = models.BooleanField()
|
||||
state_Thursday = models.BooleanField()
|
||||
state_Friday = models.BooleanField()
|
||||
state_Saturday = models.BooleanField()
|
||||
state_Sunday = models.BooleanField()
|
||||
class Meta:
|
||||
db_table = 'schedule_week'
|
||||
def __str__(self):
|
||||
return self.name_schedule
|
||||
|
||||
class Schedule_Day_Data(models.Model):
|
||||
name_schedule = models.CharField(max_length=100,unique=True)
|
||||
state_at_0 = models.BooleanField()
|
||||
state_at_1 = models.BooleanField()
|
||||
state_at_2 = models.BooleanField()
|
||||
state_at_3 = models.BooleanField()
|
||||
state_at_4 = models.BooleanField()
|
||||
state_at_5 = models.BooleanField()
|
||||
state_at_6 = models.BooleanField()
|
||||
state_at_7 = models.BooleanField()
|
||||
state_at_8 = models.BooleanField()
|
||||
state_at_9 = models.BooleanField()
|
||||
state_at_10 = models.BooleanField()
|
||||
state_at_11 = models.BooleanField()
|
||||
state_at_12 = models.BooleanField()
|
||||
state_at_13 = models.BooleanField()
|
||||
state_at_14 = models.BooleanField()
|
||||
state_at_15 = models.BooleanField()
|
||||
state_at_16 = models.BooleanField()
|
||||
state_at_17 = models.BooleanField()
|
||||
state_at_18 = models.BooleanField()
|
||||
state_at_19 = models.BooleanField()
|
||||
state_at_20 = models.BooleanField()
|
||||
state_at_21 = models.BooleanField()
|
||||
state_at_22 = models.BooleanField()
|
||||
state_at_23 = models.BooleanField()
|
||||
class Meta:
|
||||
db_table = 'schedule_day'
|
||||
def __str__(self):
|
||||
return self.name_schedule
|
||||
|
||||
class Deployment_Data(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
namespace = models.CharField(max_length=100)
|
||||
schedule_week = models.ForeignKey(Schedule_Week_Data,null=True, blank=True, on_delete=models.SET_NULL)
|
||||
schedule_day = models.ForeignKey(Schedule_Day_Data,null=True, blank=True, on_delete=models.SET_NULL)
|
||||
replicas = models.IntegerField()
|
||||
class Meta:
|
||||
db_table = 'machine'
|
||||
|
||||
class Namespace_Data(models.Model):
|
||||
namespace = models.CharField(max_length=100)
|
||||
#deployments = models.ForeignKey(Schedule_Week_Data,null=True, blank=True, on_delete=models.SET_NULL)
|
||||
class Meta:
|
||||
db_table = 'namespace'
|
||||
|
||||
namespace_cmm_data_object = Namespace_Data.objects.using('cloudmanager_db')
|
||||
@@ -0,0 +1,13 @@
|
||||
from apps.kubernetes_connection.utils import get_namespace
|
||||
|
||||
|
||||
def import_namespace(queryset):
|
||||
namespaces_list = get_namespace()
|
||||
for namespace in namespaces_list:
|
||||
queryset.create(namespace=namespace)
|
||||
|
||||
def import_deployment(queryset):
|
||||
namespaces_list = get_namespace()
|
||||
#for namespace in namespaces_list:
|
||||
# queryset.create(namespace=namespace)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
from django.http import HttpResponse
|
||||
|
||||
# IMPORT AT THE TOP HERE: This is completely safe!
|
||||
from apps.cloudmanager.models import Deployment_Data,Schedule_Week_Data
|
||||
|
||||
def coucou(request):
|
||||
# 1. Prepare the data inside the function
|
||||
data = CmmData(
|
||||
name="test",
|
||||
namespace="testspace",
|
||||
schedule_hour="1",
|
||||
schedule_day="deux",
|
||||
replicas=3
|
||||
)
|
||||
|
||||
# 2. This line actually pushes the data into your cloudmanager_db!
|
||||
data.save()
|
||||
|
||||
return HttpResponse('<h1>Hello cmm! Data saved successfully!</h1>')
|
||||
|
||||
def display(request):
|
||||
data = CmmData.objects.all()
|
||||
print(data[0].namespace)
|
||||
return HttpResponse(data)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
|
||||
def home(request):
|
||||
thislist = ["apple", "banana", "cherry"]
|
||||
return render(request, 'dashboard/home.html',{'thislist': thislist})
|
||||
|
||||
def about(request):
|
||||
thislist = ["apple", "banana", "cherry"]
|
||||
return render(request, 'dashboard/about.html',{'thislist': thislist})
|
||||
|
||||
def success(request):
|
||||
return render(request, 'dashboard/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, 'dashboard/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, 'dashboard/shutdown.html', {'namespace':namespace_name,'deployment': deploy_name, 'url': 'https://namespace.com','baseurl': baseurl})
|
||||
@@ -0,0 +1,40 @@
|
||||
from django.contrib import admin
|
||||
from import_export.admin import ImportExportModelAdmin
|
||||
from import_export import resources
|
||||
from import_export.fields import Field
|
||||
from .models import JobData
|
||||
from django.utils.text import Truncator
|
||||
|
||||
# Register your models here.
|
||||
|
||||
|
||||
class JobResource(resources.ModelResource):
|
||||
# Map 'csv_column_name' from the file to 'model_variable_name' in your DB
|
||||
job_position = Field(attribute='job_position',column_name='Job Position')
|
||||
company = Field(attribute='company',column_name='Company')
|
||||
URL = Field(attribute='URL',column_name='URL')
|
||||
status = Field(attribute='status',column_name='Status')
|
||||
date_saved = Field(attribute='date_saved',column_name='Date Saved')
|
||||
date_applied = Field(attribute='date_applied',column_name='Date Applied')
|
||||
type = Field(attribute='type',column_name='Type')
|
||||
resume = Field(attribute='resume',column_name='Resume')
|
||||
#cover_letter = Field(attribute='cover_letter',column_name='Cover Letter')
|
||||
location = Field(attribute='location',column_name='Location')
|
||||
job_description = Field(attribute='job_description',column_name='Job Description')
|
||||
salary = Field(attribute='salary',column_name='Salary')
|
||||
contact = Field(attribute='contact',column_name='Contact')
|
||||
source = Field(attribute='source',column_name='Source')
|
||||
|
||||
class Meta:
|
||||
model = JobData
|
||||
|
||||
|
||||
|
||||
@admin.register(JobData)
|
||||
class JobAdmin(ImportExportModelAdmin):
|
||||
list_display = ('job_position','company','URL','status','date_saved','date_applied','type','resume','location','short_description','salary','contact','source')
|
||||
#fields = ['job_position','company','URL','status','date_saved','date_applied','type','resume','cover_letter','location','job_description','salary ','contact','source']
|
||||
resource_classes = [JobResource]
|
||||
def short_description(self, obj):
|
||||
return Truncator(obj.job_description).words(10, truncate=' ...')
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
class JobDashboardConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'apps.job_dashboard'
|
||||
label = 'job'
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,36 @@
|
||||
# Generated by Django 4.2.29 on 2026-06-22 20:21
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='JobData',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('job_position', models.CharField(max_length=100, null=True)),
|
||||
('company', models.CharField(max_length=100, null=True)),
|
||||
('URL', models.URLField(max_length=1000, null=True)),
|
||||
('status', models.CharField(choices=[('Rejected', 'Rejected'), ('Applied', 'Applied'), ('Negotiating', 'Negotiating'), ('Bookmarked', 'Bookmarked'), ('Accepted', 'Accepted')], max_length=100, null=True)),
|
||||
('date_saved', models.CharField(max_length=100, null=True)),
|
||||
('date_applied', models.CharField(max_length=100, null=True)),
|
||||
('type', models.CharField(max_length=100, null=True)),
|
||||
('resume', models.URLField(null=True)),
|
||||
('location', models.CharField(max_length=100, null=True)),
|
||||
('job_description', models.CharField(null=True)),
|
||||
('salary', models.CharField(null=True)),
|
||||
('contact', models.CharField(max_length=100, null=True)),
|
||||
('source', models.CharField(max_length=100, null=True)),
|
||||
],
|
||||
options={
|
||||
'db_table': 'job',
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,29 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
status_CHOICES = (
|
||||
('Rejected','Rejected'),
|
||||
('Applied','Applied'),
|
||||
('Negotiating','Negotiating'),
|
||||
('Bookmarked','Bookmarked'),
|
||||
('Accepted','Accepted')
|
||||
)
|
||||
|
||||
class JobData(models.Model):
|
||||
job_position = models.CharField(max_length=100, null=True)
|
||||
company = models.CharField(max_length=100, null=True)
|
||||
URL = models.URLField(max_length=1000,null=True)
|
||||
status = models.CharField(max_length=100,choices=status_CHOICES, null=True)
|
||||
date_saved = models.CharField(max_length=100, null=True)
|
||||
date_applied = models.CharField(max_length=100, null=True)
|
||||
type = models.CharField(max_length=100, null=True)
|
||||
resume = models.URLField(max_length=200, null=True)
|
||||
#cover_letter = models.URLField(max_length=200, null=True)
|
||||
location = models.CharField(max_length=100, null=True)
|
||||
job_description = models.CharField(null=True)
|
||||
salary = models.CharField(null=True)
|
||||
contact = models.CharField(max_length=100, null=True)
|
||||
source = models.CharField(max_length=100, null=True)
|
||||
class Meta:
|
||||
db_table = 'job'
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
"""
|
||||
URL configuration for django_code 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
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('', admin.site.urls),
|
||||
]
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
+23
-14
@@ -14,27 +14,35 @@ 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='/code/kubeconfig')
|
||||
def echoHello():
|
||||
print("hello from k8s")
|
||||
return "returned from k8s"
|
||||
|
||||
def scale_up(request,namespace_name,deploy_name,replicas=1):
|
||||
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 = 2
|
||||
deployment.spec.replicas = replicas
|
||||
resp = api.patch_namespaced_deployment(
|
||||
name=deploy_name, namespace=namespace_name, body=deployment);
|
||||
return HttpResponse('<h1>Scaled up !</h1>')
|
||||
#return HttpResponse('<h1>Scaled up !</h1>')
|
||||
return render(request, 'dashboard/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='/code/kubeconfig')
|
||||
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 HttpResponse('<h1>Scaled down !</h1>')
|
||||
return render(request, 'dashboard/shutdown.html',
|
||||
{'namespace': namespace_name, 'deployment': deploy_name, 'url': 'https://namespace.com'})
|
||||
|
||||
def nodes(request):
|
||||
config.load_kube_config(config_file='/code/kubeconfig')
|
||||
@@ -111,15 +119,16 @@ def backup_job(request):
|
||||
#help with yaml import
|
||||
#https://github.com/kubernetes-client/python/issues/589
|
||||
|
||||
def backup_job_yaml(request):
|
||||
def backup_job_yaml(request,sync_target):
|
||||
config.load_kube_config(config_file='/code/kubeconfig')
|
||||
v1 = client.BatchV1Api()
|
||||
|
||||
with urllib.request.urlopen(https://gitea.tryton.geeraert.eu/pi-ux-ce/Backup_kube/raw/branch/main/Infrequent_access/pod.yaml") as manifest_url:
|
||||
yaml_location = {
|
||||
"synology" : "https://gitea.tryton.geeraert.eu/pi-ux-ce/Backup_kube/raw/branch/main/Infrequent_access/synology_pod.yaml",
|
||||
"openmediavault":"https://gitea.tryton.geeraert.eu/pi-ux-ce/Backup_kube/raw/branch/main/Infrequent_access/openmediavault_pod.yaml"
|
||||
}
|
||||
print(yaml_location[sync_target])
|
||||
url_to_select=yaml_location[sync_target]
|
||||
api_response = v1.create_namespaced_job(body=pod_manifest_job)
|
||||
|
||||
# with open('/code/pod.yaml') as :
|
||||
job = yaml.safe_load(manifest_url)
|
||||
v1.create_namespaced_job(
|
||||
job['metadata']['namespace'], job, pretty=True
|
||||
)
|
||||
return HttpResponse(job['metadata']['namespace'])
|
||||
return HttpResponse(api_response)
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,57 @@
|
||||
from kubernetes import client, config
|
||||
|
||||
|
||||
def scale_up(namespace_name,deploy_name,replicas=1):
|
||||
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 = replicas
|
||||
resp = api.patch_namespaced_deployment(
|
||||
name=deploy_name, namespace=namespace_name, body=deployment);
|
||||
return 0
|
||||
|
||||
def scale_down(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 0
|
||||
|
||||
def import_Deployments():
|
||||
config.load_kube_config(config_file='/kubeconfig/config')
|
||||
api = client.AppsV1Api()
|
||||
deployment = api.list_deployment_for_all_namespaces()
|
||||
for i in range(1,len(deployment.items)):
|
||||
print(deployment.items[i].spec.template.spec.containers[0].name)
|
||||
|
||||
len(deployment.items) #list all deployment inside the namespace
|
||||
test.items[0].spec.template.spec.containers[0].name # name the first deploy within the namespace
|
||||
test.items[2].spec.template.spec.containers[0].name # name the third deploy within the namespace
|
||||
return 0
|
||||
|
||||
def get_namespace():
|
||||
config.load_kube_config(config_file='/kubeconfig/config')
|
||||
core = client.CoreV1Api()
|
||||
namespace = core.list_namespace()
|
||||
namespace_list = []
|
||||
for i in range(0,len(namespace.items)):
|
||||
print(namespace.items[i].metadata.name)
|
||||
namespace_list.append(namespace.items[i].metadata.name)
|
||||
return namespace_list
|
||||
|
||||
def get_deployments():
|
||||
config.load_kube_config(config_file='/kubeconfig/config')
|
||||
api = client.AppsV1Api()
|
||||
namespaces_list = get_namespace()
|
||||
deployments_list = []
|
||||
for namespace in namespaces_list:
|
||||
print(namespace)
|
||||
deployments = api.list_namespaced_deployment(namespace)
|
||||
for deployment_index in range(0,len(deployments.items)):
|
||||
deployment = deployments.items[deployment_index].metadata.name
|
||||
print(" "+str(deployment))
|
||||
deployments_list.append([namespace,deployment])
|
||||
return deployments_list
|
||||
@@ -0,0 +1,75 @@
|
||||
from django.contrib import admin,messages
|
||||
from django.utils.translation import ngettext
|
||||
from prompt_toolkit.shortcuts import print_container
|
||||
from .models import SimpsonsData,simpsons_data_object
|
||||
from .utils import mark_episode_watched,unwatch_all_episodes
|
||||
from import_export import resources
|
||||
from import_export.admin import ImportExportModelAdmin
|
||||
# Register your models here.
|
||||
|
||||
DB = 'simpsons_db'
|
||||
|
||||
@admin.action(description="Mark episode as seen")
|
||||
def make_seen(modeladmin, request, queryset):
|
||||
updated = queryset.update(seen="True")
|
||||
|
||||
for query in queryset.values():
|
||||
print(query)
|
||||
season_number = query.get('season')
|
||||
episode_number = query.get('episode')
|
||||
mark_episode_watched(season_number,episode_number,"watched")
|
||||
|
||||
modeladmin.message_user(
|
||||
request,
|
||||
ngettext(
|
||||
"%d episode was successfully marked as seen.",
|
||||
"%d episodes were successfully marked as seen.",
|
||||
updated,
|
||||
)
|
||||
% updated,
|
||||
messages.SUCCESS,
|
||||
)
|
||||
|
||||
@admin.action(description="Mark episode as not seen")
|
||||
def make_unseen(modeladmin, request, queryset):
|
||||
updated = queryset.update(seen="False")
|
||||
for query in queryset.values():
|
||||
print(query)
|
||||
season_number = query.get('season')
|
||||
episode_number = query.get('episode')
|
||||
mark_episode_watched(season_number,episode_number,"unwatched")
|
||||
|
||||
modeladmin.message_user(
|
||||
request,
|
||||
ngettext(
|
||||
"%d episode was successfully marked as not seen.",
|
||||
"%d episodes were successfully marked as not seen.",
|
||||
updated,
|
||||
)
|
||||
% updated,
|
||||
messages.SUCCESS,
|
||||
)
|
||||
|
||||
@admin.action(description="mark all of them as unseen on betaserie")
|
||||
def unseen_betaserie(modeladmin, request, queryset):
|
||||
unwatch_all_episodes()
|
||||
|
||||
|
||||
@admin.register(SimpsonsData)
|
||||
class EpisodeAdmin(ImportExportModelAdmin):
|
||||
list_display = [field.name for field in SimpsonsData._meta.fields if field.name != 'id']
|
||||
list_filter = ['seen']
|
||||
fields = ['season', 'episode', 'url', 'seen']
|
||||
actions = [make_seen,make_unseen,unseen_betaserie]
|
||||
|
||||
def get_queryset(self, request):
|
||||
return super().get_queryset(request).using(DB)
|
||||
|
||||
def save_model(self, request, obj, form, change):
|
||||
obj.save(using=DB)
|
||||
|
||||
def delete_model(self, request, obj):
|
||||
obj.delete(using=DB)
|
||||
|
||||
def delete_queryset(self, request, queryset):
|
||||
queryset.using(DB).delete()
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
class RandomSimpsonsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'apps.random_simpsons'
|
||||
label = 'simpsons'
|
||||
@@ -0,0 +1,27 @@
|
||||
# Generated by Django 4.2.29 on 2026-06-22 20:21
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SimpsonsData',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('season', models.IntegerField()),
|
||||
('episode', models.IntegerField()),
|
||||
('url', models.CharField(max_length=1000)),
|
||||
('seen', models.BooleanField()),
|
||||
],
|
||||
options={
|
||||
'db_table': 'episodes',
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,12 @@
|
||||
from django.db import models
|
||||
|
||||
class SimpsonsData(models.Model):
|
||||
season = models.IntegerField()
|
||||
episode = models.IntegerField()
|
||||
url = models.CharField(max_length=1000)
|
||||
seen = models.BooleanField()
|
||||
|
||||
class Meta:
|
||||
db_table = 'episodes'
|
||||
|
||||
simpsons_data_object = SimpsonsData.objects.using('simpsons_db')
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,37 @@
|
||||
from apps.betaserie.utils import betaserieUtils
|
||||
from django.db.models import Count
|
||||
from celery.worker.state import active_requests
|
||||
from requests.compat import str
|
||||
from .models import simpsons_data_object
|
||||
|
||||
betaserie = betaserieUtils()
|
||||
|
||||
simpsons_id = 12
|
||||
|
||||
def mark_episode_watched(season,episode,action):
|
||||
|
||||
print("season_number: "+str(season))
|
||||
print("episode_number: "+str(episode))
|
||||
|
||||
episode_number = "S"+str(season)+"E"+str(episode)
|
||||
|
||||
episode_id = betaserie.identify_episode(simpsons_id,episode_number)
|
||||
|
||||
if action == "watched":
|
||||
betaserie.mark_episodes_watched(episode_id)
|
||||
elif action == "unwatched":
|
||||
betaserie.unmark_episodes_watched(episode_id)
|
||||
else:
|
||||
print("Parameter action not in range")
|
||||
|
||||
|
||||
|
||||
def unwatch_all_episodes():
|
||||
maximum_number_of_seasons = simpsons_data_object.aggregate(unique_season=Count('season', distinct=True))['unique_season']
|
||||
print("maximum_number_of_seasons: "+str(maximum_number_of_seasons))
|
||||
for season in range(1,maximum_number_of_seasons+1):
|
||||
maximum_number_of_episodes = simpsons_data_object.filter(season=season).count()
|
||||
print("maximum_number_of_episodes for "+str(season)+": "+str(maximum_number_of_episodes))
|
||||
for episode in range(1,maximum_number_of_episodes+1):
|
||||
print("S"+str(season)+"E"+str(episode))
|
||||
mark_episode_watched(season,episode,"unwatched")
|
||||
@@ -0,0 +1,67 @@
|
||||
from django.http import HttpResponse
|
||||
from django.db.models import Count
|
||||
from django.shortcuts import redirect
|
||||
from .models import SimpsonsData,simpsons_data_object
|
||||
from .utils import mark_episode_watched
|
||||
import random
|
||||
|
||||
|
||||
def hello(request):
|
||||
return HttpResponse('<h1>Hello Simpsons view!</h1>')
|
||||
|
||||
def episode_generator(request):
|
||||
#simpsons_data_object = SimpsonsData.objects.using('simpsons_db')
|
||||
|
||||
boolean_restart = True;
|
||||
while (boolean_restart):
|
||||
maximum_number_of_seasons = simpsons_data_object.aggregate(unique_season=Count('season', distinct=True))['unique_season']
|
||||
|
||||
random_seasons = random.randint(1, maximum_number_of_seasons)
|
||||
print("random season: " + str(random_seasons))
|
||||
|
||||
maximum_number_of_episodes = simpsons_data_object.filter(season=random_seasons).count()
|
||||
|
||||
random_episode = random.randint(1, maximum_number_of_episodes)
|
||||
print("random episode: " + str(random_episode))
|
||||
|
||||
episode_seen = simpsons_data_object.filter(season=random_seasons, episode=random_episode).values('seen')[0]['seen']
|
||||
|
||||
if not(episode_seen):
|
||||
boolean_restart = False
|
||||
else:
|
||||
print("episode "+str(random_episode)+" from season "+str(random_seasons)+" already seen")
|
||||
|
||||
random_url = simpsons_data_object.filter(season=random_seasons, episode=random_episode).values('url')[0]['url']
|
||||
|
||||
#Set episode as seen
|
||||
# It will still update an already seem episode but it works and I'm lazy
|
||||
|
||||
simpsons_data_object.filter(season=random_seasons, episode=random_episode).values('seen').update(seen=True)
|
||||
|
||||
#Mark episode as seen on betaseries
|
||||
mark_episode_watched(random_seasons,random_episode,"watched")
|
||||
|
||||
return redirect(str(random_url))
|
||||
|
||||
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
|
||||
|
||||
@@ -0,0 +1,276 @@
|
||||
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 celery import shared_task
|
||||
|
||||
from lxml import html
|
||||
import requests
|
||||
import os
|
||||
import json
|
||||
import time
|
||||
import random
|
||||
import mimetypes
|
||||
import ruamel.yaml
|
||||
import yaml
|
||||
from urllib import request as urlrequest
|
||||
from urllib import parse as urlparse
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
proxy_url = 'http://gluetun-svc.gluetun.svc:8888'
|
||||
proxy = urlrequest.ProxyHandler({
|
||||
'http': proxy_url,
|
||||
'https': proxy_url # Add the handler for HTTPS
|
||||
})
|
||||
|
||||
proxies = {
|
||||
"http" : proxy_url,
|
||||
"https" : proxy_url
|
||||
}
|
||||
|
||||
destination_folder = "/stash/"
|
||||
|
||||
def hello(request):
|
||||
return HttpResponse('<h1>Hello stash!</h1>')
|
||||
def form(request):
|
||||
return render(request, 'stash/stash_form.html',{})
|
||||
def album(request):
|
||||
return render(request, 'stash/album_form.html',{})
|
||||
def simple(request):
|
||||
return render(request, 'stash/simple_form.html',{})
|
||||
def check_and_create_destination_folder(name):
|
||||
#check if the output directory exist and create if not
|
||||
if not os.path.isdir(destination_folder):
|
||||
os.makedirs(destination_folder)
|
||||
|
||||
#check if the named directory exist and create if not
|
||||
destination_named_folder = os.path.join(destination_folder,name)
|
||||
if not os.path.isdir(destination_named_folder):
|
||||
os.makedirs(destination_named_folder)
|
||||
|
||||
return destination_named_folder
|
||||
|
||||
def album_form(request):
|
||||
name = request.GET.get('name')
|
||||
url = request.GET.get('url')
|
||||
external_galleries = request.GET.get('external_galleries')
|
||||
|
||||
album_downloader.delay(name=name,url=url,external_galleries=external_galleries)
|
||||
|
||||
text_generated = "successfully sent to the album downloader"
|
||||
return HttpResponse(text_generated, content_type="text/plain")
|
||||
|
||||
@shared_task()
|
||||
def album_downloader(name,url,external_galleries):
|
||||
print(name+" "+url+" "+external_galleries)
|
||||
|
||||
opener = urlrequest.build_opener(proxy)
|
||||
urlrequest.install_opener(opener)
|
||||
|
||||
req = urlrequest.Request(url)
|
||||
urlcurl = urlrequest.urlopen(req).read()
|
||||
|
||||
page = requests.get(url,proxies=proxies)
|
||||
webpage = html.fromstring(page.content)
|
||||
|
||||
#create the prerequisites folder
|
||||
destination_named_folder = check_and_create_destination_folder(name=name)
|
||||
|
||||
|
||||
#get all URLs from the code source (searching for href tag on the code)
|
||||
#https://stackoverflow.com/questions/21455349/xpath-query-get-attribute-href-from-a-tag
|
||||
|
||||
webpage_all_url = webpage.xpath('//a/@href')
|
||||
|
||||
#search for the href that contains the galleries
|
||||
webpage_all_album_url = webpage.xpath("//a[contains(@href,'pornpics.com/galleries/')]/@href")
|
||||
#print(webpage_all_album_url[3])
|
||||
#print(webpage_all_album_url)
|
||||
|
||||
|
||||
for album in webpage_all_album_url:
|
||||
print("Album "+album)
|
||||
print("")
|
||||
page = requests.get(album,proxies=proxies)
|
||||
webpage = html.fromstring(page.content)
|
||||
|
||||
images_list = webpage.xpath("//a[contains(@href,'cdni.pornpics.com/1280/')]/@href")
|
||||
images_downloader.delay(name=name,images_url_list=images_list,destination_named_folder=destination_named_folder)
|
||||
print(images_list)
|
||||
return 0
|
||||
|
||||
@shared_task()
|
||||
def images_downloader(name,images_url_list,destination_named_folder):
|
||||
for image_url in images_url_list:
|
||||
split = urlparse.urlsplit(image_url)
|
||||
#filename = destination_folder + split.path.split("/")[-1]
|
||||
filename = os.path.join(destination_named_folder,split.path.split("/")[-1])
|
||||
|
||||
|
||||
print("downloading: "+filename+" -- "+image_url)
|
||||
|
||||
opener = urlrequest.build_opener(proxy)
|
||||
|
||||
urlrequest.install_opener(opener)
|
||||
try:
|
||||
urlrequest.urlretrieve(image_url, filename )
|
||||
except:
|
||||
print("Can't download "+filename+" -- "+image_url)
|
||||
individual_image_downloader.delay(image_url=image_url, filename=filename)
|
||||
|
||||
return 0
|
||||
|
||||
@shared_task()
|
||||
def individual_image_downloader(image_url, filename ):
|
||||
print("Downloading again: "+filename+" -- "+image_url)
|
||||
|
||||
opener = urlrequest.build_opener(proxy)
|
||||
|
||||
urlrequest.install_opener(opener)
|
||||
try:
|
||||
urlrequest.urlretrieve(image_url, filename )
|
||||
except:
|
||||
print("Still Can't download "+filename+" -- "+image_url+" == Cancelling")
|
||||
return 0
|
||||
|
||||
def simple_form(request):
|
||||
name = request.GET.get('name')
|
||||
reddit_downloader(username=name)
|
||||
|
||||
text_generated = "successfully sent to the reddit downloader"
|
||||
return HttpResponse(text_generated, content_type="text/plain")
|
||||
|
||||
def reddit_downloader(username):
|
||||
|
||||
#create the prerequisites folder
|
||||
destination_named_folder = check_and_create_destination_folder(name=username)
|
||||
|
||||
|
||||
|
||||
url = "https://www.reddit.com/user/"+username+"/submitted/.json?limit=1000"
|
||||
opener = urlrequest.build_opener(proxy)
|
||||
urlrequest.install_opener(opener)
|
||||
|
||||
req = urlrequest.Request(url)
|
||||
urlcurl = urlrequest.urlopen(req).read()
|
||||
data = json.loads(urlcurl)
|
||||
|
||||
picture_list=[]
|
||||
for children in data['data']['children']:
|
||||
print("adding to the list : "+children['data']['url'])
|
||||
picture_list.append(children['data']['url'])
|
||||
|
||||
images_downloader.delay(name=username,images_url_list=picture_list,destination_named_folder=destination_named_folder)
|
||||
|
||||
return 0
|
||||
|
||||
def redgif_donloader(username):
|
||||
#on te front page of the user , https://www.redgifs.com/users/princesspizookie
|
||||
# F12 and search network , find something that start as api.redgifs.com
|
||||
# and the file is search?order=new&count=40&type=g
|
||||
# copy as curl and you got the bearer
|
||||
|
||||
#curl curl 'https://api.redgifs.com/v2/users/princesspizookie/search?order=new&count=40&type=g'
|
||||
#and you get the URLS , needs to be parsedw
|
||||
return 0
|
||||
def incremental(request):
|
||||
return render(request, 'stash/incremental_form.html',{})
|
||||
|
||||
def incremental_form(request):
|
||||
name = request.GET.get('name')
|
||||
url = request.GET.get('url')
|
||||
url_suffix = request.GET.get('url_suffix')
|
||||
maximum_increment = int(request.GET.get('maximum_increment'))
|
||||
minimum_increment = request.GET.get('minimum_increment')
|
||||
|
||||
increment_and_download.delay(minimum_increment=minimum_increment,maximum_increment=maximum_increment,url=url,url_suffix=url_suffix,name=name)
|
||||
|
||||
text_generated = "successfully sent to celery"
|
||||
return HttpResponse(text_generated, content_type="text/plain")
|
||||
|
||||
@shared_task()
|
||||
def increment_and_download(minimum_increment,maximum_increment,url,url_suffix,name):
|
||||
if minimum_increment == None:
|
||||
minimum_increment = 1
|
||||
|
||||
text_generated = ""
|
||||
minimum_increment = int(minimum_increment)
|
||||
maximum_increment = int(maximum_increment)
|
||||
|
||||
#check if the output directory exist and create if not
|
||||
if not os.path.isdir(destination_folder):
|
||||
os.makedirs(destination_folder)
|
||||
|
||||
#check if the named directory exist and create if not
|
||||
destination_named_folder = os.path.join(destination_folder,name)
|
||||
if not os.path.isdir(destination_named_folder):
|
||||
os.makedirs(destination_named_folder)
|
||||
|
||||
print("\n downloading for "+name+" "+url+"XXX"+url_suffix)
|
||||
|
||||
for increment in range(minimum_increment,maximum_increment):
|
||||
print("increment : "+str(increment)+"/"+str(maximum_increment))
|
||||
if len(str(increment)) == 3:
|
||||
increment_generated ='0' + str(increment)
|
||||
elif len(str(increment)) == 2:
|
||||
increment_generated ='00' + str(increment)
|
||||
elif len(str(increment)) == 1:
|
||||
increment_generated ='000' + str(increment)
|
||||
|
||||
url_generated = url+increment_generated+url_suffix
|
||||
print(url_generated)
|
||||
destination_filename = increment_generated+url_suffix
|
||||
destination_file = os.path.join(destination_named_folder,destination_filename)
|
||||
print(destination_file)
|
||||
opener = urlrequest.build_opener(proxy)
|
||||
urlrequest.install_opener(opener)
|
||||
urlrequest.urlretrieve(url_generated, destination_file )
|
||||
|
||||
text_generated = "\n downloading for "+name+" "+url+increment_generated+url_suffix
|
||||
print("download completed for "+name+" of "+str(maximum_increment)+" images")
|
||||
return text_generated
|
||||
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 = str(request.GET.get('external_galleries'))
|
||||
|
||||
stash_folder = "/stash"
|
||||
|
||||
if external_galleries:
|
||||
print("external_galleries is not null")
|
||||
performer_external_galleries = stash_folder+"/"+name+"_external_galleries.txt"
|
||||
with open(performer_external_galleries, "a") as f:
|
||||
f.write(external_galleries)
|
||||
skip_searching_gallery = True
|
||||
else:
|
||||
print("external_galleries is null")
|
||||
skip_searching_gallery = False
|
||||
|
||||
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]
|
||||
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,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -5,4 +5,8 @@ from django.http import HttpResponse
|
||||
from django.shortcuts import render
|
||||
|
||||
def hello(request):
|
||||
return HttpResponse('<h1>Hello Django!</h1>')
|
||||
return HttpResponse('<h1>Hello stash!</h1>')
|
||||
|
||||
|
||||
def home(request):
|
||||
return render(request, 'stash/listing.html')
|
||||
@@ -0,0 +1,9 @@
|
||||
from django.contrib import admin
|
||||
from .models import redirectData
|
||||
from import_export.admin import ImportExportModelAdmin
|
||||
|
||||
# Register your models here.
|
||||
@admin.register(redirectData)
|
||||
class redirectAdmin(ImportExportModelAdmin):
|
||||
list_display = [field.name for field in redirectData._meta.fields if field.name != 'id']
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import redis
|
||||
from django.http import HttpResponse
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import render
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class redirectConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'apps.website_redirection'
|
||||
label = 'redirect'
|
||||
@@ -0,0 +1,26 @@
|
||||
# Generated by Django 4.2.29 on 2026-06-22 20:21
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='redirectData',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('url', models.CharField(max_length=1000)),
|
||||
('addedDate', models.DateField(blank=True, null=True, verbose_name='Published')),
|
||||
('seenDate', models.DateField(blank=True, null=True, verbose_name='Published')),
|
||||
],
|
||||
options={
|
||||
'db_table': 'redirect',
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,9 @@
|
||||
from django.db import models
|
||||
|
||||
class redirectData(models.Model):
|
||||
url = models.CharField(max_length=1000)
|
||||
addedDate = models.DateField('Published', blank=True, null=True, auto_now_add=True)
|
||||
seenDate = models.DateField('Published', blank=True, null=True)
|
||||
|
||||
class Meta:
|
||||
db_table = 'redirect'
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,35 @@
|
||||
"""
|
||||
URL configuration for django_code 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 apps.website_redirection import views as website_redirectionapp
|
||||
|
||||
urlpatterns = [
|
||||
# path('admin/', admin.site.urls),
|
||||
|
||||
################### Redirect ###################
|
||||
path('', website_redirectionapp.redirect),
|
||||
path('hello/', website_redirectionapp.hello),
|
||||
path('set/', website_redirectionapp.redirect),
|
||||
path('get/<str:key>', website_redirectionapp.display_key),
|
||||
path('go/<str:key>', website_redirectionapp.redirect_to_key),
|
||||
path('redirect-form/', website_redirectionapp.redirect_process, name='submit_form'),
|
||||
path('clearkey/', website_redirectionapp.clearkey_process, name='submit_form'),
|
||||
|
||||
|
||||
|
||||
]
|
||||
@@ -0,0 +1,61 @@
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.apps import AppConfig
|
||||
from .models import redirectData
|
||||
import redis
|
||||
|
||||
|
||||
def hello(request):
|
||||
return HttpResponse('<h1>Hello Django!</h1>')
|
||||
|
||||
|
||||
|
||||
r = redis.Redis(
|
||||
host='django-redis-svc',
|
||||
port=6379,
|
||||
db=0 # The default Redis database index
|
||||
)
|
||||
|
||||
def hello(request):
|
||||
return HttpResponse('<h1>Hello redirect!</h1>')
|
||||
|
||||
|
||||
def redirect(request):
|
||||
return render(request, 'website_redirection/redirect_form.html',{})
|
||||
|
||||
def clearkey_process(request):
|
||||
key = request.GET.get('key')
|
||||
r.delete(key)
|
||||
return 0
|
||||
|
||||
def redirect_process(request):
|
||||
key = request.GET.get('key')
|
||||
value = request.GET.get('value')
|
||||
key = key.lower()
|
||||
|
||||
r.set(key, value)
|
||||
redirectData.objects.create(url=value)
|
||||
text_generated = "successfully set "+value+" to "+key
|
||||
return HttpResponse(text_generated, content_type="text/plain")
|
||||
|
||||
def display_key(request,key):
|
||||
value = r.get(key)
|
||||
value_extracted = str(value.decode())
|
||||
text_generated = key+" is set to "+value_extracted
|
||||
return HttpResponse(text_generated, content_type="text/plain")
|
||||
|
||||
|
||||
def redirect_to_key(request,key):
|
||||
value = r.get(key)
|
||||
if value == None:
|
||||
icon_url = r.get('icon')
|
||||
if icon_url == None:
|
||||
icon_url = "https://cdn-icons-png.flaticon.com/512/6402/6402576.png"
|
||||
print(key+" is not setup, displaying default page")
|
||||
return render(request, 'website_redirection/blank_page.html', {'title': key,'icon_url':icon_url})
|
||||
else:
|
||||
value_extracted = str(value.decode('utf-8'))
|
||||
print(key+" is setup to : "+value_extracted)
|
||||
print(value_extracted)
|
||||
return HttpResponseRedirect(value_extracted)
|
||||
@@ -0,0 +1,3 @@
|
||||
from .celery_settings import app as celery_app
|
||||
|
||||
__all__ = ("celery_app",)
|
||||
@@ -11,6 +11,6 @@ import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_code.settings')
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
|
||||
|
||||
application = get_asgi_application()
|
||||
@@ -0,0 +1,8 @@
|
||||
import os
|
||||
from celery import Celery
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
|
||||
|
||||
app = Celery("core")
|
||||
app.config_from_object("django.conf:settings", namespace="CELERY")
|
||||
app.autodiscover_tasks()
|
||||
@@ -0,0 +1,10 @@
|
||||
from django.conf import settings
|
||||
from django_hosts import patterns, host
|
||||
|
||||
host_patterns = patterns('',
|
||||
host(r"django-testing", settings.ROOT_URLCONF, name="django-testing"),
|
||||
host(r"redirect", 'apps.website_redirection.urls', name="redirect"),
|
||||
host(r"redirect-testing", 'apps.website_redirection.urls', name="redirect-testing"),
|
||||
host(r"job", 'apps.job_dashboard.urls', name="job_dashboard"),
|
||||
host(r"job-testing", 'apps.job_dashboard.urls', name="job_dashboard-testing"),
|
||||
)
|
||||
@@ -0,0 +1,57 @@
|
||||
# routers.py
|
||||
|
||||
class ProjectDatabaseRouter:
|
||||
"""
|
||||
A router to control all database operations on models in the
|
||||
simpsons and cloudmanager applications.
|
||||
"""
|
||||
|
||||
def db_for_read(self, model, **hints):
|
||||
"""Attempts to read simpsons and cloudmanager models go to their specific dbs."""
|
||||
if model._meta.app_label == 'simpsons':
|
||||
return 'simpsons_db'
|
||||
if model._meta.app_label == 'job':
|
||||
return 'job_db'
|
||||
if model._meta.app_label == 'redirect':
|
||||
return 'redirect_db'
|
||||
if model._meta.app_label == 'cloudmanager':
|
||||
return 'cloudmanager_db'
|
||||
return 'default'
|
||||
|
||||
def db_for_write(self, model, **hints):
|
||||
"""Attempts to write simpsons and cloudmanager models go to their specific dbs."""
|
||||
if model._meta.app_label == 'simpsons':
|
||||
return 'simpsons_db'
|
||||
if model._meta.app_label == 'job':
|
||||
return 'job_db'
|
||||
if model._meta.app_label == 'cloudmanager':
|
||||
return 'cloudmanager_db'
|
||||
if model._meta.app_label == 'redirect':
|
||||
return 'redirect_db'
|
||||
return 'default'
|
||||
|
||||
def allow_relation(self, obj1, obj2, **hints):
|
||||
"""Allow relations if both models are in the same database."""
|
||||
# Prevents accidental foreign key relationships across different physical DBs
|
||||
if (
|
||||
obj1._meta.app_label in ['simpsons', 'cloudmanager','redirect','job'] or
|
||||
obj2._meta.app_label in ['simpsons', 'cloudmanager','redirect','job']
|
||||
):
|
||||
return obj1._meta.app_label == obj2._meta.app_label
|
||||
return None
|
||||
|
||||
def allow_migrate(self, db, app_label, model_name=None, **hints):
|
||||
"""Ensure the app's models only show up in the designated database."""
|
||||
if app_label == 'simpsons':
|
||||
return db == 'simpsons_db'
|
||||
if app_label == 'job':
|
||||
return db == 'job_db'
|
||||
if app_label == 'cloudmanager':
|
||||
return db == 'cloudmanager_db'
|
||||
if app_label == 'redirect':
|
||||
return 'redirect_db'
|
||||
# Ensure default Django apps (auth, sessions, etc.) don't migrate into simpsons/cloudmanager
|
||||
if db in ['simpsons_db', 'cloudmanager_db','redirect_db','job_db']:
|
||||
return False
|
||||
|
||||
return None
|
||||
@@ -9,7 +9,7 @@ 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/
|
||||
"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
@@ -23,10 +23,14 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
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!
|
||||
DEBUG = True
|
||||
#DEBUG = os.getenv("DEBUG")
|
||||
DEBUG = os.getenv("DEBUG", "False").lower() in ("true", "1", "t")
|
||||
|
||||
ALLOWED_HOSTS = ['reverse.tryton.geeraert.eu','192.168.4.100','django.tryton.geeraert.eu','localhost']
|
||||
|
||||
ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS").split(",")
|
||||
CSRF_TRUSTED_ORIGINS=[]
|
||||
for ALLOWED_HOST in os.getenv("ALLOWED_HOSTS").split(","):
|
||||
CSRF_TRUSTED_ORIGINS.append("https://"+str(ALLOWED_HOST))
|
||||
|
||||
# Application definition
|
||||
|
||||
@@ -38,9 +42,16 @@ INSTALLED_APPS = [
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'bootstrap5',
|
||||
'django_hosts',
|
||||
'apps.cloudmanager.apps.CloudmanagerConfig',
|
||||
'apps.random_simpsons.apps.RandomSimpsonsConfig',
|
||||
'apps.website_redirection.apps.redirectConfig',
|
||||
'apps.job_dashboard.apps.JobDashboardConfig',
|
||||
'import_export',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django_hosts.middleware.HostsRequestMiddleware',
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
@@ -48,15 +59,21 @@ MIDDLEWARE = [
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'django_hosts.middleware.HostsResponseMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'django_code.urls'
|
||||
ROOT_URLCONF = 'core.urls'
|
||||
ROOT_HOSTCONF = 'core.hosts'
|
||||
DEFAULT_HOST = 'django-testing'
|
||||
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
#'DIRS': ["/code/django_code/templates","/code/django_code/dashboard/templates/"],
|
||||
'DIRS': [BASE_DIR / "templates","django_code/dashboard/templates/"],
|
||||
#'DIRS': ["/code/core/templates","/code/core/dashboard/templates/"],
|
||||
'DIRS': [
|
||||
BASE_DIR / "templates"
|
||||
],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
@@ -69,7 +86,7 @@ TEMPLATES = [
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'django_code.wsgi.application'
|
||||
WSGI_APPLICATION = 'core.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
@@ -77,11 +94,48 @@ WSGI_APPLICATION = 'django_code.wsgi.application'
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR / 'db.sqlite3',
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'django',
|
||||
'USER': os.environ.get('DB_USERNAME'),
|
||||
'PASSWORD': os.environ.get('DB_PASSWORD'),
|
||||
'HOST': os.environ.get('DB_HOST'),
|
||||
'PORT': os.environ.get('DB_PORT'),
|
||||
},
|
||||
'cloudmanager_db': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'cloudmanager',
|
||||
'USER': os.environ.get('DB_USERNAME'),
|
||||
'PASSWORD': os.environ.get('DB_PASSWORD'),
|
||||
'HOST': os.environ.get('DB_HOST'),
|
||||
'PORT': os.environ.get('DB_PORT'),
|
||||
},
|
||||
'simpsons_db': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'simpsons',
|
||||
'USER': os.environ.get('DB_USERNAME'),
|
||||
'PASSWORD': os.environ.get('DB_PASSWORD'),
|
||||
'HOST': os.environ.get('DB_HOST'),
|
||||
'PORT': os.environ.get('DB_PORT'),
|
||||
},
|
||||
'redirect_db': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'redirect',
|
||||
'USER': os.environ.get('DB_USERNAME'),
|
||||
'PASSWORD': os.environ.get('DB_PASSWORD'),
|
||||
'HOST': os.environ.get('DB_HOST'),
|
||||
'PORT': os.environ.get('DB_PORT'),
|
||||
},
|
||||
'job_db': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'job',
|
||||
'USER': os.environ.get('DB_USERNAME'),
|
||||
'PASSWORD': os.environ.get('DB_PASSWORD'),
|
||||
'HOST': os.environ.get('DB_HOST'),
|
||||
'PORT': os.environ.get('DB_PORT'),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
DATABASE_ROUTERS = ['core.routers.ProjectDatabaseRouter']
|
||||
#DATABASE_ROUTERS = []
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
||||
@@ -117,10 +171,27 @@ USE_TZ = True
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
STATICFILES_DIRS = [
|
||||
BASE_DIR / "templates/cloudmanager/css",
|
||||
BASE_DIR / "templates/cloudmanager/fonts",
|
||||
BASE_DIR / "templates/cloudmanager/images",
|
||||
BASE_DIR / "templates/cloudmanager/js"
|
||||
]
|
||||
|
||||
STATIC_ROOT = BASE_DIR / "templates/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'
|
||||
#
|
||||
# Celery settings
|
||||
CELERY_BROKER_URL = "redis://django-redis-svc:6379"
|
||||
CELERY_RESULT_BACKEND = "redis://django-redis-svc:6379"
|
||||
|
||||
CELERY_IMPORTS = [
|
||||
'apps.stash_management.apps', # This line imports the tasks.py file
|
||||
# Add other app tasks here if needed
|
||||
]
|
||||
@@ -0,0 +1,92 @@
|
||||
"""
|
||||
URL configuration for django_code 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 apps.cloudmanager import (credentials,db_interaction)
|
||||
from apps.cloudmanager import apps as cloudmanager_apps
|
||||
from apps.cloudmanager import views as cloudmanager_views
|
||||
from apps.random_simpsons import views as random_simpsons
|
||||
from apps.dashboard import apps as dashboardapp
|
||||
from apps.dashboard import views as dashboardview
|
||||
from apps.kubernetes_connection import apps as kubernetes_connection
|
||||
from apps.stash_management import apps as stashapp
|
||||
from apps.stash_management import views as stashview
|
||||
from apps.website_redirection import views as website_redirectionapp
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
|
||||
################### Simpsons ###################
|
||||
path('hello/', random_simpsons.hello),
|
||||
path('simpsons/', random_simpsons.episode_generator),
|
||||
path('download_file/', random_simpsons.download_file),
|
||||
|
||||
################### Redirect ###################
|
||||
path('redirect/hello/', website_redirectionapp.hello),
|
||||
path('redirect/set/', website_redirectionapp.redirect),
|
||||
path('redirect/get/<str:key>', website_redirectionapp.display_key),
|
||||
path('redirect/go/<str:key>', website_redirectionapp.redirect_to_key),
|
||||
path('redirect/redirect-form/', website_redirectionapp.redirect_process, name='submit_form'),
|
||||
path('redirect/clearkey/', website_redirectionapp.clearkey_process, name='submit_form'),
|
||||
|
||||
################### 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),
|
||||
|
||||
################## stash#####
|
||||
path('stash/', stashview.home),
|
||||
path('stash/hello/', stashapp.hello),
|
||||
path('stash/form/', stashapp.form),
|
||||
path('stash/incremental/', stashapp.incremental),
|
||||
path('stash/album/', stashapp.album),
|
||||
path('stash/album-form/', stashapp.album_form, name='submit_form'),
|
||||
path('stash/simple/', stashapp.simple),
|
||||
path('stash/simple-form/', stashapp.simple_form, name='submit_form'),
|
||||
path('stash/submit-form/', stashapp.handle_survey_form, name='submit_form'),
|
||||
path('stash/incremental-form/', stashapp.incremental_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),
|
||||
|
||||
################### cloudmanager ###################
|
||||
path('cmm/', cloudmanager_apps.redirect),
|
||||
path('cmm/hello', cloudmanager_apps.hello, name='hello'),
|
||||
path('cmm/coucou', cloudmanager_views.coucou, name='coucou'),
|
||||
path('cmm/display', cloudmanager_views.display, name='display'),
|
||||
#path('cmm/run-action/', cloudmanager_views.trigger_my_action, name='run_my_action_url'),
|
||||
#path('change-schedule/', cloudmanager_views.change_schedule, name='change_schedule'),
|
||||
#path('cmm/main/', db_interaction.main),
|
||||
|
||||
]
|
||||
@@ -11,6 +11,13 @@ import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_code.settings')
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
|
||||
|
||||
application = get_wsgi_application()
|
||||
https_proxy = "gluetun-svc.gluetun.svc:8888"
|
||||
|
||||
proxyDict = {
|
||||
"https" : https_proxy,
|
||||
}
|
||||
|
||||
#os.environ["PROXIES"] = proxyDict
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,9 +0,0 @@
|
||||
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})
|
||||
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.
@@ -1,63 +0,0 @@
|
||||
"""
|
||||
URL configuration for django_code 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 docker_connection import views, apps
|
||||
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
|
||||
|
||||
urlpatterns = [
|
||||
# path('admin/', admin.site.urls),
|
||||
|
||||
################### 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),
|
||||
|
||||
|
||||
################## 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),
|
||||
|
||||
# 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),
|
||||
|
||||
|
||||
]
|
||||
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.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user