add the time test
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s

This commit is contained in:
pierre.geeraert
2026-09-14 15:09:16 +01:00
parent e2f49a5b1f
commit cc0eb74090
4 changed files with 24 additions and 41 deletions
+5 -38
View File
@@ -1,31 +1,11 @@
from django.http import HttpResponse
from django.shortcuts import render
from datetime import timedelta
from django.utils import timezone
# IMPORT AT THE TOP HERE: This is completely safe!
from .models import Deployment_Data,Schedule_Week_Data
from .db_interaction import DB_generation,Check_server_supposed_XXX,Give_current_weekday,Give_current_hour
from .utils import import_namespace,retrieve_and_apply
from apps.kubernetes_connection.utils import scale_up,scale_down
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)
from .models import Deployment_Data
def hello(request):
list_schedule = ['schedule1','schedule2']
@@ -41,27 +21,14 @@ def retrieve_and_apply_view(request):
output = retrieve_and_apply()
return HttpResponse('<h1>'+output+'</h1>')
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})
def scale_up_gui(request,namespace_name,deploy_name,replicas=1):
Deployment_Data.objects.filter(namespace=namespace_name,name=deploy_name).update(do_not_touch_until=timezone.now() + timedelta(hours=1))
scale_up(namespace_name=namespace_name,deploy_name=deploy_name,replicas=replicas)
return render(request, 'dashboard/start.html', {'namespace':namespace_name,'deployment': deploy_name, 'url': 'https://namespace.com'})
def scale_down_gui(request,namespace_name,deploy_name):
Deployment_Data.objects.filter(namespace=namespace_name,name=deploy_name).update(do_not_touch_until=timezone.now() + timedelta(hours=1))
scale_down(namespace_name=namespace_name,deploy_name=deploy_name)
return render(request, 'dashboard/shutdown.html',
{'namespace': namespace_name, 'deployment': deploy_name, 'url': 'https://namespace.com'})