3.9. executions modules
- class nettoolkit.capture_it.executions.Execute_By_Excel(auth, input_file, capture_path='.', exec_log_path='.')[source]
Bases:
Execute_Common,Multi_Execution
- class nettoolkit.capture_it.executions.Execute_By_Individual_Commands(auth, dev_cmd_dict, capture_path=None, exec_log_path='.', path='.')[source]
Bases:
Multi_Execution,Execute_CommonDEPRYCATED
- class nettoolkit.capture_it.executions.Execute_By_Login(ip_list, auth, cmds, capture_path=None, exec_log_path='.', path='.')[source]
Bases:
Multi_Execution,Execute_CommonExecute the device capture by logging in to device.
- Parameters:
ip_list (set, list, tuple) – set of ip addresses to be logging for capture
auth (dict) – authentication parameters ( un, pw, en)
cmds (set, list, tuple) – set of commands to be captured
path (str) – path where output(s), logs(s) should be stored.
Properties:
cumulative (bool, optional): True: will store all commands output in a single file, False will store each command output in differet file. Defaults to False. and ‘both’ will do both.
forced_login (bool, optional): True: will try to ssh/login to devices even if ping respince fails. False will try to ssh/login only if ping responce was success. (default: False)
max_connections (int, optional): 100: manipulate how many max number of concurrent connections to be establish. default is 100.
CustomClass (class): Custom class definitition to execute additional custom commands
- Raises:
Exception – raise exception if any issue with authentication or connections.
- class nettoolkit.capture_it.executions.Execute_Common(auth, capture_path, exec_log_path)[source]
Bases:
objectcommon methods/variables declaration in a Execute Common class
- Parameters:
auth (dict) – authentication parameters
capture_path (str) – path to where captures to be stored
exec_log_path (str) – path to where device execution logs to be stored.
- Raises:
Exception – raise exception if any issue with authentication or connections.
- dependent_cmds(custom_dynamic_cmd_class)[source]
Provide dependent commands via a class definition. A new variable set of commands can be passed here using defined custom_dynamic_cmd_class class. Defined class must have an abstract property called cmds. which should return a new set/list of commands to be executed. A good example of usage of it is - derive the bgp neighbor ip addresses from show ip bgp summary output, and then create new set of commands to see advertised route for those neighbor ip addresses. In this way no need to create a separate set of show commands for multiple devices, custom class will take care of generating additional show commands to see advertized routes based on neighbors appear on bgp summary output. ( ofcouse, show ip bgp summary should be there in original show capture )
- Parameters:
custom_dynamic_cmd_class (_type_) – _description_
- Raises:
Exception – invalid input custom_dynamic_cmd_class for wront types
Exception – mandatory property missing cmds for missing property in provided class
- generate_clean_facts_file(executed_device)[source]
generate facts-generator clean file
- Parameters:
executed_device (Execute_Device) – Device Execution object instance
- generate_facts(CustomDeviceFactsClass=None, foreign_keys={})[source]
generate excel facts -clean.xlsx file using facts finder
- Parameters:
CustomDeviceFactsClass (class, optional) – class definition for the modification of excel facts with custom properties. Defaults to None.
foreign_keys (dict, optional) – custom keys(aka: custom columns) here in order to accept them and display in appropriate order. Defaults to {}.
- Raises:
Exception – Invalid type: foreign_keys if recieved in format other than dict.
- is_valid(ip)[source]
Validation function to check if provided ip is valid IPv4 or IPv6 address
- Parameters:
ip (str) – ipv4 or ipv6 address
- Returns:
True/False based on validation success/fail
- Return type:
bool
- log_summary(*, onscreen, to_file=None, excel_report_file=None)[source]
display and write log summary to output file(s)
- Parameters:
onscreen (bool) – Display report on screen
to_file (str, optional) – text file name to store summary report. Defaults to None. (Deprycated, and fn removed..)
excel_report_file (str, optional) – excel file name to store summary report. Defaults to None.
- property show_failures
Displays failure summary
- update_all_cmds(executed_device)[source]
update executed commands for all commands dictionary
- Parameters:
executed_device (Execute_Device) – Device Execution object instance
- update_other_properties(executed_device, ip)[source]
update other properties of the current object
- Parameters:
executed_device (Execute_Device) – Device Execution object instance
ip (str) – device ip address or FQDN
- write_exec_log(executed_device)[source]
write/display execution log file for the devices
- Parameters:
executed_device (Execute_Device) – Device Execution object instance