7.1. Facts Generator
7.1.1. facts_gen
Boiler plate code for the facts generation. fg_dict: attribute will provide the output dictionary with pandas dataframe as values to be readily available to write it to excel. dev_type: attribute returns the device type of configuraton provided
- class nettoolkit.facts_finder.generators.facts_gen.FactsGen(capture_file)[source]
Bases:
objectFacts Generator class (boiler plate code)
- Parameters:
capture_file (str) – configuration capture file
- property dev_type
detected device type for the given configuration capture
- Raises:
Exception – for Invalid device type
Exception – for Missing FactsGen call
- Returns:
returns device type in string
- Return type:
str
- property fg_dict
facts generator dictionary
- Returns:
dataframe dictionary
- Return type:
dict
- reset_interfaces_index(df_dict)[source]
reset Interfaces to interface and remove it from index
- Parameters:
df_dict (dict) – dataframe dictionary
- nettoolkit.facts_finder.generators.facts_gen.get_absolute_command(dev_type, cmd)[source]
retrive absolute command for given command of device type.
- Parameters:
dev_type (str) – device type (cisco_ios, juniper_junos)
cmd (str) – full/shortened command
- Returns:
full length absolute command
- Return type:
str
7.1.2. clean
Device Facts cleanup
- class nettoolkit.facts_finder.clean.CleanFacts(capture_log_file, capture_parsed_file=None, convert_to_cit=False, remove_cit_bkp=True, skip_txtfsm=False, new_suffix='-clean', use_cdp=False, debug=False, output_folder='.')[source]
Bases:
objectcleans the captured parsed file and writes out the modified facts in new clean file using additional information provided from capture log file. Also can get a few additional properties to process futher. A new clean file will be generated upon instance calling.
- Parameters:
capture_log_file (str) – configuration capture log file name
capture_parsed_file (str) – configuration parsed excel file name
convert_to_cit (bool, optional) – convert normal capture log file to capture_it output format (useful if capture was taken manually). Defaults to False.
remove_cit_bkp (bool, optional) – remove duplicated log file (capture_it output format). Defaults to True.
skip_txtfsm (bool, optional) – skip evaluation of capture excel file (textfsm parsed file), and use native facts-finder parsers. Defaults to False.
new_suffix (str, optional) – file suffix. Defaults to ‘-clean’.
use_cdp (bool, optional) – use cdp neighbor (overrides lldp neighbor) . Defaults to False.
debug (bool, optional) – for trouble shooting purpose only. Defaults to False.
- property clean_file
new output clean filename
- property config
device configuration. for cisco show running, for juniper show configuration - set output
- property dev_type
device type string either(cisco/juniper)
- property hostname
device hostname
- nettoolkit.facts_finder.clean.cisco_config(capture_log_file)[source]
returns cisco running configuration
- Parameters:
capture_log_file (str) – device captured log
- Returns:
configuration output in list
- Return type:
list
- nettoolkit.facts_finder.clean.get_clean_filename(path, file, suffix)[source]
get a new clened filename appended with suffix string
- Parameters:
path (str) – full path with output file name
file (str) – capture file name
suffix (str) – suffix to be appened
- Returns:
updated file name
- Return type:
str
- nettoolkit.facts_finder.clean.get_hostname_from_logfile(file)[source]
get device hostname from log file name
- Parameters:
file (str) – full path with output file name
- Returns:
updated file name
- Return type:
str