testing #9

Merged
pi-ux-ce merged 35 commits from testing into main 2026-06-12 08:30:01 +00:00
Showing only changes of commit 910170b594 - Show all commits
+7 -7
View File
@@ -43,7 +43,8 @@ def Launch_sql_query(sql,db):
#Return the day of the week as an integer, where Monday is 0 and Sunday is 6.
def Give_current_weekday():
weekday = datetime.datetime.today().weekday()
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday','Saturday', 'Sunday']
weekday = days[datetime.datetime.today().weekday()]
return weekday
def Give_current_hour():
@@ -51,14 +52,15 @@ def Give_current_hour():
return now.hour
def Check_server_supposed_XXX(generated_db_in,wanted_status,Wanted_hour):
def Check_server_supposed_XXX(generated_db_in,wanted_status,Wanted_hour,Wanted_day):
sql_in=""
if wanted_status == "up" or wanted_status == "start":
sql_in = "select machine.namespace, machine.name, machine.replicas from scenario_hour,machine where state_at_" + str(Wanted_hour) + "='1' and machine.hour_behaviour_id=scenario_hour.id_scenario;"
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" or wanted_status == "stop":
sql_in = "select machine.namespace, machine.name, machine.replicas from scenario_hour,machine where state_at_" + str(Wanted_hour) + "='0' and machine.hour_behaviour_id=scenario_hour.id_scenario;"
else:
print("error value")
print(sql_in)
return_value = Launch_sql_query(sql_in, generated_db_in)
return return_value
@@ -97,11 +99,9 @@ def all_operations(request,wanted_state,list_machine):
def main(request):
generated_db = DB_generation(credentials.sql.url, credentials.sql.port, credentials.sql.user, credentials.sql.password,credentials.sql.database)
##operation:
kubernetes_connection.hello(request);
## Server(s) supposed to be UP
#Check_server_supposed_XXX(generated_db, "up", Give_current_hour())
## Server(s) supposed to be UP
list_servers_up = Check_server_supposed_XXX(generated_db, "up", Give_current_hour())
list_servers_up = Check_server_supposed_XXX(generated_db, "up", Give_current_hour(),Give_current_weekday())
print("------------------------------------------")
print("-----------------UP-----------------------")
print("------------------------------------------")