For convenient reference in development, here are the Archelon Daemon API docs.
Abstract base class for data stores
archelond.data.abstract.
HistoryData
(config)[source]¶Bases: object
Abstract Data storage for command history
Abstract class implementation of a database for use with command
history. Generally a command data item needs just two things, an
ID and the command itself. It also needs order. See the
archelond.data.MemoryData
class as the simplest
structure using an collections.OrderedDict
.
An ID can be any string, and the concrete implementation of
HistoryData
is responsible for type casting it if
needed.
It is also required implicitly that there is only one entry
per command. Thus add
ing the same command multiple times
should result in the return of just one command when filtered
by a term equal to that command.
add
(command, username, host, **kwargs)[source]¶Add or update a command
Save (update or create) a command to the data store.
Parameters: |
|
---|---|
Returns: | Command ID – The id of the command stored |
Return type: | str |
all
(order, username, host, **kwargs)[source]¶Unfiltered but ordered command history
Return the full data set as a list of dict structures in the specified order.
Parameters: |
|
---|---|
Returns: |
|
Return type: | list |
delete
(command_id, username, host, **kwargs)[source]¶Delete a command
Remove a command from the data store, raise a KeyError if it is not available to be deleted.
Parameters: |
|
---|
filter
(term, order, username, host, **kwargs)[source]¶Get a filtered by term and ordered command history
Parameters: |
|
---|---|
Returns: |
|
Return type: | list |
get
(command_id, username, host, **kwargs)[source]¶Get a single command
Retrieve a single command by username and id. Raise a KeyError if the command does not exist.
Parameters: |
|
---|---|
Returns: | Command –
|
Return type: | dict |
In memory data store implementation for development and testing
archelond.data.memory.
MemoryData
(config)[source]¶Bases: archelond.data.abstract.HistoryData
A quick in memory deduplicated structure for standalone testing and development.
INITIAL_DATA
= [u'cd', u'pwd', u'echo hi', u'cat /proc/cpuinfo']¶all
(order, username, host, page=0, **kwargs)[source]¶Simply rewrap the data structure, order, and return
ElasticSearch implementation of the data store. Currently the recommended default data store.
archelond.data.elastic.
ElasticData
(config)[source]¶Bases: archelond.data.abstract.HistoryData
An ElasticSearch implementation of HistoryData. This is what should be used in production
DOC_TYPE
= u'history'¶NUM_RESULTS
= 50¶add
(command, username, host, **kwargs)[source]¶Add the command to the index with a time stamp and id by hash of the command and append username to doc type for user separation of data.
all
(order, username, host, page=0, **kwargs)[source]¶Just build a body with match all and return filter
Configure the flask application
Configure logging
Classic utility module for removing repetitive tasks and such
Main entry point for flask application
archelond.web.
history_item
(cmd_id)[source]¶Actions for individual command history items.
Updates, gets, or deletes a command from the active data store.
PUT: Takes a payload in either form or JSON request, and runs the
add routine by passing the dictinoary minus command
,
username
, and host
as kwargs to the data stores add
routine.
archelond.web.
run_server
()[source]¶If started from command line, rebuild object in debug mode and run directly