DumpResults

Function to take data and save it to the file, adding details to ToFileProcessor and files task text database index.

DumpResults does not perform any formatting on data supplied, if it is string, it is saved as is, if it is anything but string data converted to string using str(data) prior to saving it.

Primary use case for DumpResults is mainly related to Salt Stack restriction on Event Bus maximum data transmission size, as a result in certain cases need to save full results to local file system instead.

DumpResults sample usage

Code to invoke DumpResults function

from nornir import InitNornir
from nornir_salt.plugins.functions import TabulateFormatter, DumpResults
from nornir_netmiko import netmiko_send_command

nr = InitNornir(config_file="config.yaml")

result = NornirObj.run(
    task=netmiko_send_command,
    command_string="show clock"
)

serialized_output = ResultSerializer(result)
DumpResults(serialized_output, filegroup="running_config", base_url="./tofile_outputs/")

DumpResults reference

nornir_salt.plugins.functions.DumpResults.DumpResults(results, filegroup, base_url='/var/nornir-salt/', max_files=50, index='common', proxy_id='untitled')

Function to save results to local file system and update ToFileProcessor and files task text database index.

Parameters
  • results – (str, any) data to save

  • filegroup – (str) tf file group name of files to save

  • base_url – (str) OS path to folder where to save files, default “/var/nornir-salt/”

  • index – (str) index name to read files index data from

  • proxy_id – (str) filename identifier, usually equal to Proxy Minion ID

  • max_files – (int) maximum number of files to save, older files deleted once limit reached

Returns

None

Filename to save results formed using this formatter:

/{base_url}/{filegroup}__{timestamp}__{rand}__{proxy_id}.txt

Where:

  • base_url - OS path to folder where to save files

  • filegroup - tf file group name of files

  • timestamp - formed using “%d_%B_%Y_%H_%M_%S” time.strftime formatter

  • rand - random integer from 0-1000 range

  • proxy_id - Name of Proxy Minion ID