Coder Social home page Coder Social logo

umurarslan / excel2config Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 152 KB

Simple CLI tool generates network configuration based on Excel sheets which include Jinja2 template and data tables.

License: MIT License

Python 100.00%
config-generator jinja2 network network-automation network-configuration networking networking-in-python configuration excel import-excel network-programming python cisco nokia

excel2config's Introduction

Excel2Config

Excel2Config simple CLI tool generates network configuration based on Excel sheets which include Jinja2 template and data tables.


Requirements

Python >= 3.9

For Windows, select the Add Python 3.x to PATH checkbox during installation.


Installation

pip install excel2config

Installation Check

After installation excel2config command added to System Path and can be executed from any path easily as below:

> excel2config -h
usage: excel2config [-h] [excelfile]

positional arguments:
  excelfile   excel file path [e.g. srlinux_config_1.xlsx] (OPTIONAL, default: config.xlsx)

options:
  -h, --help  show this help message and exit

Usage

Simple Usage

Run excel2config command with Excel File Path from any path and check text output files in Output Folder:

excel2config <Excel_File_Path>

Example for Windows:

PS C:\Users\alg\desktop> excel2config C:\Users\alg\Desktop\test\config.xlsx
2022-07-17 09:07:40.275 INFO : OUTPUT FOLDER CREATED <OUTPUTS_config_20220717-090740>
2022-07-17 09:07:40.447 INFO : [C:\Users\alg\Desktop\test\config.xlsx] / [<Worksheet "NETWORK_INSTANCE">] START!
2022-07-17 09:07:40.463 INFO : [C:\Users\alg\Desktop\test\config.xlsx] / [<Worksheet "NETWORK_INSTANCE">] DONE!
2022-07-17 09:07:40.479 INFO : ALL DONE!
!!! ALL DONE! Press any key to exit...

PS C:\Users\alg\desktop> dir OUTPUTS_config_20220717-090740

    Directory: C:\Users\alg\desktop\OUTPUTS_config_20220717-090740

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        17/07/2022     09:07            426 leaf1.txt
-a----        17/07/2022     09:07            258 leaf2.txt

PS C:\Users\alg\desktop>

Excel File

Only .xlsx Excel file format supported.

For new features (e.g. Custom Jinja Function) check latest example Excel in project /examples folder.

In Excel File first sheet is GLOBAL_VARS, this sheet optional and only for global template variables such as host-based (e.g. leaf1), all-host (ALL) and generator (GEN).

GLOBAL_VARS Excel Sheet:

GLOBAL_VARS Excel Sheet

Besides GLOBAL_VARS sheet, other sheets have two parts:

  • Jinja2 Template (A2 cell): Jinja2 "IF", "FOR" and Filters can be used in template cell.
  • Data Tables (Header rows start with B2 cell, Variable rows start with B3 cell): Range and generator supported in variable rows.

Sheet name and Data Header name must have only [A-Za-z0-9_] (alphanumeric with underscore) characters and not start with numeric characters.

Sheet name starts with underscore "_" will be ignored. (e.g. _TEST)

As below example Jinja template render with every data table line and append host (e.g. leaf1) output text file.

INTERFACE_CONFIG Excel Sheet:

INTERFACE_CONFIG Excel Sheet

INTERFACE_CONFIG "leaf1.txt" outputs:

interface ethernet 1/1/1
  description red_1
  no shutdown
  mtu 1500
  vrf member red
  no ip redirects
  ip address 10.1.1.100/24

OTHER_CONFIG Excel Sheet:

OTHER_CONFIG Excel Sheet

Example Excel file and outputs are in project /examples folder.

EOF

excel2config's People

Contributors

umurarslan avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.