adding the sql code for the template
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
This commit is contained in:
@@ -90,31 +90,32 @@ def all_operations(wanted_state,list_machine):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
generated_db = DB_generation(credentials.sql.url, credentials.sql.port, credentials.sql.user, credentials.sql.password,credentials.sql.database)
|
generated_db = DB_generation(credentials.sql.url, credentials.sql.port, credentials.sql.user, credentials.sql.password,credentials.sql.database)
|
||||||
|
print(generated_db)
|
||||||
|
##operation:
|
||||||
|
|
||||||
|
## Server(s) supposed to be UP
|
||||||
|
Check_server_supposed_XXX(generated_db, "up", Give_current_hour())
|
||||||
|
|
||||||
###operation:
|
|
||||||
|
|
||||||
## 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())
|
||||||
print("------------------------------------------")
|
# print("------------------------------------------")
|
||||||
print("-----------------UP-----------------------")
|
# print("-----------------UP-----------------------")
|
||||||
print("------------------------------------------")
|
# print("------------------------------------------")
|
||||||
print(list_servers_up)
|
# print(list_servers_up)
|
||||||
print(all_operations("running", list_servers_up))
|
# print(all_operations("running", list_servers_up))
|
||||||
|
#
|
||||||
|
#
|
||||||
## Server(s) supposed to be DOWN
|
# ## Server(s) supposed to be DOWN
|
||||||
list_servers_down = Check_server_supposed_XXX(generated_db, "down", Give_current_hour())
|
# list_servers_down = Check_server_supposed_XXX(generated_db, "down", Give_current_hour())
|
||||||
|
#
|
||||||
print("------------------------------------------")
|
# print("------------------------------------------")
|
||||||
print("----------------DOWN----------------------")
|
# print("----------------DOWN----------------------")
|
||||||
print("------------------------------------------")
|
# print("------------------------------------------")
|
||||||
print(list_servers_down)
|
# print(list_servers_down)
|
||||||
print(all_operations("stopped",list_servers_down))
|
# print(all_operations("stopped",list_servers_down))
|
||||||
|
#
|
||||||
|
#
|
||||||
# disconnect from server
|
# # disconnect from server
|
||||||
generated_db.close()
|
generated_db.close()
|
||||||
|
|
||||||
#print(Is_the_server_already_wanted_state(112, "stopped"))
|
#print(Is_the_server_already_wanted_state(112, "stopped"))
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
drop table IF EXISTS machine;
|
||||||
|
CREATE TABLE IF NOT EXISTS machine (
|
||||||
|
id integer NOT NULL PRIMARY KEY,
|
||||||
|
namespace varchar(100) NOT null,
|
||||||
|
name varchar(100) NOT null,
|
||||||
|
hour_behaviour_id integer NOT null,
|
||||||
|
day_behaviour_id integer NOT null,
|
||||||
|
replicas integer NOT null
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT into machine (id, namespace, name, hour_behaviour_id, day_behaviour_id,replicas) VALUES (1, 'echo', 'echo-server', 0, 1,1);
|
||||||
|
INSERT into machine (id, namespace, name, hour_behaviour_id, day_behaviour_id,replicas) VALUES (2, 'wiki', 'wikijs', 1, 1,2);
|
||||||
|
INSERT into machine (id, namespace, name, hour_behaviour_id, day_behaviour_id,replicas) VALUES (3, 'book', 'bookstack-db', 2, 1,1);
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
create table scenario_day_of_week
|
||||||
|
(
|
||||||
|
id_scenario integer NOT NULL PRIMARY KEY,
|
||||||
|
name_scenario varchar(255) null,
|
||||||
|
state_Monday BOOLEAN null,
|
||||||
|
state_Tuesday BOOLEAN null,
|
||||||
|
state_Wednesday BOOLEAN null,
|
||||||
|
state_Thursday BOOLEAN null,
|
||||||
|
state_Friday BOOLEAN null,
|
||||||
|
state_Saturday BOOLEAN null,
|
||||||
|
state_Sunday BOOLEAN null
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO scenario_day_of_week (id_scenario, name_scenario, state_Monday, state_Tuesday, state_Wednesday, state_Thursday, state_Friday, state_Saturday, state_Sunday) VALUES (0, 'always off', FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
|
||||||
|
INSERT INTO scenario_day_of_week (id_scenario, name_scenario, state_Monday, state_Tuesday, state_Wednesday, state_Thursday, state_Friday, state_Saturday, state_Sunday) VALUES (1, 'always on', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
create table scenario_hour
|
||||||
|
(
|
||||||
|
id_scenario integer NOT NULL PRIMARY KEY,
|
||||||
|
name_scenario varchar(255) null,
|
||||||
|
state_at_0 BOOLEAN null,
|
||||||
|
state_at_1 BOOLEAN null,
|
||||||
|
state_at_2 BOOLEAN null,
|
||||||
|
state_at_3 BOOLEAN null,
|
||||||
|
state_at_4 BOOLEAN null,
|
||||||
|
state_at_5 BOOLEAN null,
|
||||||
|
state_at_6 BOOLEAN null,
|
||||||
|
state_at_7 BOOLEAN null,
|
||||||
|
state_at_8 BOOLEAN null,
|
||||||
|
state_at_9 BOOLEAN null,
|
||||||
|
state_at_10 BOOLEAN null,
|
||||||
|
state_at_11 BOOLEAN null,
|
||||||
|
state_at_12 BOOLEAN null,
|
||||||
|
state_at_13 BOOLEAN null,
|
||||||
|
state_at_14 BOOLEAN null,
|
||||||
|
state_at_15 BOOLEAN null,
|
||||||
|
state_at_16 BOOLEAN null,
|
||||||
|
state_at_17 BOOLEAN null,
|
||||||
|
state_at_18 BOOLEAN null,
|
||||||
|
state_at_19 BOOLEAN null,
|
||||||
|
state_at_20 BOOLEAN null,
|
||||||
|
state_at_21 BOOLEAN null,
|
||||||
|
state_at_22 BOOLEAN null,
|
||||||
|
state_at_23 BOOLEAN null
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO scenario_hour (id_scenario, name_scenario, state_at_0, state_at_1, state_at_2, state_at_3, state_at_4, state_at_5, state_at_6, state_at_7, state_at_8, state_at_9, state_at_10, state_at_11, state_at_12, state_at_13, state_at_14, state_at_15, state_at_16, state_at_17, state_at_18, state_at_19, state_at_20, state_at_21, state_at_22, state_at_23) VALUES (0, 'always off uk', FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
|
||||||
|
INSERT INTO scenario_hour (id_scenario, name_scenario, state_at_0, state_at_1, state_at_2, state_at_3, state_at_4, state_at_5, state_at_6, state_at_7, state_at_8, state_at_9, state_at_10, state_at_11, state_at_12, state_at_13, state_at_14, state_at_15, state_at_16, state_at_17, state_at_18, state_at_19, state_at_20, state_at_21, state_at_22, state_at_23) VALUES (1, 'always on uk', TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);
|
||||||
|
INSERT INTO scenario_hour (id_scenario, name_scenario, state_at_0, state_at_1, state_at_2, state_at_3, state_at_4, state_at_5, state_at_6, state_at_7, state_at_8, state_at_9, state_at_10, state_at_11, state_at_12, state_at_13, state_at_14, state_at_15, state_at_16, state_at_17, state_at_18, state_at_19, state_at_20, state_at_21, state_at_22, state_at_23) VALUES (2, 'awake hours uk', FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE);
|
||||||
Reference in New Issue
Block a user