mirror of
https://github.com/Telecominfraproject/wlan-cloud-loadsim.git
synced 2025-10-30 02:02:20 +00:00
Change from start to offset
This commit is contained in:
@@ -106,7 +106,13 @@ paths:
|
||||
name: filter
|
||||
schema:
|
||||
type: string
|
||||
required: false
|
||||
required: false
|
||||
- in: query
|
||||
description: Detailed version
|
||||
name: filter
|
||||
schema:
|
||||
type: integer
|
||||
required: false
|
||||
responses:
|
||||
200:
|
||||
description: The list of Nodes Currently connected.
|
||||
@@ -115,7 +121,7 @@ paths:
|
||||
schema:
|
||||
$ref: '#/components/schemas/NodeList'
|
||||
|
||||
/makers:
|
||||
/vendors:
|
||||
get:
|
||||
tags: [ Manufacturers ]
|
||||
summary: Get the list of all available OUIs as known by the system for a given manufacturer.
|
||||
@@ -149,7 +155,7 @@ paths:
|
||||
403:
|
||||
$ref: '#/components/responses/Unauthorized'
|
||||
|
||||
/makers/{id}:
|
||||
/vendors/{id}:
|
||||
get:
|
||||
tags: [ Manufacturers ]
|
||||
summary: Get the OUIs associated with a maker.
|
||||
@@ -536,7 +542,7 @@ components:
|
||||
properties:
|
||||
OUIs:
|
||||
type: array
|
||||
items:
|
||||
Data:
|
||||
type: string
|
||||
|
||||
MakerList:
|
||||
@@ -544,7 +550,7 @@ components:
|
||||
properties:
|
||||
Manufacturers:
|
||||
type: array
|
||||
items:
|
||||
Data:
|
||||
type: string
|
||||
|
||||
MakerOUIList:
|
||||
@@ -555,7 +561,7 @@ components:
|
||||
string
|
||||
OUIs:
|
||||
type: array
|
||||
items:
|
||||
Data:
|
||||
type: string
|
||||
|
||||
OUIMaker:
|
||||
@@ -573,7 +579,7 @@ components:
|
||||
properties:
|
||||
CAs:
|
||||
type: array
|
||||
items:
|
||||
Data:
|
||||
type: string
|
||||
|
||||
CADetails:
|
||||
@@ -716,7 +722,7 @@ components:
|
||||
description: Returning a list of CAs
|
||||
readOnly: true
|
||||
properties:
|
||||
Items:
|
||||
Data:
|
||||
$ref: '#/components/schemas/CAList'
|
||||
Meta:
|
||||
$ref: '#/components/schemas/PaginationInfo'
|
||||
@@ -725,11 +731,33 @@ components:
|
||||
description: Returning a list of OUIs
|
||||
readOnly: true
|
||||
properties:
|
||||
Items:
|
||||
Data:
|
||||
$ref: '#/components/schemas/OUIList'
|
||||
Meta:
|
||||
$ref: '#/components/schemas/PaginationInfo'
|
||||
|
||||
|
||||
DetailedNodeList:
|
||||
description: Detailed list of nodes.
|
||||
readOnly: true
|
||||
properties:
|
||||
Nodes:
|
||||
description: Node list
|
||||
type: array
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
processes:
|
||||
type: integer
|
||||
worst:
|
||||
type: number
|
||||
total:
|
||||
type: number
|
||||
allocated:
|
||||
type: number
|
||||
Meta:
|
||||
$ref: '#/components/schemas/PaginationInfo'
|
||||
|
||||
NodeList:
|
||||
description: List of nodes.
|
||||
readOnly: true
|
||||
@@ -737,8 +765,11 @@ components:
|
||||
Nodes:
|
||||
description: Node list
|
||||
type: array
|
||||
oneOf:
|
||||
- type: string
|
||||
- $ref: '#/components/schemas/DetailedNodeList'
|
||||
items:
|
||||
type: string
|
||||
type: string
|
||||
Meta:
|
||||
$ref: '#/components/schemas/PaginationInfo'
|
||||
|
||||
|
||||
10
design/events.json
Normal file
10
design/events.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{"value":{"connecting_node":"simnode1@uberl.arilia.com","address":[49,48,46,50,46,49,54,52,46,49,51,49]},"type":"event","node":"simmanager@renegademac.arilia.com","name":"node_connect"}
|
||||
|
||||
{"value":{"nodename":"simnode1@uberl.arilia.com"},"type":"event","node":"simmanager@renegademac.arilia.com","name":"nodeup"}
|
||||
|
||||
{"value":{"nodename":"simnode1@uberl.arilia.com"},"type":"event","node":"simmanager@renegademac.arilia.com","name":"nodedown"}
|
||||
|
||||
{"value":{"connecting_node":"simnode1@uberl.arilia.com","address":[49,48,46,50,46,49,54,52,46,49,51,49]},"type":"event","node":"simmanager@renegademac.arilia.com","name":"node_connect"}
|
||||
|
||||
{"value":{"nodename":"simnode1@uberl.arilia.com"},"type":"event","node":"simmanager@renegademac.arilia.com","name":"nodeup"}
|
||||
|
||||
23840
design/stats.json
Normal file
23840
design/stats.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -141,8 +141,11 @@ handle_cast({log_error,NodeName,Message,Args}, State = #manager_state{}) ->
|
||||
{noreply, State};
|
||||
handle_cast({event,NodeName,Event,EventData}, State = #manager_state{}) ->
|
||||
try
|
||||
JSON = jiffy:encode( #{ type => event, name => Event , node => NodeName , value => EventData} ),
|
||||
web_socket_handler:send_frame( JSON )
|
||||
JSON = jiffy:encode( #{ type => event, name => Event , node => NodeName , data => EventData} ),
|
||||
web_socket_handler:send_frame( JSON ),
|
||||
_ = file:write_file(filename:join([code:priv_dir(?OWLS_APP),"events.json"]),JSON,[append]),
|
||||
_ = file:write_file(filename:join([code:priv_dir(?OWLS_APP),"events.json"]),<<"\n">>,[append]),
|
||||
_ = file:write_file(filename:join([code:priv_dir(?OWLS_APP),"events.json"]),<<"\n">>,[append])
|
||||
catch
|
||||
_:_ ->
|
||||
io:format("Bad event: ~p from node: ~p~nData:~p~n",[Event,NodeName,EventData])
|
||||
|
||||
@@ -146,9 +146,13 @@ do( ?HTTP_GET ,Req,#request_state{resource = <<"cas">>,id=nothing}=State)->
|
||||
do( ?HTTP_GET , Req , #request_state{ resource = <<"nodes">> , id = nothing } = State ) ->
|
||||
PaginationParameters = restutils:get_pagination_parameters(Req),
|
||||
{ok,AllNodes}=manager:connected_nodes(),
|
||||
Nodes = [ X || {X,Role} <- AllNodes, Role == node ],
|
||||
Nodes = [ atom_to_list(X) || {X,Role} <- AllNodes, Role == node ],
|
||||
io:format("NODES>>>~p~n",[Nodes]),
|
||||
{ SubList, PaginationInfo } = restutils:paginate(PaginationParameters,Nodes),
|
||||
JSON = restutils:create_paginated_return( "Nodes" , SubList, PaginationInfo),
|
||||
JSON = case restutils:get_parameter(details,0,Req) of
|
||||
0 -> restutils:create_paginated_return( "Nodes" , SubList, PaginationInfo);
|
||||
1 -> restutils:create_paginated_return( "Nodes" , SubList, PaginationInfo,nodes)
|
||||
end,
|
||||
{JSON,restutils:add_CORS(Req),State};
|
||||
|
||||
do( ?HTTP_GET ,Req,#request_state{resource = <<"hardware_definitions">>,id=nothing}=State)->
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
%% API
|
||||
-export([ create_paginated_return/3,create_paginated_return/4,dump_string_array/1,get_access_token/1,
|
||||
add_CORS/1,generate_error/2,get_pagination_parameters/1,paginate/2,validate_token/1,
|
||||
get_access_token_not_secure/1]).
|
||||
get_access_token_not_secure/1,get_parameter/3]).
|
||||
|
||||
-record(pagination_info,{limit=0, offset=0, previous_offset=0,
|
||||
next_offset=0, current_page=0, page_count=0, total_count=0}).
|
||||
@@ -22,14 +22,20 @@
|
||||
%%% create paginated return
|
||||
create_paginated_return(Header,List,PaginationInfo )->
|
||||
binary:list_to_bin(
|
||||
[ "{ \"Items\": { \"" ++ Header ++ "\" : [ ",
|
||||
[ "{ \"Data\": { \"" ++ Header ++ "\" : [ ",
|
||||
dump_string_array(List),
|
||||
" ] }, " ++
|
||||
dump_pagination_info(PaginationInfo),"} "]).
|
||||
|
||||
create_paginated_return(Header,List,PaginationInfo,nodes )->
|
||||
binary:list_to_bin(
|
||||
[ "{ \"Data\": { \"" ++ Header ++ "\" : [ ",
|
||||
utils:json_node_info(List),
|
||||
" ] }, " ++
|
||||
dump_pagination_info(PaginationInfo),"} "]);
|
||||
create_paginated_return(Header,List,PaginationInfo,Type )->
|
||||
binary:list_to_bin(
|
||||
[ "{ \"Items\": { \"" ++ Header ++ "\" : [ ",
|
||||
[ "{ \"Data\": { \"" ++ Header ++ "\" : [ ",
|
||||
dump_record_array(List,Type),
|
||||
" ] }, " ++
|
||||
dump_pagination_info(PaginationInfo),"} "]).
|
||||
@@ -98,6 +104,11 @@ get_pagination_parameters(Req) ->
|
||||
#{ offset := Offset , limit := Limit, filter := Filter } = cowboy_req:match_qs([{offset,int,1},{limit,int,0},{filter,[],<<>>}],Req),
|
||||
{ Offset, Limit, Filter }.
|
||||
|
||||
-spec get_parameter(Parameter::atom(),Default::any(),Req :: cowboy_req:req()) -> any().
|
||||
get_parameter(Parameter, Default, Req) when is_integer(Default) ->
|
||||
#{ Parameter := Value } = cowboy_req:match_qs([{Parameter,int,Default}],Req),
|
||||
Value.
|
||||
|
||||
paginate( { Offset, Limit, Filter}, List ) ->
|
||||
%% filter the list
|
||||
List1 = case Filter == <<>> of
|
||||
|
||||
@@ -131,11 +131,13 @@ add_new_report(Node,Type,Report)->
|
||||
report = Report })
|
||||
end ),
|
||||
try
|
||||
JSON = jiffy:encode( #{ type => report, name => Type , node => Node, value => Report } ),
|
||||
web_socket_handler:send_frame( JSON )
|
||||
JSON = jiffy:encode( #{ type => report, name => Type , node => Node, data => Report } ),
|
||||
web_socket_handler:send_frame( JSON ),
|
||||
_ = file:write_file(filename:join([code:priv_dir(?OWLS_APP),"stats.json"]),JSON,[append]),
|
||||
_ = file:write_file(filename:join([code:priv_dir(?OWLS_APP),"stats.json"]),<<"\n">>,[append]),
|
||||
_ = file:write_file(filename:join([code:priv_dir(?OWLS_APP),"stats.json"]),<<"\n">>,[append])
|
||||
catch
|
||||
_:_ ->
|
||||
io:format("FAILED REPORT: ~p~n ~p~n",[Type,Report]),
|
||||
ok
|
||||
io:format("FAILED REPORT: ~p~n ~p~n",[Type,Report])
|
||||
end,
|
||||
ok.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
-export([ make_dir/1,uuid/0,get_addr/0,get_addr2/0,app_name/0,app_name/1,priv_dir/0,app_env/2,to_string_list/2,to_binary_list/2,print_nodes_info/1,
|
||||
do/2,pem_to_cert/1,pem_to_key/1,safe_binary/1,uuid_b/0,pem_key_is_encrypted/1,remove_pem_key_password/3,
|
||||
noop/0,noop_mfa/0,split_into/2,select/3,adjust/2,
|
||||
get_avg/1, new_avg/0,compute_avg/2,search_replace/3]).
|
||||
get_avg/1, new_avg/0,compute_avg/2,search_replace/3,json_node_info/1]).
|
||||
|
||||
-type average() :: { CurrentValue::number(), HowManyValues::integer(), PastValues::[number()]}.
|
||||
-export_type([average/0]).
|
||||
@@ -80,6 +80,16 @@ print_nodes_info(Nodes)->
|
||||
print_line(Nodes),
|
||||
io:format("---------------------------------------------------------------------------------------------~n").
|
||||
|
||||
json_node_info(Nodes)->
|
||||
json_node_info(Nodes,[]).
|
||||
|
||||
json_node_info([],Acc)->
|
||||
jiffy:encode(Acc);
|
||||
json_node_info([H|T],Acc)->
|
||||
NodeInfo = node_info(H),
|
||||
%% #{ total := Total , allocated := Allocated , worst := Worst , processes := Processes } = NodeInfo,
|
||||
json_node_info(T,[NodeInfo|Acc]).
|
||||
|
||||
print_line([])->
|
||||
ok;
|
||||
print_line([H|T])->
|
||||
@@ -92,10 +102,10 @@ node_info(Node)->
|
||||
try
|
||||
{Total,Allocated,{ _Pid, Worst}}=rpc:call(Node,memsup,get_memory_data,[]),
|
||||
Processes = rpc:call(Node,cpu_sup,nprocs,[]),
|
||||
#{ total => Total/(1 bsl 20), allocated => Allocated/(1 bsl 20), worst => Worst/(1 bsl 20), processes => Processes }
|
||||
#{ name => Node, total => Total/(1 bsl 20), allocated => Allocated/(1 bsl 20), worst => Worst/(1 bsl 20), processes => Processes }
|
||||
catch
|
||||
_:_ ->
|
||||
#{ total => 0, allocated => 0, worst => 0, processes => 0 }
|
||||
#{ name => Node, total => 0, allocated => 0, worst => 0, processes => 0 }
|
||||
end.
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
Reference in New Issue
Block a user