This commit is contained in:
@@ -1,37 +1,6 @@
|
||||
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})
|
||||
|
||||
|
||||
@@ -154,10 +154,6 @@ def main(request):
|
||||
#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
|
||||
|
||||
@@ -2,6 +2,7 @@ from django.http import HttpResponse
|
||||
|
||||
# IMPORT AT THE TOP HERE: This is completely safe!
|
||||
from apps.cloudmanager.models import Deployment_Data,Schedule_Week_Data
|
||||
from apps.cloudmanager.db_interaction import DB_generation,Check_server_supposed_XXX,Give_current_weekday,Give_current_hour
|
||||
|
||||
def coucou(request):
|
||||
# 1. Prepare the data inside the function
|
||||
@@ -23,3 +24,23 @@ def display(request):
|
||||
print(data[0].namespace)
|
||||
return HttpResponse(data)
|
||||
|
||||
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})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user