Skip to content

microsoft/Azure_Local_Physical_Network_Config_Tool

Network Configuration Generation Tool

Overview

This tool generates vendor-specific network switch configurations (e.g., Cisco NX-OS, Dell OS10) using JSON input and Jinja2 templates. It supports both Python source usage and standalone executables.

Documentation:


Quick Start

Option A: Standalone Executable (No Python Required)

Download from Releases, then:

# See all options
./network_config_generator -h

# Generate configs from standard-format JSON
./network_config_generator --input_json input/standard_input.json --output_folder output/

# Generate from custom-format JSON (auto-converts)
./network_config_generator --input_json my_input.json --output_folder configs/ --convertor lab

# Include debug data (vlan_map, ip_map) in converted JSON
./network_config_generator --input_json my_input.json --output_folder configs/ --debug

Option B: Python Source

# Install dependencies
pip install -r requirements.txt

# Generate from standard-format JSON
python -m src.main --input_json input/standard_input.json --output_folder output/

# Generate from custom-format JSON with auto-conversion
python -m src.main --input_json my_input.json --output_folder configs/ --convertor lab

# Include debug data in converted JSON output
python -m src.main --input_json my_input.json --output_folder configs/ --debug

# Run tests
python -m pytest tests/ -v

Output

The tool produces individual section configs plus a merged full config:

output/
├── generated_system.cfg
├── generated_vlan.cfg
├── generated_interface.cfg
├── generated_port_channel.cfg
├── generated_bgp.cfg
├── generated_prefix_list.cfg
├── generated_qos.cfg
├── generated_login.cfg
└── generated_full_config.cfg

Architecture

Pipeline

flowchart LR
    A["Standard Input JSON"] -->|Load Variables| E("Config Generator")
    C["Jinja2 Templates"] -->|Provide Templates| E
    E -->|Render| G["Generated .cfg Files"]
Loading

Converter Support

Non-standard inputs can be transformed to standard format via pluggable converters:

flowchart LR
    U1["Custom Format<br/>(JSON, CSV, YAML, etc.)"] -->|Converter| S1["Standard JSON"]
    S1 --> G["Generator + Templates → .cfg"]
Loading

Note

The standard JSON format must match the variables used in Jinja2 templates. You can safely update values but the structure must stay fixed.


Directory Structure

├── docs/                               # Documentation
│   ├── TEMPLATE_GUIDE.md               # Jinja2 + switch interface template guide
│   ├── CONVERTOR_GUIDE.md              # Custom converter guide
│   └── TROUBLESHOOTING.md              # Common issues and solutions
├── input/
│   ├── standard_input.json             # Standard format example
│   ├── jinja2_templates/               # Jinja2 config templates
│   │   ├── cisco/nxos/                 # 10 templates (bgp, vlan, interface, …)
│   │   └── dellemc/os10/              # 11 templates (+ vlt.j2)
│   └── switch_interface_templates/     # Switch model definitions
│       ├── cisco/                      # 93108TC-FX3P, 93180YC-FX, 93180YC-FX3,
│       │                               # 9348GC-FXP, 9348GC-FX3
│       └── dellemc/                    # N3248TE-ON, S5248F-ON
├── src/
│   ├── main.py                         # CLI entry point
│   ├── generator.py                    # Jinja2 rendering engine
│   ├── loader.py                       # Input file loading and parsing
│   ├── constants.py                    # Shared constants (VLAN maps, templates)
│   ├── utils.py                        # Helpers (infer_firmware, classify_vlan)
│   └── convertors/
│       ├── convertors_lab_switch_json.py  # Input format converter (TOR switches)
│       └── convertors_bmc_switch_json.py  # Input format converter (BMC switches)
├── tests/
│   ├── conftest.py                     # Shared fixtures and helpers
│   ├── test_unit.py                    # Unit tests (88 tests)
│   ├── test_convertors.py             # Golden-file converter tests (12 tests)
│   ├── test_generator.py              # Golden-file generator tests (6 tests)
│   ├── test_submission_flow.py         # Submission workflow & template tests (121 tests)
│   └── test_cases/                     # Test data (6 converter + 3 generator cases)
├── tools/                              # Utility scripts (IP mgmt, port mapping)
└── requirements.txt                    # Python dependencies

Input & Output Examples

Standard Input JSON

{
  "switch": {
    "hostname": "tor-switch-1",
    "make": "cisco",
    "firmware": "nxos"
  },
  "vlans": [
    { "vlan_id": 711, "name": "Compute" }
  ],
  "interfaces": [
    { "name": "Ethernet1/1", "vlan": 711, "description": "Compute1" }
  ],
  "bgp": {
    "asn": 65001,
    "router_id": "192.168.0.1"
  }
}

Sample Template (Jinja2)

router bgp {{ bgp.asn }}
  router-id {{ bgp.router_id }}

See docs/TEMPLATE_GUIDE.md for complete template reference.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 5