Testing #50

Merged
pi-ux-ce merged 8 commits from testing into main 2026-10-03 22:28:38 +00:00
4 changed files with 61 additions and 3 deletions
Showing only changes of commit 5908d8d282 - Show all commits
@@ -0,0 +1,18 @@
# Generated by Django 4.2.30 on 2026-09-21 21:06
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cloudmanager', '0013_ingress_data'),
]
operations = [
migrations.AlterField(
model_name='ingress_data',
name='namespace',
field=models.CharField(blank=True, max_length=100, null=True),
),
]
+1 -1
View File
@@ -67,4 +67,4 @@ class Namespace_Data(models.Model):
class Ingress_Data(models.Model):
url = models.CharField(max_length=100)
namespace = models.ForeignKey(Namespace_Data,null=True, blank=True, on_delete=models.SET_NULL)
namespace = models.CharField(max_length=100,null=True, blank=True)
+5 -1
View File
@@ -16,7 +16,7 @@ Including another URLconf
"""
from django.urls import path
from .views import hello,import_namespace_view,retrieve_and_apply_view,scale_up_gui,scale_down_gui
from .views import hello,import_namespace_view,retrieve_and_apply_view,scale_up_gui,scale_down_gui,add_ingress,delete_ingress
urlpatterns = [
@@ -26,4 +26,8 @@ urlpatterns = [
path('retrieve_and_apply_view', retrieve_and_apply_view, name='retrieve_and_apply_view'),
path('scale_up/<str:namespace_name>/<str:deploy_name>', scale_up_gui),
path('scale_down/<str:namespace_name>/<str:deploy_name>', scale_down_gui),
path('add_ingress', add_ingress),
path('delete_ingress', delete_ingress),
]
+37 -1
View File
@@ -2,10 +2,12 @@ from django.http import HttpResponse
from django.shortcuts import render
from datetime import timedelta
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
from django.http import JsonResponse
from .utils import import_namespace,retrieve_and_apply
from apps.kubernetes_connection.utils import scale_up,scale_down
from .models import Deployment_Data
from .models import Deployment_Data,Ingress_Data
def hello(request):
list_schedule = ['schedule1','schedule2']
@@ -32,3 +34,37 @@ def scale_down_gui(request,namespace_name,deploy_name):
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'})
@csrf_exempt
def add_ingress(request):
url = request.POST.get('url')
namespace = request.POST.get('namespace')
print("URL: "+str(url))
print("NS: "+str(namespace))
try:
Ingress_Data.objects.update_or_create(url=url,namespace=namespace)
except Exception as exception:
return JsonResponse({"status": "error","reason":str(exception)})
return JsonResponse({"status": "added","url":str(url),"namespace":str(namespace)})
@csrf_exempt
def delete_ingress(request):
url = request.POST.get('url')
namespace = request.POST.get('namespace')
print("URL: "+str(url))
print("NS: "+str(namespace))
try:
ingress_object = Ingress_Data.objects.filter(url=url,namespace=namespace)
except Exception as exception:
return JsonResponse({"status": "error","reason":str(exception)})
try:
ingress_object.delete()
except Exception as exception:
return JsonResponse({"status": "error","reason":str(exception)})
return JsonResponse({"status": "deleted","url":str(url),"namespace":str(namespace)})