5.8. executions modules
- class capture_it.executions.Execute_By_Individual_Commands(auth, dev_cmd_dict, path='.')
Bases:
Multi_Execution
,Execute_Common
Execute the device capture by logging in to device and running individual commands on to it.
- Parameters:
auth (dict) – authentication parameters ( un, pw, en)
dev_cmd_dict – dictionary of list {device_ip:[commands list,]}
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)
- parsed_output (bool, optional): True: will check the captures and generate the general parsed excel file.
False will omit this step. No excel will be generated in the case. (default: False)
visual_progress (int, optional): 0 will not show any progress, 10 will show all progress (default=3). log_type (str): what type of log output requires. choices are = common, individual, both common_log_file (str): output file name of a common log file 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.
- add_devices(dev_cmd_dict)
check device commands dictionary and returns set of devices
- Parameters:
dev_cmd_dict (dict) – device commands dictionary
- Returns:
None
- add_to(ip, cmds)
adds cmds to the set of commands for given ip in device commands dictionary
- Parameters:
ip (str) – ip address of device
cmds (set) – set of commands to be added for ip
- Returns:
None
- execute(ip)
execution function for a single device. hn == ip address in this case.
- Parameters:
ip (str) – ip address of a reachable device
- individual_device_cmds_dict(dev_cmd_dict)
check device commands dictionary and sets commands list for each of device
- Parameters:
dev_cmd_dict (dict) – device commands dictionary
- Returns:
None
- verify_dev_cmd_dict(dev_cmd_dict)
Verify device commands dictionary dev_cmd_dict format and values. and raises Exceptions for errors. dev_cmd_dict dictionary keys are to be from either of non-iterable type such as (string, tuple, set). dev_cmd_dict dictionary values are to be from either of iterable type such as (list, set, tuple, dict).
- Parameters:
dev_cmd_dict (dict) – device commands dictionary
- Returns:
None
- class capture_it.executions.Execute_By_Login(ip_list, auth, cmds, path='.')
Bases:
Multi_Execution
,Execute_Common
Execute 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)
- parsed_output (bool, optional): True: will check the captures and generate the general parsed excel file.
False will omit this step. No excel will be generated in the case. (default: False)
visual_progress (int, optional): 0 will not show any progress, 10 will show all progress (default=3). log_type (str): what type of log output requires. choices are = common, individual, both common_log_file (str): output file name of a common log file 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.
- execute(ip)
execution function for a single device. hn == ip address in this case.
- Parameters:
ip (str) – ip address of a reachable device
- update_all_cmds(ED)
update executed commands for all commands dictionary
- Parameters:
ED (Execute_Device) – Device Execution object instance
- class capture_it.executions.Execute_Common(auth)
Bases:
object
common methods/variables declaration in a Execute Common class
- Args:
auth (dict): authentication parameters
- Raises:
Exception – raise exception if any issue with authentication or connections.
- add_auth_para(auth)
add authentication parameters to self instance
- Parameters:
auth (dict) – authentication parameters
- Returns:
None
- dependent_cmds(custom_dynamic_cmd_class)
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
- ff_sequence(ED, CustomDeviceFactsClass, foreign_keys)
facts finder execution sequences
- Parameters:
ED (Execute_Device) – Execute_Device class instance post capture finishes
CustomDeviceFactsClass (class) – class definition for the modification of excel facts with custom properties.
foreign_keys (_type_) – custom keys(aka: custom columns)
- generate_facts(CustomDeviceFactsClass=None, foreign_keys={})
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)
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
- set_defaults()
setting the default value for optional user input parameters
- verifications()
Verification/Validation of input values