Blame view

src/core/pyros_django/agent/doc/agentSST.pu 2.91 KB
13d72009   Alexis Koralewski   Adding AgentSST U...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
@startuml
partition init() {
start
:super.init();
:get name of agentSST from obsconfig and set this value;
:start_agents;
:time.sleep(10);
:self.delay(3);
}
partition routine_after {
repeat :for agent in self.subprocess_dict.keys();
:get agent_survey of agent;
if (agent_survey.status is outdated) then (yes)
if (process of agent is running) then (yes)
:get last_executed_start_agent_cmd;
if (last_executed_start_agent_cmd exists) then (yes)
if (last_executed_start_agent_cmd was sent between 25 and 30 seconds ago) then (yes)
: self.send_cmd_to(self.name,do_start_agent, agent);
else (no)
endif
else (no)
if ( do_start_agent command already sent (is_pending or running)) then (yes)
else (no)
:send_cmd_to(self.name,"do_start_agent",agent);
endif
endif

else (no)
:get last_executed_start_or_restart_agent_cmd;

if (last_executed_start_or_restart_agent_cmd exists) then (yes)
if (last_executed_start_or_reastart_agent_cmd was sent between 25 and 30 seconds ago) then (yes)
: self.send_cmd_to(self.name,do_restart_agent, agent);
else (no)
endif
else (no)
if ( do_restart_agent command already sent (is_pending or running)) then (yes)
else (no)
:send_cmd_to(self.name,"do_restart_agent",agent);
endif
endif
endif
endif


repeat while ();
repeat :for agent in self.subprocess_dict.keys();
:log.info(process status (running or not));
repeat while();
}
end


partition do_things_before_exit(){
start
repeat :for agent in self.subprocess_dict.keys();
:self.do_kill(agent);
:reset restart counter for agent;
repeat while();
:sleep(10);
repeat :agent in self.subprocess_dict.keys();
repeat :sleep(0.5)
repeat while(wait for agent process to stop);
repeat while();
end

}

partition do_start_agent(agent){
start
:self.start_agents(agent);
:update nb_try_restart of agent in db;
end
}

partition self.start_agents(agent){
start
if (agent) then (yes)
: get agent informations from config;
if (agent has a protocol) then (yes)
: run protocol in subprocess and add it to self.subprocess_dict;
: increase nb_try_restart for this agent;
endif
else (no)
if (agents_listed_for_this_computer != None) then (yes)
repeat :for agent in agents_listed_for_this_computer;
: get agent informations from config;
if (agent has a protocol) then (yes)
: run protocol in subprocess and add it to self.subprocess_dict;
endif
repeat while();

else (no)
stop
endif
endif
end
}

partition do_kill_agent(agent){
start
if (agent in self.subprocess_dict.keys()) then (yes)
:send_cmd_to(agent,"do_exit");
endif
end
}

partition do_restart_agent(agent){
start
:get nb_try_restart for agent;
if (nb_try_restart for agent > nb_restart_max for agent) then (yes){
:send mail to operator and stop PyROS;
else (no)
:self.do_kill_agent(agent);
:self.do_start_agent(agent);
endif
:update nb_try_restart in database;
end
}

partition force_kill_agent(agent){
start
if (agent in self.subprocess_dict.keys()) then (yes)
:agent_process = get process of agent;
:agent_process.kill();
else (no)
:return None;
endif
end
}
@enduml