Package: netauto-utils
Network Automation UtilitiesThis package contains a variety of modules. Some are for general Python tasks like file conversions, others are for aiding Network Engineering  Automation. I have and still use many of these utilities as an Automation Engineer.InstallationRunpip install netauto_utilspoetry add netauto_utils`.If you cannotinstall, clone the repository & runpoetry installto install the package.NOTE:Other package managers such aspipcan also be used for installation.You can also clone and install the package locally with:$gitclonehttps://github.com/ns03444/netauto_utils.git
$cdnetauto_utils
$poetryinstall# Use --no-dev if you don't want development dependenciesQuick StartExample of using a utility in thedata_convertermodule to convert a Python object to a YAML file:See source code for more info on the utilities and their associated parameters.# Import module>>>>>>fromnetauto_utilsimportdata_converter>>>>>>python_obj={..."Yaml Data":[...{"a":1,"b":2},...{"c":3,"d":4},...{"e":5,"f":6},...]...}>>>>>>write_file=True>>>>>>filename='my_new_yaml_file.yml'>>>>>>>>>print(data_converter.python_to_yaml(python_obj,write_file,filename))my_new_yaml_file.ymlhasbeencreated!👍YamlData:-a:1b:2-c:3d:4-e:5f:6>>>The new YAML file generatedmy_new_yaml_file.yml.---
Yaml Data:
  - a: 1
    b: 2
  - c: 3
    d: 4
  - e: 5
    f: 6Modulescisco_showThis is a Python module that contains functions that retrieve various information from a Cisco device. It uses the Netmiko library to establish a connection to the device and send commands to it. The information it retrieves includes IP interface brief information, the primary IP address for a given interface, the access control lists and prefix lists used in a given route map, and BGP peer information for the default VRF. The module also contains some other functions that are used to process and manipulate this data.command_senderThis is a Python module that contains functions for sending show and configuration commands to a remote network device using the Netmiko library. It can be used to establish an SSH connection to the device, send commands to it, and retrieve the output. The module includes functions for opening and closing a connection to the device, sending configuration commands, and sending show commands. It also includes a function for parsing the output of show commands using TextFSM. The module also contains some error handling to catch and handle common exceptions that may occur when using Netmiko.data_converterThis is a Python module that contains functions for performing various types of data formatting conversions. It includes functions for converting data between different formats, such as Python dictionaries and lists to YAML or JSON, and for reading and writing data to and from files in different formats. It also includes a function for reading data from a CSV file and returning it as a list of dictionaries. The module uses the json, yaml, and csv libraries to handle these conversions. It also includes some error handling to catch and handle exceptions that may occur when reading or writing data to files.ip_addressThe function ipwildcard_to_cidr() takes an IP address and a wildcard mask as input, and returns the IP address in CIDR notation.The function ipnetmask_to_cidr() takes an IP address and a subnet mask as input, and returns the IP address in CIDR notation.The function get_port_number() takes a transport protocol name as input, and returns the port number associated with the protocol. If the protocol name is not recognized, it returns the original protocol name.The function cidr_to_ipnetmask() takes an IP address in CIDR notation as input, and returns the IP address and its corresponding subnet mask.The function prefix_to_wildcard() takes a prefix length as input and returns the corresponding wildcard mask.The function netmask_to_wildcard() takes a subnet mask as input and returns the corresponding wildcard mask.The function wildcard_to_netmask() takes a wildcard mask as input and returns the corresponding subnet mask.Cutting a New ReleaseCheckout develop branch - ensure you have the latest commits by running git pullCreate new branch - git checkout -bPerform the following operations:Run poetry version <major/minor/patch> to update version in pyproject.tomlEdit CHANGELOG.md - Update for new version with changes included in new versionRun poetry update to update Python dependenciesCommit all changes - push branch to GitLabOpen new MR for your new branch into masterAfter the merge is completed, cut a new tag (Repository > Tags > Name: vX.X.X)Open new MR from master into develop to sync branches (master will not be deleted).