Skip to main content

Generating network configuration with Excel sheets which include Jinja2 templates and data tables

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

excel2config-2023.7.8.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

excel2config-2023.7.8-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file excel2config-2023.7.8.tar.gz.

File metadata

  • Download URL: excel2config-2023.7.8.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for excel2config-2023.7.8.tar.gz
Algorithm Hash digest
SHA256 820388914286855cf0d077a58b36d449c48b7c708359757e4b5a3023352ff07e
MD5 eb894564cf37c6fcdd7c245398229746
BLAKE2b-256 5cb7368206ed14e38b1ec12ea5695882ffa39aafe18574c8318060cf0384d8c6

See more details on using hashes here.

File details

Details for the file excel2config-2023.7.8-py3-none-any.whl.

File metadata

File hashes

Hashes for excel2config-2023.7.8-py3-none-any.whl
Algorithm Hash digest
SHA256 aa51c7bade4eee9716163b7dfb53a8cbd57ea36362b160481fa19bd3ae8313d5
MD5 d994338bedd27bba138b6e351c476857
BLAKE2b-256 78189dfa270788575406e782d74f7e1d422fec04d962a4d6e41216aa23d7f910

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page