Nodelist¶
If a --nodelist
is passed, it will be used to count online Nodes and
Clients from there.
It can either be a local file, or if this does not exist,
it is interpreted as URL, and fetched from there.
If successful, the numbers will be added to the APIfile:
{
"state": {
"nodes": 0,
"description": ""
}
}
Would be changed to this:
{
"state": {
"nodes": 23,
"description": "[23 Nodes, 42 Clients]"
}
}
-
ffflash.inc.nodelist.
_nodelist_count
(ff, nodelist)[source]¶ Count online nodes and sum up their clients from a nodelist.
Parameters: - ff – running
ffflash.main.FFFlash
instance - nodelist – nodelist from
_nodelist_fetch()
, should contain a list of dictionaries at the key nodes
Returns: Tuple of counted nodes and clients
- ff – running
-
ffflash.inc.nodelist.
_nodelist_dump
(ff, nodes, clients)[source]¶ Store the counted numbers in the api-file.
Sets the key
state
.nodes
with the node number.Leaves
state
.description
untouched, if any already present. If empty, or the pattern\[[\d]+ Nodes, [\d]+ Clients\]
is matched, the numbers in the pattern will be replaced.Parameters: - ff – running
ffflash.main.FFFlash
instance - nodes – Number of online nodes
- clients – Number of their clients
Returns: True
ifapi
was modified elseFalse
- ff – running
-
ffflash.inc.nodelist.
_nodelist_fetch
(ff)[source]¶ Determines if
--nodelist
was a file or a url, and tries to fetch it. Validates nodelist to be json and to have the version, nodes and updated_at keys.Parameters: ff – running ffflash.main.FFFlash
instanceReturns: the unpickled nodelist or False
/None
on error
-
ffflash.inc.nodelist.
handle_nodelist
(ff)[source]¶ Entry function to receive a
--nodelist
and store determined results into bothapi
and--rankfile
(if specified).Parameters: ff – running ffflash.main.FFFlash
instanceReturns: True
ifapi
was modified elseFalse
Rankfile¶
-
ffflash.inc.rankfile.
_rankfile_dump
(ff, rankfile, ranks)[source]¶ Store ranks in
rankfile
. Also sets a timestamp and writes the release string into the output.Parameters: - ff – running
ffflash.main.FFFlash
instance - rankfile – validated path to the
rankfile
- ranks – content to store
Returns: True
on success, orFalse
on error- ff – running
-
ffflash.inc.rankfile.
_rankfile_load
(ff)[source]¶ Load either existing
rankfile
from disk, or create empty stub if one does not exist yet. Path and extension (json) get validated.Parameters: ff – running ffflash.main.FFFlash
instanceReturns: Tuple of either ( False
,None
) on error or:- validated path to the
rankfile
rankfile
content
- validated path to the
-
ffflash.inc.rankfile.
_rankfile_score
(ff, ranks, nodelist)[source]¶ Do some number crunching.
Parameters: - ff – running
ffflash.main.FFFlash
instance - ranks – rankfile content from
_rankfile_load()
, should contain a list of dictionaries at the key nodes - nodelist – nodelist from
ffflash.inc.nodelist._nodelist_fetch()
, should contain a list of dictionaries at the key nodes
Returns: ranks
with new scores, sorted by score- ff – running
-
ffflash.inc.rankfile.
handle_rankfile
(ff, nodelist)[source]¶ Entry function gather results from a retrieved
--nodelist
to store it into the--rankfile
.Parameters: ff – running ffflash.main.FFFlash
instanceReturns: True
if rankfile was modified elseFalse