silo.low_code package
- class silo.low_code.AgentConfigGenerator(da_job)
Bases:
object
Generates an agent config
This class allows for easier generator of agent configs by being a front-end for setting values correctly and ensuring that all required information is present and valid.
The created commands use a specific name that allows the framework to automatically rebuild the ResultContainers with the correct data. This is accomplished by appending the RC’s Requestors hash.
- add_command(command, result_container)
Add a command that will be executed by the agent
The provided command must be a python object formatted correctly for the given execution type (datatype). For example, JMX and PowerShell require different information within this field.
- Parameters
command (..agent.messages.ProtocolConfig) – Information related to the command that needs to be executed. This data must match the required information for the given datatype.
result_container (ResultContainer) – ResultContainer for extracting required information for the command
- Returns
Command was successfully added
- Return type
bool
- generate_group()
Generate the group_id for the agent
- Returns
Unique hash for the given information
- Return type
int
- exception silo.low_code.DeviceError
Bases:
FrameworkError
- exception silo.low_code.FrameworkError
Bases:
SLError
- class silo.low_code.RequestMaker(credential, cache_read=True, result_cache=None)
Bases:
SequencePhase
Network Requests
- agent_supported = False
- static generate_agent_config(da_job, result_containers)
Generate an agent configuration for the Requestor / DA Job
This function generates all required configurations and returns them as a list of messages. This allows agent alignment to occur with the proper configuration to collect the required collections. If this function is not implemented, execution on the agent will not occur.
- Parameters
da_job (dict) – Dynamic Application job pertaining to a specific app / device id.
result_containers (list) – List of result containers for the current collections
- Returns
List of messages that can be used to generate the config
- Return type
list
- classmethod get_hash_information(result_container)
Generates the hash information for a specific RC
- Parameters
result_container (ResultContainer) – RC to use for generating the Requestor hash. This ensures that duplicate requests are not made which will reduce the load on the local system and reduce toe bandwidth to SL1 and storage on both devices.
- Returns
Tuple containing the Display ID and backend ID
- Return type
tuple
- classmethod get_req_id_disp(result_container)
Setup and calling for generating the request ID
- Parameters
result_container (ResultContainer) – Current RC
- Returns
Request ID Display name
- Return type
str
- classmethod get_request_id(result_container)
Given a request for a network response, return the request’s unique ID. By default, this is just the details of the network connection. You may need to make it unique based on e.g. headers, credentials, etc.
The goal is to have a unique hashable identifier based on whatever properties make this request unique.
- Parameters
result_container (ResultContainer) – ResultContainer of this network request
- Returns
A unique, hashable identifier for this request
- Return type
hashable
- static manipulate_agent_data(result)
Modify the results to be consistent between the agent and CU
- Parameters
result (object) – Results from the agent
- abstract validate_request(request)
Accepts a single request to ensure that it is valid for the network requester
Validates that the provided request meets the criteria to be executed by this RequestMaker. If the request is not valid, an exception stating why will be raised. There is no return for this function.
- Parameters
request (ResultContainer) – Request that needs to be verified.
- exception silo.low_code.RequestMoreData(*args, **kwargs)
Bases:
Exception
Informs the framework to goto the previous requestor
Raising this exception within a step will rewind the device metric to the previous Requestor. This allows for additional data to be collected if required. The Requestor must know how to consume the data that is raised for the next collection to occur.
This step cannot be used within Syntax and Requestor steps. The Snippet Framework will consider this exception an unhandled exception and will stop the collection process for that device metric.
- class silo.low_code.ResultContainer(result, **kwargs)
Bases:
object
The ResultContainer is the standard data interface for moving information between the steps. It is a pure data-class with no attached functions so its only purpose is to move information around.
Object properties are set with the following precedence:
Assigned as a keyword argument
Value from previous_result
- Variables
collection (Collection) – Collection associated with the ResultContainer
error_data (object) – Information for errors that occurred
metadata (dict) – Metadata associated with the collection.
name (str) – Name of the ResultContainer. If a name is not provided, a name will be generated as “<obj_id>.<did>”.
request_ids (list) – Request_ids for each step
result (object) – Result from the previous step or final result of the current step
execution (list) – List of steps that need to be executed to get the result
cache_info (dict) – Dictionary of step caching information
action_number (int) – Current index of the execution plan
indexing (str) – Index to help identify the request
max_iterations (int) – Maximum number of times RequestMoreData can be executed prior to exiting out of RequestMoreData mode.
rmd_data (OrderedDict) – Data related to RequestMoreData iterations. To avoid duplicating memory, rmd_data gets pushed into a nested dictionary. This allows us to pop the data out rather than having to clone and return, which results in memory duplication.
- Parameters
result (object) – Result to set for the container
name (str) – Name of the ResultContainer
metadata (dict) – Metadata associated with the collection.
error_data (object) – Information for errors that occurred
request_ids (list) – Request_ids for each step
collection (Collection) – Collection associated with the ResultContainer
previous_result (ResultContainer) – ResultContainer that should be use for attribute inheritance
indexing (str) – Index to help identify the request
max_iterations (int) – Maximum number of times RequestMoreData can be executed prior to exiting out of RequestMoreData mode.
rmd_data (OrderedDict) – Data related to RequestMoreData iterations
- Noindex
- action_number
- argument
- cache_info
- clear_rmd()
Clear out everything related to RequestMoreData and returns the value
- Return type
dict
- collection
- property credential
Lookup the credential assigned to the device
- Return type
dict
- property current_config
Return the configuration for the current step
- Return type
object
- property current_step_info
Return the step information for the current step. (step_name, step_config)
- Return type
tuple
- property current_step_name
Return the name for the current step
- Return type
str
- did
- error_data
- execution
- get_rmd()
Return the results of RequestMoreData
- Return type
dict
- property index
- indexing
- is_cache_step(action_num=None)
Determine if the current step is a caching step
- Return type
bool
- max_iterations
- metadata
- name
- property request_id
Return the current request_id based off action_number
- Returns
Request ID for current action number or None
- Return type
union[str,None]
- request_ids
- result
- rmd_data
- set_index(index)
Set the index for the result container
- Parameters
index (str) – Index when RequestMoreData is active
- status
- update_rmd()
Add the current result to RequestMoreData
- class silo.low_code.ScriptConfig(script)
Bases:
ProtocolConfig
Generate a Script command
- Parameters
script (str) – Command that should be executed locally
- Returns
Dictionary with the required fields populated for the Agent config
- Return type
dict
- attributes = ['script']
- datatype = 'script'
- silo.low_code.String23
alias of
str
- silo.low_code.add_group_descr(group, descr)
Adds a description for a group
- Parameters
group (str) – Name of the group
descr (str) – Description of the group
- silo.low_code.agent_processing(*args, **kwargs)
- silo.low_code.generate_agent_config(*args, **kwargs)
- silo.low_code.get_module_logger(name)
Get a logger for the module
This logger is used when any non-contextually aware information needs to be logged.
- Parameters
name (str) – Name of the module
- Returns
Logger that is used for logging non-contextually aware information
- silo.low_code.get_step_adapter(rc, user_logger)
Get a LogAdapter for context-aware log messages based on the user-provided logger
This adapter updates the log messages to use the Framework’s logging header. These messages will not be available in the snippet_framework logfile but will be captured by the WebUIs logging capturing.
- Parameters
rc (ResultContainer) – Result container containing information about the current collection
user_logger (logger) – Logger for the Adapter
- Returns
A logger adapter with extra content headers.
- silo.low_code.get_step_logger(rc)
Get access to the Snippet Frameworks debug function
This allows a step developer access to write to snippet_framework.log through the debug method. It allows tracing for the framework to be handled in a single log file. If the developer wanted to write “Hello, World!” into the snippet_framework log the following commands would need to be run:
debug = get_step_logger(rc) debug("Hello, World!")
- Parameters
rc (ResultContainer) – Result container containing information about the current collection
- Returns
Debug function for the snippet_framework
- Return type
callable
- silo.low_code.is_sf_supported(*args, **kwargs)
- silo.low_code.read_cached_results(cache_key, reuse_for=None)
Return the most recent cached element for the given cache_key
This function enables the lookup of Snippet Framework cached elements outside of the Snippet Framework. While this function could work with automatic cache keys the Snippet Framework generates, its best used by overriding the cache_key name within the steps configuration.
The functionality of
reuse_for
operates the same way within the Snippet Framework. This value is specified in minutes before a cached entry is considered stale. If this value is specified, an entry is considered stale if the following criteria is met:\[collection\_time + reuse\_for <= current\_time\]If the newest entry is considered stale, the exception silo.apps.cache.CacheDataIsExpired will be raised.
If an invalid object is found (bad formatting within the cache), the exception
MetadataError
will be raised.- Parameters
cache_key (str) – Specified cache_key for the step
reuse_for (int) – Time (in seconds) before considering an entry as stale
- Return type
object
- silo.low_code.register_cacher(*args, **kwargs)
Decorator to register a cacher
Register a cacher that will be validated once the Framework is initialized.
- Parameters
get_req_id (callable) – Optional. Function used for generating the request id
name (str) – Step Name to use for the Custom Step
metadata (dict) – Metadata related to the step
read (callable) – Callable function that performs a cache read for fast-forwarding
required_args (list) – List of required top-level arguments for the step. If these arguments are not present in the action_arg, the Snippet Framework will not attempt to execute the collection and log a warning message instead.
arg_required (bool) – If an argument is required for a step. This denotes a step must have an argument, regardless of the type. This can be used in conjunction with required_args if your step accepts a dictionary or a single value.
- Returns
Original object
- Return type
object
- silo.low_code.register_processor(*args, **kwargs)
Decorator to register a processor
Register a processor that will be validated once the Framework is initialized. There are no sanity checks on a processor so it should always be valid.
- Parameters
get_req_id (callable) – Optional. Function used for generating the request id
name (str) – Step Name to use for the Custom Step
metadata (dict) – Metadata related to the step
type (str) – Type of the step.
required_args (list) – List of required top-level arguments for the step. If these arguments are not present in the action_arg, the Snippet Framework will not attempt to execute the collection and log a warning message instead.
arg_required (bool) – If an argument is required for a step. This denotes a step must have an argument, regardless of the type. This can be used in conjunction with required_args if your step accepts a dictionary or a single value.
- Returns
Original object
- Return type
object
- silo.low_code.register_requestor(*args, **kwargs)
Decorator for registering Requesters
Register a Requester that will be validated once the Framework is initialized. A Requester must inherit from the class
silo.low_code.RequestMaker
.- Parameters
get_req_id (callable) – Optional. Function used for generating the request id
name (str) – Step Name to use for the Custom Step
metadata (dict) – Metadata related to the step
rewind (callable) – Callable function that updates the action_arg to start the rewinding process
required_args (list) – List of required top-level arguments for the step. If these arguments are not present in the action_arg, the Snippet Framework will not attempt to execute the collection and log a warning message instead.
arg_required (bool) – If an argument is required for a step. This denotes a step must have an argument, regardless of the type. This can be used in conjunction with required_args if your step accepts a dictionary or a single value.
- Returns
Original object
- Return type
object
- silo.low_code.snippet_framework(*args, **kwargs)
- silo.low_code.snippet_framework_single(*args, **kwargs)
- silo.low_code.typechecked(*v, **k)
Decorator to check the input and output type of a function or method.
Perform type-checking at run-time to ensure the parameters have the correct types. If an incorrect type is provided, an exception will be raised stating the parameter and type issue.
- Parameters
input (object) – The expected input type. If the typechecking is running against a Requestor it will use request as input. If the typechecking is running against a Processor it will use result as input. If the input is not correct, the exception InputTypeError will be raised.
output (object) – The expected output type. If the output is not correct, the exception OutputTypeError will be raised.
**extra (object) – Used when checking additional parameters. The name must match the parameter. If the input is not correct, the exception InputTypeError will be raised.
Subpackages
- silo.low_code.agent package
- silo.low_code.cli package
- silo.low_code.fixtures package
cache_dict_with_database()
enable_debug()
enable_typechecking()
generate_logpath()
mock_cache_manager()
mock_env_cache()
perform_collector_registration()
pytest_runtest_setup()
register_step()
registrar_clean()
reset_framework()
setup_test_env()
sl1_env_nodebug()
snip_id()
test_caching()
- Submodules
- silo.low_code.framework package
ArgParser
DeviceError
FrameworkError
RequestMaker
RequestMoreData
ResultContainer
ResultContainer.action_number
ResultContainer.argument
ResultContainer.cache_info
ResultContainer.clear_rmd()
ResultContainer.collection
ResultContainer.credential
ResultContainer.current_config
ResultContainer.current_step_info
ResultContainer.current_step_name
ResultContainer.did
ResultContainer.error_data
ResultContainer.execution
ResultContainer.get_rmd()
ResultContainer.index
ResultContainer.indexing
ResultContainer.is_cache_step()
ResultContainer.max_iterations
ResultContainer.metadata
ResultContainer.name
ResultContainer.request_id
ResultContainer.request_ids
ResultContainer.result
ResultContainer.rmd_data
ResultContainer.set_index()
ResultContainer.status
ResultContainer.update_rmd()
String23
add_group_descr()
cleanup_run()
get_module_logger()
get_step_adapter()
get_step_logger()
read_cached_results()
register_cacher()
register_processor()
register_requestor()
register_syntax()
set_typechecking()
snippet_framework()
snippet_framework_single()
time_execution()
typechecked()
unique_id_execution()
- Submodules
- silo.low_code.framework.action_inspection module
- silo.low_code.framework.authenticators module
- silo.low_code.framework.base_classes module
- silo.low_code.framework.caching module
- silo.low_code.framework.config module
- silo.low_code.framework.decorators module
- silo.low_code.framework.entrypoint module
- silo.low_code.framework.exceptions module
AgentError
AuthMethodBadTokenFormat
AuthMethodNotRegistered
CollectionError
ConfigGenerationError
CredAttributeError
CredTypeNotSupported
CredentialError
DeviceError
FrameworkError
FrameworkStopIteration
InputNotFound
InputTypeError
InvalidProtocol
InvalidSnippetArgumentException
InvalidYAML
NetworkRequestException
OutputTypeError
ParserError
RegistrationError
ResultsParsingError
SelectorParsingError
StepInvalidArguments
StepNotRegistered
TypeCheckError
- silo.low_code.framework.framework_logging module
- silo.low_code.framework.pipeline_processing module
- silo.low_code.framework.registrar module
- silo.low_code.framework.result_container module
- silo.low_code.framework.sf_single module
- silo.low_code.framework.sf_typing module
- silo.low_code.framework.snippet_validation module
- silo.low_code.framework.syntax_processing module
- silo.low_code.log_policy package
ConfiguredPolicy
PolicyFilter
PolicyManager
PolicyManager.calculate_ttl()
PolicyManager.delete_policy()
PolicyManager.filter_data()
PolicyManager.get_filter_policies()
PolicyManager.get_filter_policy()
PolicyManager.make_duration_time_human_readable()
PolicyManager.parse_time()
PolicyManager.save_policy()
PolicyManager.validate()
PolicyManager.verify_data_in_sys()
PolicySearch
cleanup_expired_policies()
get_app_header()
get_filtered_policies()
process_logging_policies()
- Submodules