mirror of
https://github.com/Telecominfraproject/wlan-cloud-loadsim.git
synced 2026-01-11 14:25:15 +00:00
fixing stats
This commit is contained in:
@@ -246,21 +246,28 @@ handle_call ({api_cmd_start,Which,Options},_From, State) ->
|
||||
end;
|
||||
|
||||
handle_call ({api_cmd_stop, Which, Options},_,State) ->
|
||||
io:format("Actively stopping:~n"),
|
||||
case State#state.state of
|
||||
configured ->
|
||||
io:format(">>>1~n"),
|
||||
spawn_link(?MODULE,stop_aps,[Which,Options,State#state.clients_pid]),
|
||||
{reply, ok, State#state{ state = stopping }};
|
||||
paused ->
|
||||
io:format(">>>2~n"),
|
||||
spawn_link(?MODULE,stop_aps,[Which,Options,State#state.clients_pid]),
|
||||
{reply, ok, State#state{ state = stopping }};
|
||||
stopped ->
|
||||
io:format(">>>3~n"),
|
||||
{reply, ok, State};
|
||||
started ->
|
||||
io:format(">>>4~n"),
|
||||
spawn_link(?MODULE,stop_aps,[Which,Options,State#state.clients_pid]),
|
||||
{reply, ok, State#state{ state = stopping }};
|
||||
cancelled ->
|
||||
io:format(">>>5~n"),
|
||||
{reply, {error,simulation_most_receive_new_configuration},State};
|
||||
_ ->
|
||||
io:format(">>>6~n"),
|
||||
{reply, ok, State}
|
||||
end;
|
||||
|
||||
|
||||
@@ -355,17 +355,21 @@ handle_call({stop,SimName,Attributes,Notification}, _From, State = #simengine_st
|
||||
[] ->
|
||||
{ reply, ?ERROR_SIM_UNKNOWN, State };
|
||||
[SimInfo] ->
|
||||
io:format("S>>>1~n"),
|
||||
S = maps:get(SimName,State#simengine_state.sim_states),
|
||||
case SimInfo#simulation.assets_created of
|
||||
false->
|
||||
io:format("S>>>2~n"),
|
||||
{reply,?ERROR_SIM_NO_ASSETS_EXIST,State};
|
||||
true->
|
||||
case not S#sim_state.pushed of
|
||||
true ->
|
||||
io:format("S>>>3~n"),
|
||||
{reply,?ERROR_SIM_ASSETS_NOT_PUSHED,State};
|
||||
false->
|
||||
case length(S#sim_state.outstanding_nodes)>0 of
|
||||
true->
|
||||
io:format("S>>>4~n"),
|
||||
{reply,?ERROR_SIM_OPERATION_IN_PROGRESS,State};
|
||||
false->
|
||||
case ((S#sim_state.state==started) or (S#sim_state.state==paused)) of
|
||||
@@ -385,6 +389,7 @@ handle_call({stop,SimName,Attributes,Notification}, _From, State = #simengine_st
|
||||
start_os_time = os:system_time()
|
||||
},
|
||||
NewActions = maps:put(JobId,SimAction,State#simengine_state.sim_actions),
|
||||
io:format("S>>>5~n"),
|
||||
{reply,{ok,JobId},State#simengine_state{ sim_states = maps:put(SimName,
|
||||
S#sim_state{current_op_pid = OpPid,
|
||||
current_op = stopping ,
|
||||
@@ -792,11 +797,12 @@ start_assets(SimInfo,Attributes,SimEnginePid,{M,F,A}=_Notification,JobId)->
|
||||
|
||||
-spec stop_assets(SimInfo::simulation(), Attributes::#{atom()=>term()}, ManagerPis::pid(),Notification::notification_cb(),JobId::binary())->ok.
|
||||
stop_assets(SimInfo,Attributes,SimEnginePid,{M,F,A}=_Notification,JobId)->
|
||||
?L_IA("~s: Stopping all assets.",[binary_to_list(SimInfo#simulation.name)]),
|
||||
io:format("~s: Stopping all assets.",[binary_to_list(SimInfo#simulation.name)]),
|
||||
_Results = lists:reverse(lists:foldl(fun(Node,Acc) ->
|
||||
R = rpc:call(Node,simnode,stop,[all,Attributes#{ callback => {SimEnginePid,{SimInfo#simulation.name, Node,stop_done,erlang:timestamp(),JobId}} }]),
|
||||
[R|Acc] end,[],SimInfo#simulation.nodes)),
|
||||
apply(M,F,A),
|
||||
io:format("Stopping assets~n"),
|
||||
ok.
|
||||
|
||||
-spec pause_assets(SimInfo::simulation(), Attributes::#{atom()=>term()}, ManagerPis::pid(),Notification::notification_cb(),JobId::binary())->ok.
|
||||
|
||||
@@ -152,7 +152,7 @@ handle_call({stop,UIDs,Attributes}, _From, State = #simnode_state{}) ->
|
||||
safe_execute( State#simnode_state.ap_client_handler, stop, [UIDs,Attributes]),
|
||||
safe_execute( State#simnode_state.mqtt_server_handler, stop, [UIDs,Attributes]),
|
||||
safe_execute( State#simnode_state.ovsdb_server_handler, stop, [UIDs,Attributes]),
|
||||
?RL_I("STOP sent to all handlers."),
|
||||
io:format("STOP sent to all handlers."),
|
||||
{ reply, ok , State};
|
||||
|
||||
handle_call({pause,UIDs,Attributes}, _From, State = #simnode_state{}) ->
|
||||
|
||||
Reference in New Issue
Block a user