collector module
- class collector.Collector[source]
Bases:
object
A class to collect, format and print information gathered from hosts.
- json_indentation
The default is
4
. It can be changed in the configuration.--- defaults: report_types: - html - json:2
- Type:
int
- htmltop
html snippet for html report. See
constants.Constants.HTML_TOP
.- Type:
str
- htmlbottom
html snippet for html report. See
constants.Constants.HTML_BOTTOM
.- Type:
str
- collected_objects
[ { "group": "awesomegroup", "host": "some-switch", "errors": [], "rc": 0, "output": { "cmds_before": [ "ip name-server 8.8.8.8" ], "cmds_after": [ "ip name-server 9.9.9.9" ] }, "message": "ok", "config": { "settings": { "device_type": "cisco_ios", "connection_timeout": 10, "read_timeout": 10, "silent": True, "conf_cmds": [ "no ip name-server 8.8.8.8", "ip name-server 9.9.9.9" ], "cmds_before": [ "show run | include name-server" ], "cmds_after": [ "show run | include name-server" ], "log_file": "~/.conquers/some-switch.log" }, "credentials": { "user": "admin", "host": "some-switch", "encrypted_pass": "********", "pass": "********" } } }, ]
- Type:
list
- hosts_by_group
{ "awesomegroup": [ { "another-switch": { "errors": [], "rc": null, "message": "skipped", "config": { "host": "another-switch", "settings": { "device_type": "cisco_ios", "connection_timeout": 10, "read_timeout": 10, "silent": true }, "credentials": false } } }, { "some-switch": { "errors": [], "rc": 0, "output": { "cmds_before": [ "ip name-server 8.8.8.8" ], "cmds_after": [ "ip name-server 9.9.9.9" ] }, "message": "ok", "config": { "settings": { "device_type": "cisco_ios", "connection_timeout": 10, "read_timeout": 10, "silent": true, "conf_cmds": [ "no ip name-server 8.8.8.8", "ip name-server 9.9.9.9" ], "cmds_before": [ "show run | include name-server" ], "cmds_after": [ "show run | include name-server" ], "log_file": "~/.conquers/some-switch.log" }, "credentials": { "user": "admin", "host": "some-switch", "encrypted_pass": "********", "pass": "********" } } } } ], "anothergroup": [ "..." ], }
- Type:
dict
- add_to_collection(item) None [source]
Adds item to collected_objects
- Parameters:
item (dict) – Object to add
- hide_passwords(data) None [source]
Overrides password strings with * for console output.
- Parameters:
data (dict) –
- log_to_file(data) None [source]
If log_file is specified in the configuration, the output of commands sent to a swtich and information about the host are logged to this file.
- log_to_report() None [source]
Logs a full report if configured in the configuration file. Three output format are possible:
html (fancy, recommended for humans)
yaml
json or json:<indentation>