diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 25ed646..0000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,72 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ main ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ main ] - schedule: - - cron: '22 0 * * 2' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ "go" ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v4 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ā„¹ļø Command-line programs to run using the OS shell. - # šŸ“š See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/README.md b/README.md index 8283f79..fb7a3ed 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,6 @@ - [Sample Input JSON](#sample-input-json) - [Sample Template (Jinja2)](#sample-template-jinja2) - [Quick Start](#quick-start) - - [Choose Your Path](#choose-your-path) - - [Basic Usage](#basic-usage) - - [Quick Examples](#quick-examples) - [What's Improved in This Version](#whats-improved-in-this-version) - [Key Enhancements](#key-enhancements) @@ -27,7 +24,7 @@ This tool generates vendor-specific network switch configurations (e.g., Cisco N **First time here?** Choose your path: -- **Just want to use it?** → [`docs/EXECUTABLE_USAGE.md`](docs/EXECUTABLE_USAGE.md) +- **Just want to use it?** → [`docs/QUICK_START.md`](docs/QUICK_START.md) - **Need to convert your data format?** → [`docs/CONVERTOR_GUIDE.md`](docs/CONVERTOR_GUIDE.md) - **Want to customize templates?** → [`docs/TEMPLATE_GUIDE.md`](docs/TEMPLATE_GUIDE.md) - **Need to create/modify switch templates?** → [`docs/SWITCH_INTERFACE_TEMPLATE.md`](docs/SWITCH_INTERFACE_TEMPLATE.md) @@ -157,7 +154,7 @@ root/ ā”œā”€ā”€ build/ # Build artifacts and executables ā”œā”€ā”€ docs/ # Documentation files │ ā”œā”€ā”€ CONVERTOR_GUIDE.md # Guide for creating custom convertors -│ ā”œā”€ā”€ EXECUTABLE_USAGE.md # Standalone executable usage guide +│ ā”œā”€ā”€ QUICK_START.md # Quick start and executable usage guide │ ā”œā”€ā”€ SWITCH_INTERFACE_TEMPLATE.md # Switch interface template guide │ ā”œā”€ā”€ TEMPLATE_GUIDE.md # Jinja2 template development guide │ └── TROUBLESHOOTING.md # Common issues and solutions @@ -231,51 +228,7 @@ router bgp {{ bgp.asn }} ## Quick Start -### Choose Your Path - -**New to this tool?** Start here based on what you want to do: - -| I want to... | Go to | -|--------------|--------| -| **Use the precompiled executable** (no coding needed) | [`docs/EXECUTABLE_USAGE.md`](docs/EXECUTABLE_USAGE.md) | -| **Convert my custom input format** | [`docs/CONVERTOR_GUIDE.md`](docs/CONVERTOR_GUIDE.md) | -| **Create or modify configuration templates** | [`docs/TEMPLATE_GUIDE.md`](docs/TEMPLATE_GUIDE.md) | -| **Create or modify switch interface templates** | [`docs/SWITCH_INTERFACE_TEMPLATE.md`](docs/SWITCH_INTERFACE_TEMPLATE.md) | -| **Understand the tool's architecture** | [`docs/TOOL_DESIGN.md`](docs/TOOL_DESIGN.md) | -| **Fix issues or troubleshoot** | [`docs/TROUBLESHOOTING.md`](docs/TROUBLESHOOTING.md) | - -### Basic Usage - -The tool accepts these parameters: - -| Parameter | Required | Description | -|-------------------|----------|-------------| -| `--input_json` | āœ… Yes | Path to your input JSON file (lab or standard format) | -| `--output_folder` | āŒ No | Directory to save generated configs (default: current directory) | -| `--template_folder` | āŒ No | Folder containing Jinja2 templates (default: input/jinja2_templates) | -| `--convertor` | āŒ No | Convertor to use for non-standard formats (default: convertors.convertors_lab_switch_json) | - -### Quick Examples - -```bash -# Basic usage - auto-detects input format -python src/main.py --input_json input/standard_input.json --output_folder output/ - -# With custom output directory -python src/main.py --input_json my_input.json --output_folder configs/ - -# Using short convertor alias -python src/main.py --input_json lab_input.json --output_folder output/ --convertor lab - -# Using the standalone executable (Windows) -network_config_generator.exe --input_json input/standard_input.json --output_folder output/ - -# Using the standalone executable (Linux) -./network_config_generator --input_json input/standard_input.json --output_folder output/ -``` - -> [!IMPORTANT] -> **Tip:** The tool automatically detects if your input is in standard format or needs conversion! +For detailed usage instructions, examples, and setup steps, see [`docs/QUICK_START.md`](docs/QUICK_START.md). --- diff --git a/docs/EXECUTABLE_USAGE.md b/docs/QUICK_START.md similarity index 60% rename from docs/EXECUTABLE_USAGE.md rename to docs/QUICK_START.md index dd8d7e3..e3c084a 100644 --- a/docs/EXECUTABLE_USAGE.md +++ b/docs/QUICK_START.md @@ -13,21 +13,42 @@ The easiest way to use this tool is with our pre-built executables. No need to i ## šŸš€ Quick Start -### Step 1: Prepare your input file -- Any JSON file with your switch data works -- Tool automatically detects the format -### Step 2: Generate configs -```bash +To see all available options and usage details, run the executable with the `-h` or `--help` flag: + +```powershell # Windows -.\network_config_generator.exe --input_json your_switches.json --output_folder configs\ +.\network_config_generator.exe -h # Linux -# Make it executable (Linux only) -chmod +x network_config_generator -./network_config_generator --input_json your_switches.json --output_folder configs/ +./network_config_generator -h +``` + +This will display a summary of command-line arguments, default values, and workflow steps. +```powershell +> .\network_config_generator.exe -h +usage: network_config_generator.exe [-h] --input_json INPUT_JSON [--template_folder TEMPLATE_FOLDER] + [--output_folder OUTPUT_FOLDER] [--convertor CONVERTOR] + +options: + -h, --help show this help message and exit + --input_json INPUT_JSON + Path to input JSON file (lab or standard format) + --template_folder TEMPLATE_FOLDER + Folder containing Jinja2 templates (default: input/jinja2_templates) + --output_folder OUTPUT_FOLDER + Directory to save generated configs (default: same directory as input file) + --convertor CONVERTOR + Convertor to use for non-standard input formats (default: + convertors.convertors_lab_switch_json) + +Examples: + network_config_generator.exe --input_json input/standard_input.json --output_folder output/ + network_config_generator.exe --input_json my_lab_input.json --output_folder configs/ --convertor lab ``` +![Network Config Generator Demo](./media/network-config-generator01.gif) + ## šŸ“‹ What You Get @@ -49,41 +70,6 @@ configs/ └── ... (same files) ``` -## āš™ļø Advanced Options - -To see all available options and usage details, run the executable with the `-h` or `--help` flag: - -```bash -# Windows -.\network_config_generator.exe -h - -# Linux -./network_config_generator -h -``` - -This will display a summary of command-line arguments, default values, and workflow steps. -```powershell -PS C:\Users\liunick\Downloads\config_test> .\network_config_generator.exe -h -usage: network_config_generator.exe [-h] --input_json INPUT_JSON [--template_folder TEMPLATE_FOLDER] - [--output_folder OUTPUT_FOLDER] [--convertor CONVERTOR] - -Network config generator - automatically detects input format and converts if needed, then generates configs. - -options: - -h, --help show this help message and exit - --input_json INPUT_JSON - Path to input JSON file (can be lab format or standard format) - --template_folder TEMPLATE_FOLDER - Root folder containing vendor templates (default: input/jinja2_templates) - --output_folder OUTPUT_FOLDER - Directory to save generated config files (default: current directory) - --convertor CONVERTOR - Python module path for the convertor to use when input is not in standard format. Only used if - conversion is needed. (default: convertors.convertors_lab_switch_json) - -Workflow: 1) Check if input is standard format 2) If not, convert using specified convertor 3) Generate config files -from standard format -``` ## šŸ†˜ Need Help? diff --git a/docs/media/network-config-generator01.gif b/docs/media/network-config-generator01.gif new file mode 100644 index 0000000..d9a7bce Binary files /dev/null and b/docs/media/network-config-generator01.gif differ diff --git a/tests/TEST_CASES_SUMMARY.md b/tests/TEST_CASES_SUMMARY.md new file mode 100644 index 0000000..95097ea --- /dev/null +++ b/tests/TEST_CASES_SUMMARY.md @@ -0,0 +1,47 @@ +# Test Cases Summary + +## Quick Reference +**Status**: āœ… All tests passing (38 passed, 8 skipped) +**Run Tests**: `python -m pytest tests/ -v` + +### Understanding Test Results +- āœ… **Passed**: Test executed and validation succeeded (38 tests) +- ā­ļø **Skipped**: Expected baseline files don't exist (8 tests - missing full_config.cfg files) +- āŒ **Failed**: Would indicate actual test failure (none currently) + +--- + +## Test Scenarios + +### Configuration Generator Tests (`test_generator.py`) +**Total: 34 tests** | 29 passed āœ… | 5 skipped + +| Test Scenario | Count | Description | +|--------------|-------|-------------| +| `test_generated_config_output` | 28 | Compares generated config files against expected outputs | +| `test_config_syntax_validation` | 3 | Validates syntax of generated configuration files | +| `test_output_file_generation` | 3 | Verifies output files are created successfully | + +**Test Cases Coverage:** +- āœ… `std_cisco_nxos_fc` - Cisco NX-OS Fully Connected (9 config files validated) +- āœ… `std_cisco_nxos_switched` - Cisco NX-OS Switched (8 passed, 1 skipped: full_config.cfg) +- āœ… `std_dell_os10_fc` - Dell OS10 Fully Connected (9 passed, 1 skipped: full_config.cfg) + +> **Note**: Only `full_config.cfg` files are skipped (typically not used in production deployments) + +### Lab Input Convertor Tests (`test_convertors.py`) +**Total: 12 tests** | 9 passed āœ… | 3 skipped + +| Test Scenario | Count | Description | +|--------------|-------|-------------| +| `test_convert_switch_input_json` | 4 | Converts lab format to standard format and validates | +| `test_input_format_validation` | 4 | Validates lab input format structure | +| `test_output_format_validation` | 4 | Validates standard output format structure | + +**Test Cases Coverage:** +- āœ… `convert_lab_switch_input_json_cisco_nxos_fc` - Cisco NX-OS Fully Connected (validated) +- ā­ļø `convert_lab_switch_input_json_cisco_nxos_switched` - Cisco NX-OS Switched (skipped: missing BMC outputs) +- āœ… `convert_lab_switch_input_json_cisco_nxos_switchless` - Cisco NX-OS Switchless (validated) +- āœ… `convert_lab_switch_input_json_dell_os10` - Dell OS10 (validated) + +> **Note**: Some expected output files may differ from generated ones (e.g., BMC switch definitions) - these tests are skipped until baselines are updated. diff --git a/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_fc/expected_outputs/s46-r21-93180hl-24-1a.json b/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_fc/expected_outputs/s46-r21-93180hl-24-1a.json new file mode 100644 index 0000000..7c091e0 --- /dev/null +++ b/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_fc/expected_outputs/s46-r21-93180hl-24-1a.json @@ -0,0 +1,623 @@ +{ + "switch": { + "make": "cisco", + "model": "93180yc-fx3", + "type": "TOR1", + "hostname": "s46-r21-93180hl-24-1a", + "version": "10.3(4a)", + "firmware": "nxos", + "site": "rr1" + }, + "vlans": [ + { + "vlan_id": 2, + "name": "UNUSED_VLAN", + "shutdown": true + }, + { + "vlan_id": 6, + "name": "HNVPA_6", + "interface": { + "ip": "100.71.131.2", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 6, + "priority": 150, + "virtual_ip": "100.71.131.1" + } + } + }, + { + "vlan_id": 7, + "name": "Infra_7", + "interface": { + "ip": "100.69.176.2", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 7, + "priority": 150, + "virtual_ip": "100.69.176.1" + } + } + }, + { + "vlan_id": 99, + "name": "NativeVlan" + }, + { + "vlan_id": 125, + "name": "BMC_Mgmt_125", + "interface": { + "ip": "100.71.85.123", + "cidr": 26, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 125, + "priority": 150, + "virtual_ip": "100.71.85.65" + } + } + }, + { + "vlan_id": 201, + "name": "Tenant_201", + "interface": { + "ip": "100.69.177.2", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 201, + "priority": 150, + "virtual_ip": "100.69.177.1" + } + } + }, + { + "vlan_id": 301, + "name": "LogicalTenant_301", + "interface": { + "ip": "100.69.178.2", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 301, + "priority": 150, + "virtual_ip": "100.69.178.1" + } + } + }, + { + "vlan_id": 401, + "name": "DhcpTenant_401", + "interface": { + "ip": "100.69.178.130", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 401, + "priority": 150, + "virtual_ip": "100.69.178.129" + } + } + }, + { + "vlan_id": 501, + "name": "L3forward_501", + "interface": { + "ip": "100.69.179.2", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 501, + "priority": 150, + "virtual_ip": "100.69.179.1" + } + } + }, + { + "vlan_id": 502, + "name": "L3forward_502", + "interface": { + "ip": "100.69.179.18", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 502, + "priority": 150, + "virtual_ip": "100.69.179.17" + } + } + }, + { + "vlan_id": 503, + "name": "L3forward_503", + "interface": { + "ip": "100.69.179.34", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 503, + "priority": 150, + "virtual_ip": "100.69.179.33" + } + } + }, + { + "vlan_id": 504, + "name": "L3forward_504", + "interface": { + "ip": "100.69.179.50", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 504, + "priority": 150, + "virtual_ip": "100.69.179.49" + } + } + }, + { + "vlan_id": 505, + "name": "L3forward_505", + "interface": { + "ip": "100.69.179.66", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 505, + "priority": 150, + "virtual_ip": "100.69.179.65" + } + } + }, + { + "vlan_id": 506, + "name": "L3forward_506", + "interface": { + "ip": "100.69.179.82", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 506, + "priority": 150, + "virtual_ip": "100.69.179.81" + } + } + }, + { + "vlan_id": 507, + "name": "L3forward_507", + "interface": { + "ip": "100.69.179.98", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 507, + "priority": 150, + "virtual_ip": "100.69.179.97" + } + } + }, + { + "vlan_id": 508, + "name": "L3forward_508", + "interface": { + "ip": "100.69.179.114", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 508, + "priority": 150, + "virtual_ip": "100.69.179.113" + } + } + }, + { + "vlan_id": 509, + "name": "L3forward_509", + "interface": { + "ip": "100.69.179.130", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 509, + "priority": 150, + "virtual_ip": "100.69.179.129" + } + } + }, + { + "vlan_id": 510, + "name": "L3forward_510", + "interface": { + "ip": "100.69.179.145", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 510, + "priority": 150, + "virtual_ip": "" + } + } + }, + { + "vlan_id": 511, + "name": "L3forward_511", + "interface": { + "ip": "100.69.179.162", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 511, + "priority": 150, + "virtual_ip": "100.69.179.161" + } + } + }, + { + "vlan_id": 512, + "name": "L3forward_512", + "interface": { + "ip": "100.69.179.178", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 512, + "priority": 150, + "virtual_ip": "100.69.179.177" + } + } + }, + { + "vlan_id": 513, + "name": "L3forward_513", + "interface": { + "ip": "100.69.179.194", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 513, + "priority": 150, + "virtual_ip": "100.69.179.193" + } + } + }, + { + "vlan_id": 514, + "name": "L3forward_514", + "interface": { + "ip": "100.69.179.210", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 514, + "priority": 150, + "virtual_ip": "100.69.179.209" + } + } + }, + { + "vlan_id": 515, + "name": "L3forward_515", + "interface": { + "ip": "100.69.179.226", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 515, + "priority": 150, + "virtual_ip": "100.69.179.225" + } + } + }, + { + "vlan_id": 516, + "name": "L3forward_516", + "interface": { + "ip": "100.69.179.242", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 516, + "priority": 150, + "virtual_ip": "100.69.179.241" + } + } + }, + { + "vlan_id": 711, + "name": "Storage_711_TOR1" + }, + { + "vlan_id": 712, + "name": "Storage_712_TOR2" + } + ], + "interfaces": [ + { + "name": "Unused", + "type": "Access", + "description": "initial unused for all interfaces then config as defined", + "intf_type": "Ethernet", + "start_intf": "1/1", + "end_intf": "1/54", + "access_vlan": "2", + "shutdown": true + }, + { + "name": "Loopback0", + "type": "L3", + "intf_type": "loopback", + "intf": "loopback0", + "ipv4": "100.71.85.21/32" + }, + { + "name": "P2P_Border1", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/48", + "ipv4": "100.71.85.2/30" + }, + { + "name": "P2P_Border2", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/47", + "ipv4": "100.71.85.10/30" + }, + { + "name": "Trunk_TO_BMC_SWITCH", + "type": "Trunk", + "intf_type": "Ethernet", + "intf": "1/49", + "native_vlan": "99", + "tagged_vlans": "125" + } + ], + "port_channels": [ + { + "id": 50, + "description": "P2P_IBGP", + "type": "L3", + "ipv4": "100.71.85.17", + "members": [ + "1/41", + "1/42" + ] + }, + { + "id": 101, + "description": "ToR_Peer_Link", + "type": "Trunk", + "native_vlan": "99", + "members": [ + "1/49", + "1/50", + "1/51" + ] + } + ], + "bgp": { + "asn": 65242, + "router_id": "100.71.85.21", + "networks": [ + "100.71.85.2/30", + "100.71.85.10/30", + "100.71.85.21/32", + "100.71.85.16/30", + "100.71.131.0/25", + "100.69.176.0/24", + "100.71.85.64/26", + "100.69.177.0/24", + "100.69.178.0/25", + "100.69.178.128/25", + "100.69.179.0/28", + "100.69.179.16/28", + "100.69.179.32/28", + "100.69.179.48/28", + "100.69.179.64/28", + "100.69.179.80/28", + "100.69.179.96/28", + "100.69.179.112/28", + "100.69.179.128/28", + "100.69.179.144/28", + "100.69.179.160/28", + "100.69.179.176/28", + "100.69.179.192/28", + "100.69.179.208/28", + "100.69.179.224/28", + "100.69.179.240/28" + ], + "neighbors": [ + { + "ip": "100.71.85.1", + "description": "TO_Border1", + "remote_as": 64846, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.71.85.9", + "description": "TO_Border2", + "remote_as": 64846, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.71.85.18", + "description": "iBGP_PEER", + "remote_as": 65242, + "af_ipv4_unicast": {} + }, + { + "ip": "100.71.131.0/25", + "description": "TO_HNVPA", + "remote_as": 65112, + "update_source": "Loopback0", + "ebgp_multihop": 3, + "af_ipv4_unicast": { + "prefix_list_out": "DefaultRoute" + } + } + ] + }, + "prefix_lists": { + "DefaultRoute": [ + { + "seq": 10, + "action": "permit", + "prefix": "0.0.0.0/0" + }, + { + "seq": 50, + "action": "deny", + "prefix": "0.0.0.0/0", + "prefix_filter": "le 32" + } + ] + }, + "qos": true, + "debug": { + "vlan_map": { + "C": [ + 6, + 201, + 301, + 401, + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516 + ], + "M": [ + 7 + ], + "S": [ + 711, + 712 + ], + "S1": [ + 711 + ], + "S2": [ + 712 + ], + "UNUSED": [ + 2 + ], + "NATIVE": [ + 99 + ] + }, + "ip_map": { + "P2P_BORDER1_TOR1": [ + "100.71.85.2/30" + ], + "P2P_TOR1_BORDER1": [ + "100.71.85.1" + ], + "P2P_BORDER1_TOR2": [ + "100.71.85.6/30" + ], + "P2P_TOR2_BORDER1": [ + "100.71.85.5" + ], + "P2P_BORDER2_TOR1": [ + "100.71.85.10/30" + ], + "P2P_TOR1_BORDER2": [ + "100.71.85.9" + ], + "P2P_BORDER2_TOR2": [ + "100.71.85.14/30" + ], + "P2P_TOR2_BORDER2": [ + "100.71.85.13" + ], + "P2P_IBGP_TOR1": [ + "100.71.85.17" + ], + "P2P_IBGP_TOR2": [ + "100.71.85.18" + ], + "LOOPBACK0_TOR1": [ + "100.71.85.21/32" + ], + "LOOPBACK0_TOR2": [ + "100.71.85.22/32" + ], + "HNVPA": [ + "100.71.131.0/25" + ], + "M": [ + "100.69.176.0/24" + ], + "C": [ + "100.69.177.0/24", + "100.69.178.0/25", + "100.69.178.128/25", + "100.69.179.0/28", + "100.69.179.16/28", + "100.69.179.32/28", + "100.69.179.48/28", + "100.69.179.64/28", + "100.69.179.80/28", + "100.69.179.96/28", + "100.69.179.112/28", + "100.69.179.128/28", + "100.69.179.144/28", + "100.69.179.160/28", + "100.69.179.176/28", + "100.69.179.192/28", + "100.69.179.208/28", + "100.69.179.224/28", + "100.69.179.240/28" + ] + }, + "resolved_trunks": [ + { + "name": "Trunk_TO_BMC_SWITCH", + "native_vlan": "99", + "tagged_vlans": "125" + } + ] + } +} \ No newline at end of file diff --git a/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_fc/expected_outputs/s46-r21-93180hl-24-1b.json b/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_fc/expected_outputs/s46-r21-93180hl-24-1b.json new file mode 100644 index 0000000..91be8bd --- /dev/null +++ b/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_fc/expected_outputs/s46-r21-93180hl-24-1b.json @@ -0,0 +1,623 @@ +{ + "switch": { + "make": "cisco", + "model": "93180yc-fx3", + "type": "TOR2", + "hostname": "s46-r21-93180hl-24-1b", + "version": "10.3(4a)", + "firmware": "nxos", + "site": "rr1" + }, + "vlans": [ + { + "vlan_id": 2, + "name": "UNUSED_VLAN", + "shutdown": true + }, + { + "vlan_id": 6, + "name": "HNVPA_6", + "interface": { + "ip": "100.71.131.3", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 6, + "priority": 140, + "virtual_ip": "100.71.131.1" + } + } + }, + { + "vlan_id": 7, + "name": "Infra_7", + "interface": { + "ip": "100.69.176.3", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 7, + "priority": 140, + "virtual_ip": "100.69.176.1" + } + } + }, + { + "vlan_id": 99, + "name": "NativeVlan" + }, + { + "vlan_id": 125, + "name": "BMC_Mgmt_125", + "interface": { + "ip": "100.71.85.124", + "cidr": 26, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 125, + "priority": 140, + "virtual_ip": "100.71.85.65" + } + } + }, + { + "vlan_id": 201, + "name": "Tenant_201", + "interface": { + "ip": "100.69.177.3", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 201, + "priority": 140, + "virtual_ip": "100.69.177.1" + } + } + }, + { + "vlan_id": 301, + "name": "LogicalTenant_301", + "interface": { + "ip": "100.69.178.3", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 301, + "priority": 140, + "virtual_ip": "100.69.178.1" + } + } + }, + { + "vlan_id": 401, + "name": "DhcpTenant_401", + "interface": { + "ip": "100.69.178.131", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 401, + "priority": 140, + "virtual_ip": "100.69.178.129" + } + } + }, + { + "vlan_id": 501, + "name": "L3forward_501", + "interface": { + "ip": "100.69.179.3", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 501, + "priority": 140, + "virtual_ip": "100.69.179.1" + } + } + }, + { + "vlan_id": 502, + "name": "L3forward_502", + "interface": { + "ip": "100.69.179.19", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 502, + "priority": 140, + "virtual_ip": "100.69.179.17" + } + } + }, + { + "vlan_id": 503, + "name": "L3forward_503", + "interface": { + "ip": "100.69.179.35", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 503, + "priority": 140, + "virtual_ip": "100.69.179.33" + } + } + }, + { + "vlan_id": 504, + "name": "L3forward_504", + "interface": { + "ip": "100.69.179.51", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 504, + "priority": 140, + "virtual_ip": "100.69.179.49" + } + } + }, + { + "vlan_id": 505, + "name": "L3forward_505", + "interface": { + "ip": "100.69.179.67", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 505, + "priority": 140, + "virtual_ip": "100.69.179.65" + } + } + }, + { + "vlan_id": 506, + "name": "L3forward_506", + "interface": { + "ip": "100.69.179.83", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 506, + "priority": 140, + "virtual_ip": "100.69.179.81" + } + } + }, + { + "vlan_id": 507, + "name": "L3forward_507", + "interface": { + "ip": "100.69.179.99", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 507, + "priority": 140, + "virtual_ip": "100.69.179.97" + } + } + }, + { + "vlan_id": 508, + "name": "L3forward_508", + "interface": { + "ip": "100.69.179.115", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 508, + "priority": 140, + "virtual_ip": "100.69.179.113" + } + } + }, + { + "vlan_id": 509, + "name": "L3forward_509", + "interface": { + "ip": "100.69.179.131", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 509, + "priority": 140, + "virtual_ip": "100.69.179.129" + } + } + }, + { + "vlan_id": 510, + "name": "L3forward_510", + "interface": { + "ip": "100.69.179.146", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 510, + "priority": 140, + "virtual_ip": "" + } + } + }, + { + "vlan_id": 511, + "name": "L3forward_511", + "interface": { + "ip": "100.69.179.163", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 511, + "priority": 140, + "virtual_ip": "100.69.179.161" + } + } + }, + { + "vlan_id": 512, + "name": "L3forward_512", + "interface": { + "ip": "100.69.179.179", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 512, + "priority": 140, + "virtual_ip": "100.69.179.177" + } + } + }, + { + "vlan_id": 513, + "name": "L3forward_513", + "interface": { + "ip": "100.69.179.195", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 513, + "priority": 140, + "virtual_ip": "100.69.179.193" + } + } + }, + { + "vlan_id": 514, + "name": "L3forward_514", + "interface": { + "ip": "100.69.179.211", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 514, + "priority": 140, + "virtual_ip": "100.69.179.209" + } + } + }, + { + "vlan_id": 515, + "name": "L3forward_515", + "interface": { + "ip": "100.69.179.227", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 515, + "priority": 140, + "virtual_ip": "100.69.179.225" + } + } + }, + { + "vlan_id": 516, + "name": "L3forward_516", + "interface": { + "ip": "100.69.179.243", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 516, + "priority": 140, + "virtual_ip": "100.69.179.241" + } + } + }, + { + "vlan_id": 711, + "name": "Storage_711_TOR1" + }, + { + "vlan_id": 712, + "name": "Storage_712_TOR2" + } + ], + "interfaces": [ + { + "name": "Unused", + "type": "Access", + "description": "initial unused for all interfaces then config as defined", + "intf_type": "Ethernet", + "start_intf": "1/1", + "end_intf": "1/54", + "access_vlan": "2", + "shutdown": true + }, + { + "name": "Loopback0", + "type": "L3", + "intf_type": "loopback", + "intf": "loopback0", + "ipv4": "100.71.85.22/32" + }, + { + "name": "P2P_Border1", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/48", + "ipv4": "100.71.85.6/30" + }, + { + "name": "P2P_Border2", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/47", + "ipv4": "100.71.85.14/30" + }, + { + "name": "Trunk_TO_BMC_SWITCH", + "type": "Trunk", + "intf_type": "Ethernet", + "intf": "1/49", + "native_vlan": "99", + "tagged_vlans": "125" + } + ], + "port_channels": [ + { + "id": 50, + "description": "P2P_IBGP", + "type": "L3", + "ipv4": "100.71.85.18", + "members": [ + "1/41", + "1/42" + ] + }, + { + "id": 101, + "description": "ToR_Peer_Link", + "type": "Trunk", + "native_vlan": "99", + "members": [ + "1/49", + "1/50", + "1/51" + ] + } + ], + "bgp": { + "asn": 65242, + "router_id": "100.71.85.22", + "networks": [ + "100.71.85.6/30", + "100.71.85.14/30", + "100.71.85.22/32", + "100.71.85.16/30", + "100.71.131.0/25", + "100.69.176.0/24", + "100.71.85.64/26", + "100.69.177.0/24", + "100.69.178.0/25", + "100.69.178.128/25", + "100.69.179.0/28", + "100.69.179.16/28", + "100.69.179.32/28", + "100.69.179.48/28", + "100.69.179.64/28", + "100.69.179.80/28", + "100.69.179.96/28", + "100.69.179.112/28", + "100.69.179.128/28", + "100.69.179.144/28", + "100.69.179.160/28", + "100.69.179.176/28", + "100.69.179.192/28", + "100.69.179.208/28", + "100.69.179.224/28", + "100.69.179.240/28" + ], + "neighbors": [ + { + "ip": "100.71.85.5", + "description": "TO_Border1", + "remote_as": 64846, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.71.85.13", + "description": "TO_Border2", + "remote_as": 64846, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.71.85.17", + "description": "iBGP_PEER", + "remote_as": 65242, + "af_ipv4_unicast": {} + }, + { + "ip": "100.71.131.0/25", + "description": "TO_HNVPA", + "remote_as": 65112, + "update_source": "Loopback0", + "ebgp_multihop": 3, + "af_ipv4_unicast": { + "prefix_list_out": "DefaultRoute" + } + } + ] + }, + "prefix_lists": { + "DefaultRoute": [ + { + "seq": 10, + "action": "permit", + "prefix": "0.0.0.0/0" + }, + { + "seq": 50, + "action": "deny", + "prefix": "0.0.0.0/0", + "prefix_filter": "le 32" + } + ] + }, + "qos": true, + "debug": { + "vlan_map": { + "C": [ + 6, + 201, + 301, + 401, + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516 + ], + "M": [ + 7 + ], + "S": [ + 711, + 712 + ], + "S1": [ + 711 + ], + "S2": [ + 712 + ], + "UNUSED": [ + 2 + ], + "NATIVE": [ + 99 + ] + }, + "ip_map": { + "P2P_BORDER1_TOR1": [ + "100.71.85.2/30" + ], + "P2P_TOR1_BORDER1": [ + "100.71.85.1" + ], + "P2P_BORDER1_TOR2": [ + "100.71.85.6/30" + ], + "P2P_TOR2_BORDER1": [ + "100.71.85.5" + ], + "P2P_BORDER2_TOR1": [ + "100.71.85.10/30" + ], + "P2P_TOR1_BORDER2": [ + "100.71.85.9" + ], + "P2P_BORDER2_TOR2": [ + "100.71.85.14/30" + ], + "P2P_TOR2_BORDER2": [ + "100.71.85.13" + ], + "P2P_IBGP_TOR1": [ + "100.71.85.17" + ], + "P2P_IBGP_TOR2": [ + "100.71.85.18" + ], + "LOOPBACK0_TOR1": [ + "100.71.85.21/32" + ], + "LOOPBACK0_TOR2": [ + "100.71.85.22/32" + ], + "HNVPA": [ + "100.71.131.0/25" + ], + "M": [ + "100.69.176.0/24" + ], + "C": [ + "100.69.177.0/24", + "100.69.178.0/25", + "100.69.178.128/25", + "100.69.179.0/28", + "100.69.179.16/28", + "100.69.179.32/28", + "100.69.179.48/28", + "100.69.179.64/28", + "100.69.179.80/28", + "100.69.179.96/28", + "100.69.179.112/28", + "100.69.179.128/28", + "100.69.179.144/28", + "100.69.179.160/28", + "100.69.179.176/28", + "100.69.179.192/28", + "100.69.179.208/28", + "100.69.179.224/28", + "100.69.179.240/28" + ] + }, + "resolved_trunks": [ + { + "name": "Trunk_TO_BMC_SWITCH", + "native_vlan": "99", + "tagged_vlans": "125" + } + ] + } +} \ No newline at end of file diff --git a/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_switched/expected_outputs/s46-r21-93180hl-24-1a.json b/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_switched/expected_outputs/s46-r21-93180hl-24-1a.json new file mode 100644 index 0000000..b231a8a --- /dev/null +++ b/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_switched/expected_outputs/s46-r21-93180hl-24-1a.json @@ -0,0 +1,654 @@ +{ + "switch": { + "make": "cisco", + "model": "93180yc-fx", + "type": "TOR1", + "hostname": "s46-r21-93180hl-24-1a", + "version": "9.3(11)", + "firmware": "nxos", + "site": "rr1" + }, + "vlans": [ + { + "vlan_id": 2, + "name": "UNUSED_VLAN", + "shutdown": true + }, + { + "vlan_id": 6, + "name": "HNVPA_6", + "interface": { + "ip": "100.71.131.2", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 6, + "priority": 150, + "virtual_ip": "100.71.131.1" + } + } + }, + { + "vlan_id": 7, + "name": "Infra_7", + "interface": { + "ip": "100.69.176.2", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 7, + "priority": 150, + "virtual_ip": "100.69.176.1" + } + } + }, + { + "vlan_id": 99, + "name": "NativeVlan" + }, + { + "vlan_id": 125, + "name": "BMC_Mgmt_125", + "interface": { + "ip": "100.71.85.123", + "cidr": 26, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 125, + "priority": 150, + "virtual_ip": "100.71.85.65" + } + } + }, + { + "vlan_id": 201, + "name": "Tenant_201", + "interface": { + "ip": "100.69.177.2", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 201, + "priority": 150, + "virtual_ip": "100.69.177.1" + } + } + }, + { + "vlan_id": 301, + "name": "LogicalTenant_301", + "interface": { + "ip": "100.69.178.2", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 301, + "priority": 150, + "virtual_ip": "100.69.178.1" + } + } + }, + { + "vlan_id": 401, + "name": "DhcpTenant_401", + "interface": { + "ip": "100.69.178.130", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 401, + "priority": 150, + "virtual_ip": "100.69.178.129" + } + } + }, + { + "vlan_id": 501, + "name": "L3forward_501", + "interface": { + "ip": "100.69.179.2", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 501, + "priority": 150, + "virtual_ip": "100.69.179.1" + } + } + }, + { + "vlan_id": 502, + "name": "L3forward_502", + "interface": { + "ip": "100.69.179.18", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 502, + "priority": 150, + "virtual_ip": "100.69.179.17" + } + } + }, + { + "vlan_id": 503, + "name": "L3forward_503", + "interface": { + "ip": "100.69.179.34", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 503, + "priority": 150, + "virtual_ip": "100.69.179.33" + } + } + }, + { + "vlan_id": 504, + "name": "L3forward_504", + "interface": { + "ip": "100.69.179.50", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 504, + "priority": 150, + "virtual_ip": "100.69.179.49" + } + } + }, + { + "vlan_id": 505, + "name": "L3forward_505", + "interface": { + "ip": "100.69.179.66", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 505, + "priority": 150, + "virtual_ip": "100.69.179.65" + } + } + }, + { + "vlan_id": 506, + "name": "L3forward_506", + "interface": { + "ip": "100.69.179.82", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 506, + "priority": 150, + "virtual_ip": "100.69.179.81" + } + } + }, + { + "vlan_id": 507, + "name": "L3forward_507", + "interface": { + "ip": "100.69.179.98", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 507, + "priority": 150, + "virtual_ip": "100.69.179.97" + } + } + }, + { + "vlan_id": 508, + "name": "L3forward_508", + "interface": { + "ip": "100.69.179.114", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 508, + "priority": 150, + "virtual_ip": "100.69.179.113" + } + } + }, + { + "vlan_id": 509, + "name": "L3forward_509", + "interface": { + "ip": "100.69.179.130", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 509, + "priority": 150, + "virtual_ip": "100.69.179.129" + } + } + }, + { + "vlan_id": 510, + "name": "L3forward_510", + "interface": { + "ip": "100.69.179.145", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 510, + "priority": 150, + "virtual_ip": "" + } + } + }, + { + "vlan_id": 511, + "name": "L3forward_511", + "interface": { + "ip": "100.69.179.162", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 511, + "priority": 150, + "virtual_ip": "100.69.179.161" + } + } + }, + { + "vlan_id": 512, + "name": "L3forward_512", + "interface": { + "ip": "100.69.179.178", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 512, + "priority": 150, + "virtual_ip": "100.69.179.177" + } + } + }, + { + "vlan_id": 513, + "name": "L3forward_513", + "interface": { + "ip": "100.69.179.194", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 513, + "priority": 150, + "virtual_ip": "100.69.179.193" + } + } + }, + { + "vlan_id": 514, + "name": "L3forward_514", + "interface": { + "ip": "100.69.179.210", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 514, + "priority": 150, + "virtual_ip": "100.69.179.209" + } + } + }, + { + "vlan_id": 515, + "name": "L3forward_515", + "interface": { + "ip": "100.69.179.226", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 515, + "priority": 150, + "virtual_ip": "100.69.179.225" + } + } + }, + { + "vlan_id": 516, + "name": "L3forward_516", + "interface": { + "ip": "100.69.179.242", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 516, + "priority": 150, + "virtual_ip": "100.69.179.241" + } + } + }, + { + "vlan_id": 711, + "name": "Storage_711_TOR1" + }, + { + "vlan_id": 712, + "name": "Storage_712_TOR2" + } + ], + "interfaces": [ + { + "name": "Unused", + "type": "Access", + "description": "initial unused for all interfaces then config as defined", + "intf_type": "Ethernet", + "start_intf": "1/1", + "end_intf": "1/54", + "access_vlan": "2", + "shutdown": true + }, + { + "name": "Loopback0", + "type": "L3", + "intf_type": "loopback", + "intf": "loopback0", + "ipv4": "100.71.85.21/32" + }, + { + "name": "P2P_Border1", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/48", + "ipv4": "100.71.85.2/30" + }, + { + "name": "P2P_Border2", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/47", + "ipv4": "100.71.85.10/30" + }, + { + "name": "Trunk_TO_BMC_SWITCH", + "type": "Trunk", + "intf_type": "Ethernet", + "intf": "1/49", + "native_vlan": "99", + "tagged_vlans": "125" + }, + { + "name": "Switched_Compute_To_Host", + "type": "Trunk", + "intf_type": "Ethernet", + "start_intf": "1/1", + "end_intf": "1/16", + "native_vlan": "7", + "tagged_vlans": "7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516" + }, + { + "name": "Switched_Storage_To_Host", + "type": "Trunk", + "intf_type": "Ethernet", + "start_intf": "1/17", + "end_intf": "1/32", + "native_vlan": "99", + "tagged_vlans": "711", + "service_policy": { + "qos_input": "AZLOCAL-QOS-MAP" + } + } + ], + "port_channels": [ + { + "id": 50, + "description": "P2P_IBGP", + "type": "L3", + "ipv4": "100.71.85.17", + "members": [ + "1/41", + "1/42" + ] + }, + { + "id": 101, + "description": "ToR_Peer_Link", + "type": "Trunk", + "native_vlan": "99", + "members": [ + "1/49", + "1/50", + "1/51" + ] + } + ], + "bgp": { + "asn": 65242, + "router_id": "100.71.85.21", + "networks": [ + "100.71.85.2/30", + "100.71.85.10/30", + "100.71.85.21/32", + "100.71.85.16/30", + "100.71.131.0/25", + "100.69.176.0/24", + "100.71.85.64/26", + "100.69.177.0/24", + "100.69.178.0/25", + "100.69.178.128/25", + "100.69.179.0/28", + "100.69.179.16/28", + "100.69.179.32/28", + "100.69.179.48/28", + "100.69.179.64/28", + "100.69.179.80/28", + "100.69.179.96/28", + "100.69.179.112/28", + "100.69.179.128/28", + "100.69.179.144/28", + "100.69.179.160/28", + "100.69.179.176/28", + "100.69.179.192/28", + "100.69.179.208/28", + "100.69.179.224/28", + "100.69.179.240/28" + ], + "neighbors": [ + { + "ip": "100.71.85.1", + "description": "TO_Border1", + "remote_as": 64846, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.71.85.9", + "description": "TO_Border2", + "remote_as": 64846, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.71.85.18", + "description": "iBGP_PEER", + "remote_as": 65242, + "af_ipv4_unicast": {} + }, + { + "ip": "100.71.131.0/25", + "description": "TO_HNVPA", + "remote_as": 65112, + "update_source": "Loopback0", + "ebgp_multihop": 3, + "af_ipv4_unicast": { + "prefix_list_out": "DefaultRoute" + } + } + ] + }, + "prefix_lists": { + "DefaultRoute": [ + { + "seq": 10, + "action": "permit", + "prefix": "0.0.0.0/0" + }, + { + "seq": 50, + "action": "deny", + "prefix": "0.0.0.0/0", + "prefix_filter": "le 32" + } + ] + }, + "qos": true, + "debug": { + "vlan_map": { + "C": [ + 6, + 201, + 301, + 401, + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516 + ], + "M": [ + 7 + ], + "S": [ + 711, + 712 + ], + "S1": [ + 711 + ], + "S2": [ + 712 + ], + "UNUSED": [ + 2 + ], + "NATIVE": [ + 99 + ] + }, + "ip_map": { + "P2P_BORDER1_TOR1": [ + "100.71.85.2/30" + ], + "P2P_TOR1_BORDER1": [ + "100.71.85.1" + ], + "P2P_BORDER1_TOR2": [ + "100.71.85.6/30" + ], + "P2P_TOR2_BORDER1": [ + "100.71.85.5" + ], + "P2P_BORDER2_TOR1": [ + "100.71.85.10/30" + ], + "P2P_TOR1_BORDER2": [ + "100.71.85.9" + ], + "P2P_BORDER2_TOR2": [ + "100.71.85.14/30" + ], + "P2P_TOR2_BORDER2": [ + "100.71.85.13" + ], + "P2P_IBGP_TOR1": [ + "100.71.85.17" + ], + "P2P_IBGP_TOR2": [ + "100.71.85.18" + ], + "LOOPBACK0_TOR1": [ + "100.71.85.21/32" + ], + "LOOPBACK0_TOR2": [ + "100.71.85.22/32" + ], + "HNVPA": [ + "100.71.131.0/25" + ], + "M": [ + "100.69.176.0/24" + ], + "C": [ + "100.69.177.0/24", + "100.69.178.0/25", + "100.69.178.128/25", + "100.69.179.0/28", + "100.69.179.16/28", + "100.69.179.32/28", + "100.69.179.48/28", + "100.69.179.64/28", + "100.69.179.80/28", + "100.69.179.96/28", + "100.69.179.112/28", + "100.69.179.128/28", + "100.69.179.144/28", + "100.69.179.160/28", + "100.69.179.176/28", + "100.69.179.192/28", + "100.69.179.208/28", + "100.69.179.224/28", + "100.69.179.240/28" + ] + }, + "resolved_trunks": [ + { + "name": "Trunk_TO_BMC_SWITCH", + "native_vlan": "99", + "tagged_vlans": "125" + }, + { + "name": "Switched_Compute_To_Host", + "native_vlan": "7", + "tagged_vlans": "7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516" + }, + { + "name": "Switched_Storage_To_Host", + "native_vlan": "99", + "tagged_vlans": "711" + } + ] + } +} \ No newline at end of file diff --git a/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_switched/expected_outputs/s46-r21-93180hl-24-1b.json b/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_switched/expected_outputs/s46-r21-93180hl-24-1b.json new file mode 100644 index 0000000..78d3b8b --- /dev/null +++ b/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_switched/expected_outputs/s46-r21-93180hl-24-1b.json @@ -0,0 +1,654 @@ +{ + "switch": { + "make": "cisco", + "model": "93180yc-fx", + "type": "TOR2", + "hostname": "s46-r21-93180hl-24-1b", + "version": "9.3(11)", + "firmware": "nxos", + "site": "rr1" + }, + "vlans": [ + { + "vlan_id": 2, + "name": "UNUSED_VLAN", + "shutdown": true + }, + { + "vlan_id": 6, + "name": "HNVPA_6", + "interface": { + "ip": "100.71.131.3", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 6, + "priority": 140, + "virtual_ip": "100.71.131.1" + } + } + }, + { + "vlan_id": 7, + "name": "Infra_7", + "interface": { + "ip": "100.69.176.3", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 7, + "priority": 140, + "virtual_ip": "100.69.176.1" + } + } + }, + { + "vlan_id": 99, + "name": "NativeVlan" + }, + { + "vlan_id": 125, + "name": "BMC_Mgmt_125", + "interface": { + "ip": "100.71.85.124", + "cidr": 26, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 125, + "priority": 140, + "virtual_ip": "100.71.85.65" + } + } + }, + { + "vlan_id": 201, + "name": "Tenant_201", + "interface": { + "ip": "100.69.177.3", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 201, + "priority": 140, + "virtual_ip": "100.69.177.1" + } + } + }, + { + "vlan_id": 301, + "name": "LogicalTenant_301", + "interface": { + "ip": "100.69.178.3", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 301, + "priority": 140, + "virtual_ip": "100.69.178.1" + } + } + }, + { + "vlan_id": 401, + "name": "DhcpTenant_401", + "interface": { + "ip": "100.69.178.131", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 401, + "priority": 140, + "virtual_ip": "100.69.178.129" + } + } + }, + { + "vlan_id": 501, + "name": "L3forward_501", + "interface": { + "ip": "100.69.179.3", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 501, + "priority": 140, + "virtual_ip": "100.69.179.1" + } + } + }, + { + "vlan_id": 502, + "name": "L3forward_502", + "interface": { + "ip": "100.69.179.19", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 502, + "priority": 140, + "virtual_ip": "100.69.179.17" + } + } + }, + { + "vlan_id": 503, + "name": "L3forward_503", + "interface": { + "ip": "100.69.179.35", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 503, + "priority": 140, + "virtual_ip": "100.69.179.33" + } + } + }, + { + "vlan_id": 504, + "name": "L3forward_504", + "interface": { + "ip": "100.69.179.51", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 504, + "priority": 140, + "virtual_ip": "100.69.179.49" + } + } + }, + { + "vlan_id": 505, + "name": "L3forward_505", + "interface": { + "ip": "100.69.179.67", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 505, + "priority": 140, + "virtual_ip": "100.69.179.65" + } + } + }, + { + "vlan_id": 506, + "name": "L3forward_506", + "interface": { + "ip": "100.69.179.83", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 506, + "priority": 140, + "virtual_ip": "100.69.179.81" + } + } + }, + { + "vlan_id": 507, + "name": "L3forward_507", + "interface": { + "ip": "100.69.179.99", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 507, + "priority": 140, + "virtual_ip": "100.69.179.97" + } + } + }, + { + "vlan_id": 508, + "name": "L3forward_508", + "interface": { + "ip": "100.69.179.115", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 508, + "priority": 140, + "virtual_ip": "100.69.179.113" + } + } + }, + { + "vlan_id": 509, + "name": "L3forward_509", + "interface": { + "ip": "100.69.179.131", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 509, + "priority": 140, + "virtual_ip": "100.69.179.129" + } + } + }, + { + "vlan_id": 510, + "name": "L3forward_510", + "interface": { + "ip": "100.69.179.146", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 510, + "priority": 140, + "virtual_ip": "" + } + } + }, + { + "vlan_id": 511, + "name": "L3forward_511", + "interface": { + "ip": "100.69.179.163", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 511, + "priority": 140, + "virtual_ip": "100.69.179.161" + } + } + }, + { + "vlan_id": 512, + "name": "L3forward_512", + "interface": { + "ip": "100.69.179.179", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 512, + "priority": 140, + "virtual_ip": "100.69.179.177" + } + } + }, + { + "vlan_id": 513, + "name": "L3forward_513", + "interface": { + "ip": "100.69.179.195", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 513, + "priority": 140, + "virtual_ip": "100.69.179.193" + } + } + }, + { + "vlan_id": 514, + "name": "L3forward_514", + "interface": { + "ip": "100.69.179.211", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 514, + "priority": 140, + "virtual_ip": "100.69.179.209" + } + } + }, + { + "vlan_id": 515, + "name": "L3forward_515", + "interface": { + "ip": "100.69.179.227", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 515, + "priority": 140, + "virtual_ip": "100.69.179.225" + } + } + }, + { + "vlan_id": 516, + "name": "L3forward_516", + "interface": { + "ip": "100.69.179.243", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 516, + "priority": 140, + "virtual_ip": "100.69.179.241" + } + } + }, + { + "vlan_id": 711, + "name": "Storage_711_TOR1" + }, + { + "vlan_id": 712, + "name": "Storage_712_TOR2" + } + ], + "interfaces": [ + { + "name": "Unused", + "type": "Access", + "description": "initial unused for all interfaces then config as defined", + "intf_type": "Ethernet", + "start_intf": "1/1", + "end_intf": "1/54", + "access_vlan": "2", + "shutdown": true + }, + { + "name": "Loopback0", + "type": "L3", + "intf_type": "loopback", + "intf": "loopback0", + "ipv4": "100.71.85.22/32" + }, + { + "name": "P2P_Border1", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/48", + "ipv4": "100.71.85.6/30" + }, + { + "name": "P2P_Border2", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/47", + "ipv4": "100.71.85.14/30" + }, + { + "name": "Trunk_TO_BMC_SWITCH", + "type": "Trunk", + "intf_type": "Ethernet", + "intf": "1/49", + "native_vlan": "99", + "tagged_vlans": "125" + }, + { + "name": "Switched_Compute_To_Host", + "type": "Trunk", + "intf_type": "Ethernet", + "start_intf": "1/1", + "end_intf": "1/16", + "native_vlan": "7", + "tagged_vlans": "7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516" + }, + { + "name": "Switched_Storage_To_Host", + "type": "Trunk", + "intf_type": "Ethernet", + "start_intf": "1/17", + "end_intf": "1/32", + "native_vlan": "99", + "tagged_vlans": "712", + "service_policy": { + "qos_input": "AZLOCAL-QOS-MAP" + } + } + ], + "port_channels": [ + { + "id": 50, + "description": "P2P_IBGP", + "type": "L3", + "ipv4": "100.71.85.18", + "members": [ + "1/41", + "1/42" + ] + }, + { + "id": 101, + "description": "ToR_Peer_Link", + "type": "Trunk", + "native_vlan": "99", + "members": [ + "1/49", + "1/50", + "1/51" + ] + } + ], + "bgp": { + "asn": 65242, + "router_id": "100.71.85.22", + "networks": [ + "100.71.85.6/30", + "100.71.85.14/30", + "100.71.85.22/32", + "100.71.85.16/30", + "100.71.131.0/25", + "100.69.176.0/24", + "100.71.85.64/26", + "100.69.177.0/24", + "100.69.178.0/25", + "100.69.178.128/25", + "100.69.179.0/28", + "100.69.179.16/28", + "100.69.179.32/28", + "100.69.179.48/28", + "100.69.179.64/28", + "100.69.179.80/28", + "100.69.179.96/28", + "100.69.179.112/28", + "100.69.179.128/28", + "100.69.179.144/28", + "100.69.179.160/28", + "100.69.179.176/28", + "100.69.179.192/28", + "100.69.179.208/28", + "100.69.179.224/28", + "100.69.179.240/28" + ], + "neighbors": [ + { + "ip": "100.71.85.5", + "description": "TO_Border1", + "remote_as": 64846, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.71.85.13", + "description": "TO_Border2", + "remote_as": 64846, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.71.85.17", + "description": "iBGP_PEER", + "remote_as": 65242, + "af_ipv4_unicast": {} + }, + { + "ip": "100.71.131.0/25", + "description": "TO_HNVPA", + "remote_as": 65112, + "update_source": "Loopback0", + "ebgp_multihop": 3, + "af_ipv4_unicast": { + "prefix_list_out": "DefaultRoute" + } + } + ] + }, + "prefix_lists": { + "DefaultRoute": [ + { + "seq": 10, + "action": "permit", + "prefix": "0.0.0.0/0" + }, + { + "seq": 50, + "action": "deny", + "prefix": "0.0.0.0/0", + "prefix_filter": "le 32" + } + ] + }, + "qos": true, + "debug": { + "vlan_map": { + "C": [ + 6, + 201, + 301, + 401, + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516 + ], + "M": [ + 7 + ], + "S": [ + 711, + 712 + ], + "S1": [ + 711 + ], + "S2": [ + 712 + ], + "UNUSED": [ + 2 + ], + "NATIVE": [ + 99 + ] + }, + "ip_map": { + "P2P_BORDER1_TOR1": [ + "100.71.85.2/30" + ], + "P2P_TOR1_BORDER1": [ + "100.71.85.1" + ], + "P2P_BORDER1_TOR2": [ + "100.71.85.6/30" + ], + "P2P_TOR2_BORDER1": [ + "100.71.85.5" + ], + "P2P_BORDER2_TOR1": [ + "100.71.85.10/30" + ], + "P2P_TOR1_BORDER2": [ + "100.71.85.9" + ], + "P2P_BORDER2_TOR2": [ + "100.71.85.14/30" + ], + "P2P_TOR2_BORDER2": [ + "100.71.85.13" + ], + "P2P_IBGP_TOR1": [ + "100.71.85.17" + ], + "P2P_IBGP_TOR2": [ + "100.71.85.18" + ], + "LOOPBACK0_TOR1": [ + "100.71.85.21/32" + ], + "LOOPBACK0_TOR2": [ + "100.71.85.22/32" + ], + "HNVPA": [ + "100.71.131.0/25" + ], + "M": [ + "100.69.176.0/24" + ], + "C": [ + "100.69.177.0/24", + "100.69.178.0/25", + "100.69.178.128/25", + "100.69.179.0/28", + "100.69.179.16/28", + "100.69.179.32/28", + "100.69.179.48/28", + "100.69.179.64/28", + "100.69.179.80/28", + "100.69.179.96/28", + "100.69.179.112/28", + "100.69.179.128/28", + "100.69.179.144/28", + "100.69.179.160/28", + "100.69.179.176/28", + "100.69.179.192/28", + "100.69.179.208/28", + "100.69.179.224/28", + "100.69.179.240/28" + ] + }, + "resolved_trunks": [ + { + "name": "Trunk_TO_BMC_SWITCH", + "native_vlan": "99", + "tagged_vlans": "125" + }, + { + "name": "Switched_Compute_To_Host", + "native_vlan": "7", + "tagged_vlans": "7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516" + }, + { + "name": "Switched_Storage_To_Host", + "native_vlan": "99", + "tagged_vlans": "712" + } + ] + } +} \ No newline at end of file diff --git a/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_switchless/expected_outputs/b88-b11-93108hl-2-1a.json b/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_switchless/expected_outputs/b88-b11-93108hl-2-1a.json new file mode 100644 index 0000000..a82080d --- /dev/null +++ b/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_switchless/expected_outputs/b88-b11-93108hl-2-1a.json @@ -0,0 +1,638 @@ +{ + "switch": { + "make": "cisco", + "model": "93108tc-fx3p", + "type": "TOR1", + "hostname": "b88-b11-93108hl-2-1a", + "version": "10.3(4a)", + "firmware": "nxos", + "site": "b88" + }, + "vlans": [ + { + "vlan_id": 2, + "name": "UNUSED_VLAN", + "shutdown": true + }, + { + "vlan_id": 6, + "name": "HNVPA_6", + "interface": { + "ip": "100.100.162.130", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 6, + "priority": 150, + "virtual_ip": "100.100.162.129" + } + } + }, + { + "vlan_id": 7, + "name": "Infra_7", + "interface": { + "ip": "100.103.96.2", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 7, + "priority": 150, + "virtual_ip": "100.103.96.1" + } + } + }, + { + "vlan_id": 99, + "name": "NativeVlan" + }, + { + "vlan_id": 125, + "name": "BMC_Mgmt_125", + "interface": { + "ip": "100.100.69.123", + "cidr": 26, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 125, + "priority": 150, + "virtual_ip": "100.100.69.65" + } + } + }, + { + "vlan_id": 201, + "name": "Tenant_201", + "interface": { + "ip": "100.99.20.2", + "cidr": 23, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 201, + "priority": 150, + "virtual_ip": "100.99.20.1" + } + } + }, + { + "vlan_id": 301, + "name": "LogicalTenant_301", + "interface": { + "ip": "100.99.22.2", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 301, + "priority": 150, + "virtual_ip": "100.99.22.1" + } + } + }, + { + "vlan_id": 401, + "name": "DhcpTenant_401", + "interface": { + "ip": "100.99.23.2", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 401, + "priority": 150, + "virtual_ip": "100.99.23.1" + } + } + }, + { + "vlan_id": 501, + "name": "L3forward_501", + "interface": { + "ip": "100.103.97.2", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 501, + "priority": 150, + "virtual_ip": "100.103.97.1" + } + } + }, + { + "vlan_id": 502, + "name": "L3forward_502", + "interface": { + "ip": "100.103.97.18", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 502, + "priority": 150, + "virtual_ip": "100.103.97.17" + } + } + }, + { + "vlan_id": 503, + "name": "L3forward_503", + "interface": { + "ip": "100.103.97.34", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 503, + "priority": 150, + "virtual_ip": "100.103.97.33" + } + } + }, + { + "vlan_id": 504, + "name": "L3forward_504", + "interface": { + "ip": "100.103.97.50", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 504, + "priority": 150, + "virtual_ip": "100.103.97.49" + } + } + }, + { + "vlan_id": 505, + "name": "L3forward_505", + "interface": { + "ip": "100.103.97.66", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 505, + "priority": 150, + "virtual_ip": "100.103.97.65" + } + } + }, + { + "vlan_id": 506, + "name": "L3forward_506", + "interface": { + "ip": "100.103.97.82", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 506, + "priority": 150, + "virtual_ip": "100.103.97.81" + } + } + }, + { + "vlan_id": 507, + "name": "L3forward_507", + "interface": { + "ip": "100.103.97.98", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 507, + "priority": 150, + "virtual_ip": "100.103.97.97" + } + } + }, + { + "vlan_id": 508, + "name": "L3forward_508", + "interface": { + "ip": "100.103.97.114", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 508, + "priority": 150, + "virtual_ip": "100.103.97.113" + } + } + }, + { + "vlan_id": 509, + "name": "L3forward_509", + "interface": { + "ip": "100.103.97.130", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 509, + "priority": 150, + "virtual_ip": "100.103.97.129" + } + } + }, + { + "vlan_id": 510, + "name": "L3forward_510", + "interface": { + "ip": "100.103.97.146", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 510, + "priority": 150, + "virtual_ip": "100.103.97.145" + } + } + }, + { + "vlan_id": 511, + "name": "L3forward_511", + "interface": { + "ip": "100.103.97.162", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 511, + "priority": 150, + "virtual_ip": "100.103.97.161" + } + } + }, + { + "vlan_id": 512, + "name": "L3forward_512", + "interface": { + "ip": "100.103.97.178", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 512, + "priority": 150, + "virtual_ip": "100.103.97.177" + } + } + }, + { + "vlan_id": 513, + "name": "L3forward_513", + "interface": { + "ip": "100.103.97.194", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 513, + "priority": 150, + "virtual_ip": "100.103.97.193" + } + } + }, + { + "vlan_id": 514, + "name": "L3forward_514", + "interface": { + "ip": "100.103.97.210", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 514, + "priority": 150, + "virtual_ip": "100.103.97.209" + } + } + }, + { + "vlan_id": 515, + "name": "L3forward_515", + "interface": { + "ip": "100.103.97.226", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 515, + "priority": 150, + "virtual_ip": "100.103.97.225" + } + } + }, + { + "vlan_id": 516, + "name": "L3forward_516", + "interface": { + "ip": "100.103.97.242", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 516, + "priority": 150, + "virtual_ip": "100.103.97.241" + } + } + }, + { + "vlan_id": 711, + "name": "Storage_711_TOR1" + }, + { + "vlan_id": 712, + "name": "Storage_712_TOR2" + } + ], + "interfaces": [ + { + "name": "Unused", + "type": "Access", + "description": "initial unused for all interfaces then config as defined", + "intf_type": "Ethernet", + "start_intf": "1/1", + "end_intf": "1/54", + "access_vlan": "2", + "shutdown": true + }, + { + "name": "Loopback0", + "type": "L3", + "intf_type": "loopback", + "intf": "loopback0", + "ipv4": "100.100.69.21/32" + }, + { + "name": "P2P_Border1", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/48", + "ipv4": "100.100.69.2/30" + }, + { + "name": "P2P_Border2", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/47", + "ipv4": "100.100.69.10/30" + }, + { + "name": "Trunk_TO_BMC_SWITCH", + "type": "Trunk", + "intf_type": "Ethernet", + "intf": "1/49", + "native_vlan": "99", + "tagged_vlans": "125" + }, + { + "name": "Switchless_Compute_To_Host", + "type": "Trunk", + "intf_type": "Ethernet", + "start_intf": "1/1", + "end_intf": "1/16", + "native_vlan": "7", + "tagged_vlans": "7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516" + } + ], + "port_channels": [ + { + "id": 50, + "description": "P2P_IBGP", + "type": "L3", + "ipv4": "100.100.69.17", + "members": [ + "1/41", + "1/42" + ] + }, + { + "id": 101, + "description": "ToR_Peer_Link", + "type": "Trunk", + "native_vlan": "99", + "tagged_vlans": "", + "members": [ + "1/49", + "1/50", + "1/51" + ] + } + ], + "bgp": { + "asn": 64576, + "router_id": "100.100.69.21", + "networks": [ + "100.100.69.2/30", + "100.100.69.10/30", + "100.100.69.21/32", + "100.100.69.16/30", + "100.100.162.128/25", + "100.103.96.0/24", + "100.100.69.64/26", + "100.99.20.0/23", + "100.99.22.0/24", + "100.99.23.0/24", + "100.103.97.0/28", + "100.103.97.16/28", + "100.103.97.32/28", + "100.103.97.48/28", + "100.103.97.64/28", + "100.103.97.80/28", + "100.103.97.96/28", + "100.103.97.112/28", + "100.103.97.128/28", + "100.103.97.144/28", + "100.103.97.160/28", + "100.103.97.176/28", + "100.103.97.192/28", + "100.103.97.208/28", + "100.103.97.224/28", + "100.103.97.240/28" + ], + "neighbors": [ + { + "ip": "100.100.69.1", + "description": "TO_Border1", + "remote_as": 64809, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.100.69.9", + "description": "TO_Border2", + "remote_as": 64809, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.100.69.18", + "description": "iBGP_PEER", + "remote_as": 64576, + "af_ipv4_unicast": {} + }, + { + "ip": "100.100.162.128/25", + "description": "TO_HNVPA", + "remote_as": 65044, + "update_source": "Loopback0", + "ebgp_multihop": 3, + "af_ipv4_unicast": { + "prefix_list_out": "DefaultRoute" + } + } + ] + }, + "prefix_lists": { + "DefaultRoute": [ + { + "seq": 10, + "action": "permit", + "prefix": "0.0.0.0/0" + }, + { + "seq": 50, + "action": "deny", + "prefix": "0.0.0.0/0", + "prefix_filter": "le 32" + } + ] + }, + "qos": true, + "debug": { + "vlan_map": { + "C": [ + 6, + 201, + 301, + 401, + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516 + ], + "M": [ + 7 + ], + "S": [ + 711, + 712 + ], + "S1": [ + 711 + ], + "S2": [ + 712 + ], + "UNUSED": [ + 2 + ], + "NATIVE": [ + 99 + ] + }, + "ip_map": { + "P2P_BORDER1_TOR1": [ + "100.100.69.2/30" + ], + "P2P_TOR1_BORDER1": [ + "100.100.69.1" + ], + "P2P_BORDER1_TOR2": [ + "100.100.69.6/30" + ], + "P2P_TOR2_BORDER1": [ + "100.100.69.5" + ], + "P2P_BORDER2_TOR1": [ + "100.100.69.10/30" + ], + "P2P_TOR1_BORDER2": [ + "100.100.69.9" + ], + "P2P_BORDER2_TOR2": [ + "100.100.69.14/30" + ], + "P2P_TOR2_BORDER2": [ + "100.100.69.13" + ], + "P2P_IBGP_TOR1": [ + "100.100.69.17" + ], + "P2P_IBGP_TOR2": [ + "100.100.69.18" + ], + "LOOPBACK0_TOR1": [ + "100.100.69.21/32" + ], + "LOOPBACK0_TOR2": [ + "100.100.69.22/32" + ], + "HNVPA": [ + "100.100.162.128/25" + ], + "M": [ + "100.103.96.0/24" + ], + "C": [ + "100.99.20.0/23", + "100.99.22.0/24", + "100.99.23.0/24", + "100.103.97.0/28", + "100.103.97.16/28", + "100.103.97.32/28", + "100.103.97.48/28", + "100.103.97.64/28", + "100.103.97.80/28", + "100.103.97.96/28", + "100.103.97.112/28", + "100.103.97.128/28", + "100.103.97.144/28", + "100.103.97.160/28", + "100.103.97.176/28", + "100.103.97.192/28", + "100.103.97.208/28", + "100.103.97.224/28", + "100.103.97.240/28" + ] + }, + "resolved_trunks": [ + { + "name": "Trunk_TO_BMC_SWITCH", + "native_vlan": "99", + "tagged_vlans": "125" + }, + { + "name": "Switchless_Compute_To_Host", + "native_vlan": "7", + "tagged_vlans": "7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516" + } + ] + } +} \ No newline at end of file diff --git a/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_switchless/expected_outputs/b88-b11-93108hl-2-1b.json b/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_switchless/expected_outputs/b88-b11-93108hl-2-1b.json new file mode 100644 index 0000000..ca2563d --- /dev/null +++ b/tests/test_cases/convert_lab_switch_input_json_cisco_nxos_switchless/expected_outputs/b88-b11-93108hl-2-1b.json @@ -0,0 +1,638 @@ +{ + "switch": { + "make": "cisco", + "model": "93108tc-fx3p", + "type": "TOR2", + "hostname": "b88-b11-93108hl-2-1b", + "version": "10.3(4a)", + "firmware": "nxos", + "site": "b88" + }, + "vlans": [ + { + "vlan_id": 2, + "name": "UNUSED_VLAN", + "shutdown": true + }, + { + "vlan_id": 6, + "name": "HNVPA_6", + "interface": { + "ip": "100.100.162.131", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 6, + "priority": 140, + "virtual_ip": "100.100.162.129" + } + } + }, + { + "vlan_id": 7, + "name": "Infra_7", + "interface": { + "ip": "100.103.96.3", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 7, + "priority": 140, + "virtual_ip": "100.103.96.1" + } + } + }, + { + "vlan_id": 99, + "name": "NativeVlan" + }, + { + "vlan_id": 125, + "name": "BMC_Mgmt_125", + "interface": { + "ip": "100.100.69.124", + "cidr": 26, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 125, + "priority": 140, + "virtual_ip": "100.100.69.65" + } + } + }, + { + "vlan_id": 201, + "name": "Tenant_201", + "interface": { + "ip": "100.99.20.3", + "cidr": 23, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 201, + "priority": 140, + "virtual_ip": "100.99.20.1" + } + } + }, + { + "vlan_id": 301, + "name": "LogicalTenant_301", + "interface": { + "ip": "100.99.22.3", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 301, + "priority": 140, + "virtual_ip": "100.99.22.1" + } + } + }, + { + "vlan_id": 401, + "name": "DhcpTenant_401", + "interface": { + "ip": "100.99.23.3", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 401, + "priority": 140, + "virtual_ip": "100.99.23.1" + } + } + }, + { + "vlan_id": 501, + "name": "L3forward_501", + "interface": { + "ip": "100.103.97.3", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 501, + "priority": 140, + "virtual_ip": "100.103.97.1" + } + } + }, + { + "vlan_id": 502, + "name": "L3forward_502", + "interface": { + "ip": "100.103.97.19", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 502, + "priority": 140, + "virtual_ip": "100.103.97.17" + } + } + }, + { + "vlan_id": 503, + "name": "L3forward_503", + "interface": { + "ip": "100.103.97.35", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 503, + "priority": 140, + "virtual_ip": "100.103.97.33" + } + } + }, + { + "vlan_id": 504, + "name": "L3forward_504", + "interface": { + "ip": "100.103.97.51", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 504, + "priority": 140, + "virtual_ip": "100.103.97.49" + } + } + }, + { + "vlan_id": 505, + "name": "L3forward_505", + "interface": { + "ip": "100.103.97.67", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 505, + "priority": 140, + "virtual_ip": "100.103.97.65" + } + } + }, + { + "vlan_id": 506, + "name": "L3forward_506", + "interface": { + "ip": "100.103.97.83", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 506, + "priority": 140, + "virtual_ip": "100.103.97.81" + } + } + }, + { + "vlan_id": 507, + "name": "L3forward_507", + "interface": { + "ip": "100.103.97.99", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 507, + "priority": 140, + "virtual_ip": "100.103.97.97" + } + } + }, + { + "vlan_id": 508, + "name": "L3forward_508", + "interface": { + "ip": "100.103.97.115", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 508, + "priority": 140, + "virtual_ip": "100.103.97.113" + } + } + }, + { + "vlan_id": 509, + "name": "L3forward_509", + "interface": { + "ip": "100.103.97.131", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 509, + "priority": 140, + "virtual_ip": "100.103.97.129" + } + } + }, + { + "vlan_id": 510, + "name": "L3forward_510", + "interface": { + "ip": "100.103.97.147", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 510, + "priority": 140, + "virtual_ip": "100.103.97.145" + } + } + }, + { + "vlan_id": 511, + "name": "L3forward_511", + "interface": { + "ip": "100.103.97.163", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 511, + "priority": 140, + "virtual_ip": "100.103.97.161" + } + } + }, + { + "vlan_id": 512, + "name": "L3forward_512", + "interface": { + "ip": "100.103.97.179", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 512, + "priority": 140, + "virtual_ip": "100.103.97.177" + } + } + }, + { + "vlan_id": 513, + "name": "L3forward_513", + "interface": { + "ip": "100.103.97.195", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 513, + "priority": 140, + "virtual_ip": "100.103.97.193" + } + } + }, + { + "vlan_id": 514, + "name": "L3forward_514", + "interface": { + "ip": "100.103.97.211", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 514, + "priority": 140, + "virtual_ip": "100.103.97.209" + } + } + }, + { + "vlan_id": 515, + "name": "L3forward_515", + "interface": { + "ip": "100.103.97.227", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 515, + "priority": 140, + "virtual_ip": "100.103.97.225" + } + } + }, + { + "vlan_id": 516, + "name": "L3forward_516", + "interface": { + "ip": "100.103.97.243", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "hsrp", + "group": 516, + "priority": 140, + "virtual_ip": "100.103.97.241" + } + } + }, + { + "vlan_id": 711, + "name": "Storage_711_TOR1" + }, + { + "vlan_id": 712, + "name": "Storage_712_TOR2" + } + ], + "interfaces": [ + { + "name": "Unused", + "type": "Access", + "description": "initial unused for all interfaces then config as defined", + "intf_type": "Ethernet", + "start_intf": "1/1", + "end_intf": "1/54", + "access_vlan": "2", + "shutdown": true + }, + { + "name": "Loopback0", + "type": "L3", + "intf_type": "loopback", + "intf": "loopback0", + "ipv4": "100.100.69.22/32" + }, + { + "name": "P2P_Border1", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/48", + "ipv4": "100.100.69.6/30" + }, + { + "name": "P2P_Border2", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/47", + "ipv4": "100.100.69.14/30" + }, + { + "name": "Trunk_TO_BMC_SWITCH", + "type": "Trunk", + "intf_type": "Ethernet", + "intf": "1/49", + "native_vlan": "99", + "tagged_vlans": "125" + }, + { + "name": "Switchless_Compute_To_Host", + "type": "Trunk", + "intf_type": "Ethernet", + "start_intf": "1/1", + "end_intf": "1/16", + "native_vlan": "7", + "tagged_vlans": "7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516" + } + ], + "port_channels": [ + { + "id": 50, + "description": "P2P_IBGP", + "type": "L3", + "ipv4": "100.100.69.18", + "members": [ + "1/41", + "1/42" + ] + }, + { + "id": 101, + "description": "ToR_Peer_Link", + "type": "Trunk", + "native_vlan": "99", + "tagged_vlans": "", + "members": [ + "1/49", + "1/50", + "1/51" + ] + } + ], + "bgp": { + "asn": 64576, + "router_id": "100.100.69.22", + "networks": [ + "100.100.69.6/30", + "100.100.69.14/30", + "100.100.69.22/32", + "100.100.69.16/30", + "100.100.162.128/25", + "100.103.96.0/24", + "100.100.69.64/26", + "100.99.20.0/23", + "100.99.22.0/24", + "100.99.23.0/24", + "100.103.97.0/28", + "100.103.97.16/28", + "100.103.97.32/28", + "100.103.97.48/28", + "100.103.97.64/28", + "100.103.97.80/28", + "100.103.97.96/28", + "100.103.97.112/28", + "100.103.97.128/28", + "100.103.97.144/28", + "100.103.97.160/28", + "100.103.97.176/28", + "100.103.97.192/28", + "100.103.97.208/28", + "100.103.97.224/28", + "100.103.97.240/28" + ], + "neighbors": [ + { + "ip": "100.100.69.5", + "description": "TO_Border1", + "remote_as": 64809, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.100.69.13", + "description": "TO_Border2", + "remote_as": 64809, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.100.69.17", + "description": "iBGP_PEER", + "remote_as": 64576, + "af_ipv4_unicast": {} + }, + { + "ip": "100.100.162.128/25", + "description": "TO_HNVPA", + "remote_as": 65044, + "update_source": "Loopback0", + "ebgp_multihop": 3, + "af_ipv4_unicast": { + "prefix_list_out": "DefaultRoute" + } + } + ] + }, + "prefix_lists": { + "DefaultRoute": [ + { + "seq": 10, + "action": "permit", + "prefix": "0.0.0.0/0" + }, + { + "seq": 50, + "action": "deny", + "prefix": "0.0.0.0/0", + "prefix_filter": "le 32" + } + ] + }, + "qos": true, + "debug": { + "vlan_map": { + "C": [ + 6, + 201, + 301, + 401, + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516 + ], + "M": [ + 7 + ], + "S": [ + 711, + 712 + ], + "S1": [ + 711 + ], + "S2": [ + 712 + ], + "UNUSED": [ + 2 + ], + "NATIVE": [ + 99 + ] + }, + "ip_map": { + "P2P_BORDER1_TOR1": [ + "100.100.69.2/30" + ], + "P2P_TOR1_BORDER1": [ + "100.100.69.1" + ], + "P2P_BORDER1_TOR2": [ + "100.100.69.6/30" + ], + "P2P_TOR2_BORDER1": [ + "100.100.69.5" + ], + "P2P_BORDER2_TOR1": [ + "100.100.69.10/30" + ], + "P2P_TOR1_BORDER2": [ + "100.100.69.9" + ], + "P2P_BORDER2_TOR2": [ + "100.100.69.14/30" + ], + "P2P_TOR2_BORDER2": [ + "100.100.69.13" + ], + "P2P_IBGP_TOR1": [ + "100.100.69.17" + ], + "P2P_IBGP_TOR2": [ + "100.100.69.18" + ], + "LOOPBACK0_TOR1": [ + "100.100.69.21/32" + ], + "LOOPBACK0_TOR2": [ + "100.100.69.22/32" + ], + "HNVPA": [ + "100.100.162.128/25" + ], + "M": [ + "100.103.96.0/24" + ], + "C": [ + "100.99.20.0/23", + "100.99.22.0/24", + "100.99.23.0/24", + "100.103.97.0/28", + "100.103.97.16/28", + "100.103.97.32/28", + "100.103.97.48/28", + "100.103.97.64/28", + "100.103.97.80/28", + "100.103.97.96/28", + "100.103.97.112/28", + "100.103.97.128/28", + "100.103.97.144/28", + "100.103.97.160/28", + "100.103.97.176/28", + "100.103.97.192/28", + "100.103.97.208/28", + "100.103.97.224/28", + "100.103.97.240/28" + ] + }, + "resolved_trunks": [ + { + "name": "Trunk_TO_BMC_SWITCH", + "native_vlan": "99", + "tagged_vlans": "125" + }, + { + "name": "Switchless_Compute_To_Host", + "native_vlan": "7", + "tagged_vlans": "7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516" + } + ] + } +} \ No newline at end of file diff --git a/tests/test_cases/convert_lab_switch_input_json_dell_os10/expected_outputs/s46-r06-3248bmc-6-1.json b/tests/test_cases/convert_lab_switch_input_json_dell_os10/expected_outputs/s46-r06-3248bmc-6-1.json new file mode 100644 index 0000000..65e26ca --- /dev/null +++ b/tests/test_cases/convert_lab_switch_input_json_dell_os10/expected_outputs/s46-r06-3248bmc-6-1.json @@ -0,0 +1,81 @@ +{ + "switch": { + "make": "dellemc", + "model": "n3248te-on", + "type": "BMC", + "hostname": "s46-r06-3248bmc-6-1", + "version": "10.5.5.5", + "firmware": "os10" + }, + "vlans": [ + { + "vlan_id": 2, + "name": "UNUSED_VLAN", + "shutdown": true + }, + { + "vlan_id": 7, + "name": "Infra_7" + }, + { + "vlan_id": 99, + "name": "NativeVlan" + }, + { + "vlan_id": 125, + "name": "BMC_Mgmt_125", + "interface": { + "ip": "100.71.12.126", + "cidr": 26, + "mtu": 9216 + } + } + ], + "interfaces": [ + { + "name": "Unused", + "type": "Access", + "description": "initial unused for all interfaces then config as defined", + "intf_type": "Ethernet", + "start_intf": "1/1/1", + "end_intf": "1/1/54", + "access_vlan": "2", + "shutdown": true + }, + { + "name": "Host_BMC", + "type": "Access", + "description": "Host BMC Connection", + "intf_type": "Ethernet", + "start_intf": "1/1/1", + "end_intf": "1/1/40", + "access_vlan": "125" + }, + { + "name": "HLH_BMC", + "type": "Access", + "description": "HLH BMC Connection", + "intf_type": "Ethernet", + "intf": "1/1/46", + "access_vlan": "125" + }, + { + "name": "HLH_OS", + "type": "Access", + "description": "HLH OS Connection", + "intf_type": "Ethernet", + "start_intf": "1/1/49", + "end_intf": "1/1/50", + "access_vlan": "7" + }, + { + "name": "To_TORs", + "type": "Trunk", + "intf_type": "Ethernet", + "start_intf": "1/1/51", + "end_intf": "1/1/52", + "native_vlan": "99", + "tagged_vlans": "7,125" + } + ] +} \ No newline at end of file diff --git a/tests/test_cases/convert_lab_switch_input_json_dell_os10/expected_outputs/s46-r06-5248hl-6-1a.json b/tests/test_cases/convert_lab_switch_input_json_dell_os10/expected_outputs/s46-r06-5248hl-6-1a.json new file mode 100644 index 0000000..5b1ff52 --- /dev/null +++ b/tests/test_cases/convert_lab_switch_input_json_dell_os10/expected_outputs/s46-r06-5248hl-6-1a.json @@ -0,0 +1,646 @@ +{ + "switch": { + "make": "dellemc", + "model": "s5248f-on", + "type": "TOR1", + "hostname": "s46-r06-5248hl-6-1a", + "version": "10.5.5.5", + "firmware": "os10", + "site": "rr1" + }, + "vlans": [ + { + "vlan_id": 2, + "name": "UNUSED_VLAN", + "shutdown": true + }, + { + "vlan_id": 6, + "name": "HNVPA_6", + "interface": { + "ip": "100.71.143.2", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 6, + "priority": 150, + "virtual_ip": "100.71.143.1" + } + } + }, + { + "vlan_id": 7, + "name": "Infra_7", + "interface": { + "ip": "100.68.148.2", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 7, + "priority": 150, + "virtual_ip": "100.68.148.1" + } + } + }, + { + "vlan_id": 99, + "name": "NativeVlan" + }, + { + "vlan_id": 125, + "name": "BMC_Mgmt_125", + "interface": { + "ip": "100.71.12.123", + "cidr": 26, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 125, + "priority": 150, + "virtual_ip": "100.71.12.65" + } + } + }, + { + "vlan_id": 201, + "name": "Tenant_201", + "interface": { + "ip": "100.68.149.2", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 201, + "priority": 150, + "virtual_ip": "100.68.149.1" + } + } + }, + { + "vlan_id": 301, + "name": "LogicalTenant_301", + "interface": { + "ip": "100.68.150.2", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 301, + "priority": 150, + "virtual_ip": "100.68.150.1" + } + } + }, + { + "vlan_id": 401, + "name": "DhcpTenant_401", + "interface": { + "ip": "100.68.150.130", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 401, + "priority": 150, + "virtual_ip": "100.68.150.129" + } + } + }, + { + "vlan_id": 501, + "name": "L3forward_501", + "interface": { + "ip": "100.68.151.2", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 501, + "priority": 150, + "virtual_ip": "100.68.151.1" + } + } + }, + { + "vlan_id": 502, + "name": "L3forward_502", + "interface": { + "ip": "100.68.151.18", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 502, + "priority": 150, + "virtual_ip": "100.68.151.17" + } + } + }, + { + "vlan_id": 503, + "name": "L3forward_503", + "interface": { + "ip": "100.68.151.34", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 503, + "priority": 150, + "virtual_ip": "100.68.151.33" + } + } + }, + { + "vlan_id": 504, + "name": "L3forward_504", + "interface": { + "ip": "100.68.151.50", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 504, + "priority": 150, + "virtual_ip": "100.68.151.49" + } + } + }, + { + "vlan_id": 505, + "name": "L3forward_505", + "interface": { + "ip": "100.68.151.66", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 505, + "priority": 150, + "virtual_ip": "100.68.151.65" + } + } + }, + { + "vlan_id": 506, + "name": "L3forward_506", + "interface": { + "ip": "100.68.151.82", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 506, + "priority": 150, + "virtual_ip": "100.68.151.81" + } + } + }, + { + "vlan_id": 507, + "name": "L3forward_507", + "interface": { + "ip": "100.68.151.98", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 507, + "priority": 150, + "virtual_ip": "100.68.151.97" + } + } + }, + { + "vlan_id": 508, + "name": "L3forward_508", + "interface": { + "ip": "100.68.151.114", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 508, + "priority": 150, + "virtual_ip": "100.68.151.113" + } + } + }, + { + "vlan_id": 509, + "name": "L3forward_509", + "interface": { + "ip": "100.68.151.130", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 509, + "priority": 150, + "virtual_ip": "100.68.151.129" + } + } + }, + { + "vlan_id": 510, + "name": "L3forward_510", + "interface": { + "ip": "100.68.151.145", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 510, + "priority": 150, + "virtual_ip": "10.69.179.145" + } + } + }, + { + "vlan_id": 511, + "name": "L3forward_511", + "interface": { + "ip": "100.68.151.162", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 511, + "priority": 150, + "virtual_ip": "100.68.151.161" + } + } + }, + { + "vlan_id": 512, + "name": "L3forward_512", + "interface": { + "ip": "100.68.151.178", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 512, + "priority": 150, + "virtual_ip": "100.68.151.177" + } + } + }, + { + "vlan_id": 513, + "name": "L3forward_513", + "interface": { + "ip": "100.68.151.194", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 513, + "priority": 150, + "virtual_ip": "100.68.151.193" + } + } + }, + { + "vlan_id": 514, + "name": "L3forward_514", + "interface": { + "ip": "100.68.151.210", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 514, + "priority": 150, + "virtual_ip": "100.68.151.209" + } + } + }, + { + "vlan_id": 515, + "name": "L3forward_515", + "interface": { + "ip": "100.68.151.226", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 515, + "priority": 150, + "virtual_ip": "100.68.151.225" + } + } + }, + { + "vlan_id": 516, + "name": "L3forward_516", + "interface": { + "ip": "100.68.151.242", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 516, + "priority": 150, + "virtual_ip": "100.68.151.241" + } + } + }, + { + "vlan_id": 711, + "name": "Storage_711_TOR1" + }, + { + "vlan_id": 712, + "name": "Storage_711_TOR2" + } + ], + "interfaces": [ + { + "name": "Unused", + "type": "Access", + "description": "initial unused for all interfaces then config as defined", + "intf_type": "Ethernet", + "start_intf": "1/1/1", + "end_intf": "1/1/56", + "access_vlan": "2", + "shutdown": true + }, + { + "name": "Loopback0", + "type": "L3", + "intf_type": "loopback", + "intf": "loopback0", + "ipv4": "100.71.12.21/32" + }, + { + "name": "MLAG_Peer_Links", + "type": "MLAG", + "intf_type": "Ethernet", + "start_intf": "1/1/49", + "end_intf": "1/1/52" + }, + { + "name": "P2P_Border1", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/1/48:1", + "ipv4": "100.71.12.2/30" + }, + { + "name": "P2P_Border2", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/1/47:1", + "ipv4": "100.71.12.10/30" + }, + { + "name": "Trunk_TO_BMC_SWITCH", + "type": "Trunk", + "intf_type": "Ethernet", + "intf": "1/1/44", + "native_vlan": "99", + "tagged_vlans": "125" + }, + { + "name": "HyperConverged_To_Host", + "type": "Trunk", + "intf_type": "Ethernet", + "start_intf": "1/1/1", + "end_intf": "1/1/40", + "native_vlan": "7", + "tagged_vlans": "7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,711", + "service_policy": { + "qos_input": "AZLOCAL-QOS-MAP" + } + } + ], + "port_channels": [ + { + "id": 50, + "description": "P2P_IBGP", + "type": "L3", + "ipv4": "100.71.12.17", + "members": [ + "1/1/45:1", + "1/1/46:1" + ] + }, + { + "id": 102, + "description": "ToR_Peer_Link", + "type": "Trunk", + "native_vlan": "99", + "tagged_vlans": "", + "members": [ + "1/1/44:1" + ] + } + ], + "bgp": { + "asn": 64556, + "router_id": "100.71.12.21", + "networks": [ + "100.71.12.2/30", + "100.71.12.10/30", + "100.71.12.21/32", + "100.71.12.16/30", + "100.71.143.0/25", + "100.68.148.0/24", + "100.71.12.64/26", + "100.68.149.0/24", + "100.68.150.0/25", + "100.68.150.128/25", + "100.68.151.0/28", + "100.68.151.16/28", + "100.68.151.32/28", + "100.68.151.48/28", + "100.68.151.64/28", + "100.68.151.80/28", + "100.68.151.96/28", + "100.68.151.112/28", + "100.68.151.128/28", + "100.68.151.144/28", + "100.68.151.160/28", + "100.68.151.176/28", + "100.68.151.192/28", + "100.68.151.208/28", + "100.68.151.224/28", + "100.68.151.240/28" + ], + "neighbors": [ + { + "ip": "100.71.12.1", + "description": "TO_Border1", + "remote_as": 64846, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.71.12.9", + "description": "TO_Border2", + "remote_as": 64846, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.71.12.18", + "description": "iBGP_PEER", + "remote_as": 64556, + "af_ipv4_unicast": {} + }, + { + "ip": "100.71.143.0/25", + "description": "TO_HNVPA", + "remote_as": 65018, + "update_source": "Loopback0", + "ebgp_multihop": 3, + "af_ipv4_unicast": { + "prefix_list_out": "DefaultRoute" + } + } + ] + }, + "prefix_lists": { + "DefaultRoute": [ + { + "seq": 10, + "action": "permit", + "prefix": "0.0.0.0/0" + }, + { + "seq": 50, + "action": "deny", + "prefix": "0.0.0.0/0", + "prefix_filter": "le 32" + } + ] + }, + "qos": true, + "debug": { + "vlan_map": { + "C": [ + 6, + 201, + 301, + 401, + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516 + ], + "M": [ + 7 + ], + "S": [ + 711, + 712 + ], + "S1": [ + 711 + ], + "S2": [ + 712 + ], + "UNUSED": [ + 2 + ], + "NATIVE": [ + 99 + ] + }, + "ip_map": { + "P2P_BORDER1_TOR1": [ + "100.71.12.2/30" + ], + "P2P_TOR1_BORDER1": [ + "100.71.12.1" + ], + "P2P_BORDER1_TOR2": [ + "100.71.12.6/30" + ], + "P2P_TOR2_BORDER1": [ + "100.71.12.5" + ], + "P2P_BORDER2_TOR1": [ + "100.71.12.10/30" + ], + "P2P_TOR1_BORDER2": [ + "100.71.12.9" + ], + "P2P_BORDER2_TOR2": [ + "100.71.12.14/30" + ], + "P2P_TOR2_BORDER2": [ + "100.71.12.13" + ], + "P2P_IBGP_TOR1": [ + "100.71.12.17" + ], + "P2P_IBGP_TOR2": [ + "100.71.12.18" + ], + "LOOPBACK0_TOR1": [ + "100.71.12.21/32" + ], + "LOOPBACK0_TOR2": [ + "100.71.12.22/32" + ], + "HNVPA": [ + "100.71.143.0/25" + ], + "M": [ + "100.68.148.0/24" + ], + "C": [ + "100.68.149.0/24", + "100.68.150.0/25", + "100.68.150.128/25", + "100.68.151.0/28", + "100.68.151.16/28", + "100.68.151.32/28", + "100.68.151.48/28", + "100.68.151.64/28", + "100.68.151.80/28", + "100.68.151.96/28", + "100.68.151.112/28", + "100.68.151.128/28", + "100.68.151.144/28", + "100.68.151.160/28", + "100.68.151.176/28", + "100.68.151.192/28", + "100.68.151.208/28", + "100.68.151.224/28", + "100.68.151.240/28" + ] + }, + "resolved_trunks": [ + { + "name": "Trunk_TO_BMC_SWITCH", + "native_vlan": "99", + "tagged_vlans": "125" + }, + { + "name": "HyperConverged_To_Host", + "native_vlan": "7", + "tagged_vlans": "7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,711" + } + ] + } +} \ No newline at end of file diff --git a/tests/test_cases/convert_lab_switch_input_json_dell_os10/expected_outputs/s46-r06-5248hl-6-1b.json b/tests/test_cases/convert_lab_switch_input_json_dell_os10/expected_outputs/s46-r06-5248hl-6-1b.json new file mode 100644 index 0000000..f7c5cea --- /dev/null +++ b/tests/test_cases/convert_lab_switch_input_json_dell_os10/expected_outputs/s46-r06-5248hl-6-1b.json @@ -0,0 +1,646 @@ +{ + "switch": { + "make": "dellemc", + "model": "s5248f-on", + "type": "TOR2", + "hostname": "s46-r06-5248hl-6-1b", + "version": "10.5.5.5", + "firmware": "os10", + "site": "rr1" + }, + "vlans": [ + { + "vlan_id": 2, + "name": "UNUSED_VLAN", + "shutdown": true + }, + { + "vlan_id": 6, + "name": "HNVPA_6", + "interface": { + "ip": "100.71.143.3", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 6, + "priority": 140, + "virtual_ip": "100.71.143.1" + } + } + }, + { + "vlan_id": 7, + "name": "Infra_7", + "interface": { + "ip": "100.68.148.3", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 7, + "priority": 140, + "virtual_ip": "100.68.148.1" + } + } + }, + { + "vlan_id": 99, + "name": "NativeVlan" + }, + { + "vlan_id": 125, + "name": "BMC_Mgmt_125", + "interface": { + "ip": "100.71.12.124", + "cidr": 26, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 125, + "priority": 140, + "virtual_ip": "100.71.12.65" + } + } + }, + { + "vlan_id": 201, + "name": "Tenant_201", + "interface": { + "ip": "100.68.149.3", + "cidr": 24, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 201, + "priority": 140, + "virtual_ip": "100.68.149.1" + } + } + }, + { + "vlan_id": 301, + "name": "LogicalTenant_301", + "interface": { + "ip": "100.68.150.3", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 301, + "priority": 140, + "virtual_ip": "100.68.150.1" + } + } + }, + { + "vlan_id": 401, + "name": "DhcpTenant_401", + "interface": { + "ip": "100.68.150.131", + "cidr": 25, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 401, + "priority": 140, + "virtual_ip": "100.68.150.129" + } + } + }, + { + "vlan_id": 501, + "name": "L3forward_501", + "interface": { + "ip": "100.68.151.3", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 501, + "priority": 140, + "virtual_ip": "100.68.151.1" + } + } + }, + { + "vlan_id": 502, + "name": "L3forward_502", + "interface": { + "ip": "100.68.151.19", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 502, + "priority": 140, + "virtual_ip": "100.68.151.17" + } + } + }, + { + "vlan_id": 503, + "name": "L3forward_503", + "interface": { + "ip": "100.68.151.35", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 503, + "priority": 140, + "virtual_ip": "100.68.151.33" + } + } + }, + { + "vlan_id": 504, + "name": "L3forward_504", + "interface": { + "ip": "100.68.151.51", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 504, + "priority": 140, + "virtual_ip": "100.68.151.49" + } + } + }, + { + "vlan_id": 505, + "name": "L3forward_505", + "interface": { + "ip": "100.68.151.67", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 505, + "priority": 140, + "virtual_ip": "100.68.151.65" + } + } + }, + { + "vlan_id": 506, + "name": "L3forward_506", + "interface": { + "ip": "100.68.151.83", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 506, + "priority": 140, + "virtual_ip": "100.68.151.81" + } + } + }, + { + "vlan_id": 507, + "name": "L3forward_507", + "interface": { + "ip": "100.68.151.99", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 507, + "priority": 140, + "virtual_ip": "100.68.151.97" + } + } + }, + { + "vlan_id": 508, + "name": "L3forward_508", + "interface": { + "ip": "100.68.151.115", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 508, + "priority": 140, + "virtual_ip": "100.68.151.113" + } + } + }, + { + "vlan_id": 509, + "name": "L3forward_509", + "interface": { + "ip": "100.68.151.131", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 509, + "priority": 140, + "virtual_ip": "100.68.151.129" + } + } + }, + { + "vlan_id": 510, + "name": "L3forward_510", + "interface": { + "ip": "100.68.151.146", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 510, + "priority": 140, + "virtual_ip": "10.69.179.145" + } + } + }, + { + "vlan_id": 511, + "name": "L3forward_511", + "interface": { + "ip": "100.68.151.163", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 511, + "priority": 140, + "virtual_ip": "100.68.151.161" + } + } + }, + { + "vlan_id": 512, + "name": "L3forward_512", + "interface": { + "ip": "100.68.151.179", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 512, + "priority": 140, + "virtual_ip": "100.68.151.177" + } + } + }, + { + "vlan_id": 513, + "name": "L3forward_513", + "interface": { + "ip": "100.68.151.195", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 513, + "priority": 140, + "virtual_ip": "100.68.151.193" + } + } + }, + { + "vlan_id": 514, + "name": "L3forward_514", + "interface": { + "ip": "100.68.151.211", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 514, + "priority": 140, + "virtual_ip": "100.68.151.209" + } + } + }, + { + "vlan_id": 515, + "name": "L3forward_515", + "interface": { + "ip": "100.68.151.227", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 515, + "priority": 140, + "virtual_ip": "100.68.151.225" + } + } + }, + { + "vlan_id": 516, + "name": "L3forward_516", + "interface": { + "ip": "100.68.151.243", + "cidr": 28, + "mtu": 9216, + "redundancy": { + "type": "vrrp", + "group": 516, + "priority": 140, + "virtual_ip": "100.68.151.241" + } + } + }, + { + "vlan_id": 711, + "name": "Storage_711_TOR1" + }, + { + "vlan_id": 712, + "name": "Storage_711_TOR2" + } + ], + "interfaces": [ + { + "name": "Unused", + "type": "Access", + "description": "initial unused for all interfaces then config as defined", + "intf_type": "Ethernet", + "start_intf": "1/1/1", + "end_intf": "1/1/56", + "access_vlan": "2", + "shutdown": true + }, + { + "name": "Loopback0", + "type": "L3", + "intf_type": "loopback", + "intf": "loopback0", + "ipv4": "100.71.12.22/32" + }, + { + "name": "MLAG_Peer_Links", + "type": "MLAG", + "intf_type": "Ethernet", + "start_intf": "1/1/49", + "end_intf": "1/1/52" + }, + { + "name": "P2P_Border1", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/1/48:1", + "ipv4": "100.71.12.6/30" + }, + { + "name": "P2P_Border2", + "type": "L3", + "intf_type": "Ethernet", + "intf": "1/1/47:1", + "ipv4": "100.71.12.14/30" + }, + { + "name": "Trunk_TO_BMC_SWITCH", + "type": "Trunk", + "intf_type": "Ethernet", + "intf": "1/1/44", + "native_vlan": "99", + "tagged_vlans": "125" + }, + { + "name": "HyperConverged_To_Host", + "type": "Trunk", + "intf_type": "Ethernet", + "start_intf": "1/1/1", + "end_intf": "1/1/40", + "native_vlan": "7", + "tagged_vlans": "7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,712", + "service_policy": { + "qos_input": "AZLOCAL-QOS-MAP" + } + } + ], + "port_channels": [ + { + "id": 50, + "description": "P2P_IBGP", + "type": "L3", + "ipv4": "100.71.12.18", + "members": [ + "1/1/45:1", + "1/1/46:1" + ] + }, + { + "id": 102, + "description": "ToR_Peer_Link", + "type": "Trunk", + "native_vlan": "99", + "tagged_vlans": "", + "members": [ + "1/1/44:1" + ] + } + ], + "bgp": { + "asn": 64556, + "router_id": "100.71.12.22", + "networks": [ + "100.71.12.6/30", + "100.71.12.14/30", + "100.71.12.22/32", + "100.71.12.16/30", + "100.71.143.0/25", + "100.68.148.0/24", + "100.71.12.64/26", + "100.68.149.0/24", + "100.68.150.0/25", + "100.68.150.128/25", + "100.68.151.0/28", + "100.68.151.16/28", + "100.68.151.32/28", + "100.68.151.48/28", + "100.68.151.64/28", + "100.68.151.80/28", + "100.68.151.96/28", + "100.68.151.112/28", + "100.68.151.128/28", + "100.68.151.144/28", + "100.68.151.160/28", + "100.68.151.176/28", + "100.68.151.192/28", + "100.68.151.208/28", + "100.68.151.224/28", + "100.68.151.240/28" + ], + "neighbors": [ + { + "ip": "100.71.12.5", + "description": "TO_Border1", + "remote_as": 64846, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.71.12.13", + "description": "TO_Border2", + "remote_as": 64846, + "af_ipv4_unicast": { + "prefix_list_in": "DefaultRoute" + } + }, + { + "ip": "100.71.12.17", + "description": "iBGP_PEER", + "remote_as": 64556, + "af_ipv4_unicast": {} + }, + { + "ip": "100.71.143.0/25", + "description": "TO_HNVPA", + "remote_as": 65018, + "update_source": "Loopback0", + "ebgp_multihop": 3, + "af_ipv4_unicast": { + "prefix_list_out": "DefaultRoute" + } + } + ] + }, + "prefix_lists": { + "DefaultRoute": [ + { + "seq": 10, + "action": "permit", + "prefix": "0.0.0.0/0" + }, + { + "seq": 50, + "action": "deny", + "prefix": "0.0.0.0/0", + "prefix_filter": "le 32" + } + ] + }, + "qos": true, + "debug": { + "vlan_map": { + "C": [ + 6, + 201, + 301, + 401, + 501, + 502, + 503, + 504, + 505, + 506, + 507, + 508, + 509, + 510, + 511, + 512, + 513, + 514, + 515, + 516 + ], + "M": [ + 7 + ], + "S": [ + 711, + 712 + ], + "S1": [ + 711 + ], + "S2": [ + 712 + ], + "UNUSED": [ + 2 + ], + "NATIVE": [ + 99 + ] + }, + "ip_map": { + "P2P_BORDER1_TOR1": [ + "100.71.12.2/30" + ], + "P2P_TOR1_BORDER1": [ + "100.71.12.1" + ], + "P2P_BORDER1_TOR2": [ + "100.71.12.6/30" + ], + "P2P_TOR2_BORDER1": [ + "100.71.12.5" + ], + "P2P_BORDER2_TOR1": [ + "100.71.12.10/30" + ], + "P2P_TOR1_BORDER2": [ + "100.71.12.9" + ], + "P2P_BORDER2_TOR2": [ + "100.71.12.14/30" + ], + "P2P_TOR2_BORDER2": [ + "100.71.12.13" + ], + "P2P_IBGP_TOR1": [ + "100.71.12.17" + ], + "P2P_IBGP_TOR2": [ + "100.71.12.18" + ], + "LOOPBACK0_TOR1": [ + "100.71.12.21/32" + ], + "LOOPBACK0_TOR2": [ + "100.71.12.22/32" + ], + "HNVPA": [ + "100.71.143.0/25" + ], + "M": [ + "100.68.148.0/24" + ], + "C": [ + "100.68.149.0/24", + "100.68.150.0/25", + "100.68.150.128/25", + "100.68.151.0/28", + "100.68.151.16/28", + "100.68.151.32/28", + "100.68.151.48/28", + "100.68.151.64/28", + "100.68.151.80/28", + "100.68.151.96/28", + "100.68.151.112/28", + "100.68.151.128/28", + "100.68.151.144/28", + "100.68.151.160/28", + "100.68.151.176/28", + "100.68.151.192/28", + "100.68.151.208/28", + "100.68.151.224/28", + "100.68.151.240/28" + ] + }, + "resolved_trunks": [ + { + "name": "Trunk_TO_BMC_SWITCH", + "native_vlan": "99", + "tagged_vlans": "125" + }, + { + "name": "HyperConverged_To_Host", + "native_vlan": "7", + "tagged_vlans": "7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,712" + } + ] + } +} \ No newline at end of file diff --git a/tests/test_cases/std_cisco_nxos_switched/expected_bgp.cfg b/tests/test_cases/std_cisco_nxos_switched/expected_bgp.cfg new file mode 100644 index 0000000..3c4499d --- /dev/null +++ b/tests/test_cases/std_cisco_nxos_switched/expected_bgp.cfg @@ -0,0 +1,61 @@ + +! bgp.j2 +router bgp 65242 + router-id 100.71.85.21 + bestpath as-path multipath-relax + log-neighbor-changes + address-family ipv4 unicast + network 100.71.85.2/30 + network 100.71.85.10/30 + network 100.71.85.21/32 + network 100.69.177.0/24 + network 100.69.178.0/25 + network 100.69.178.128/25 + network 100.69.179.0/28 + network 100.69.179.16/28 + network 100.69.179.32/28 + network 100.69.179.48/28 + network 100.69.179.64/28 + network 100.69.179.80/28 + network 100.69.179.96/28 + network 100.69.179.112/28 + network 100.69.179.128/28 + network 100.69.179.144/28 + network 100.69.179.160/28 + network 100.69.179.176/28 + network 100.69.179.192/28 + network 100.69.179.208/28 + network 100.69.179.224/28 + network 100.69.179.240/28 + maximum-paths 8 + maximum-paths ibgp 8 + + neighbor 100.71.85.1 + description TO_Border1 + remote-as 64846 + address-family ipv4 unicast + maximum-prefix 12000 warning-only + prefix-list DefaultRoute in + + neighbor 100.71.85.9 + description TO_Border2 + remote-as 64846 + address-family ipv4 unicast + maximum-prefix 12000 warning-only + prefix-list DefaultRoute in + + neighbor 100.71.85.18 + description iBGP_PEER + remote-as 65242 + address-family ipv4 unicast + maximum-prefix 12000 warning-only + + neighbor 100.71.131.0/25 + description TO_HNVPA + remote-as 65112 + update-source Loopback0 + ebgp-multihop 3 + address-family ipv4 unicast + maximum-prefix 12000 warning-only + prefix-list DefaultRoute out + \ No newline at end of file diff --git a/tests/test_cases/std_cisco_nxos_switched/expected_full_config.cfg b/tests/test_cases/std_cisco_nxos_switched/expected_full_config.cfg new file mode 100644 index 0000000..af80c4a --- /dev/null +++ b/tests/test_cases/std_cisco_nxos_switched/expected_full_config.cfg @@ -0,0 +1,736 @@ +! system.j2 + +! Name: s46-r21-93180hl-24-1a +! Make: cisco +! Model: 93180yc-fx +hostname s46-r21-93180hl-24-1a + +banner motd # +NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE + +hostname s46-r21-93180hl-24-1a +Unauthorized access and/or use prohibited. +All access and/or use subject to monitoring. + +NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE +# + + +no feature telnet +feature scp-server +feature bgp +feature interface-vlan +feature lldp +feature dhcp +feature vpc +feature hsrp +feature lacp +feature ssh +feature tacacs+ + + +clock timezone PST -8 0 +clock summer-time PDT 2 Sun Apr 02:00 1 Sun Nov 02:00 60 +ntp server [NTP_SERVER_IP] +ntp source-interface [MGMT_VLAN] + + +logging server [LOG_SERVER_IP] 7 facility local7 use-vrf default +logging source-interface [MGMT_VLAN] +logging level local7 7 +no logging console +login on-success log +logging origin-id hostname + +logging level acllog 7 +logging level aclmgr 7 +logging level eth_port_channel 7 +logging level hsrp 7 +logging level icam 7 +logging level interface-vlan 7 +logging level ipqosmgr 7 +logging level vlan_mgr 7 +logging level vpc 7 +logging level netstack 7 +logging level bgp 7 + + +no cdp enable +lldp tlv-select dcbxp egress-queuing + +service dhcp +ip dhcp relay + +ip load-sharing address source-destination port source-destination + +ip icmp-errors source-interface [MGMT_VLAN] + +cli alias name wr copy running-config startup-config + + +snmp-server community [PLACEHOLDER] ro +snmp-server community [PLACEHOLDER] rW +snmp-server contact "Contact Support" +snmp-server location + +! login.j2 + +fips mode enable +user max-logins 1 +password prompt username +userpassphrase min-length 15 max-length 80 +username admin password 0 $CREDENTIAL_PLACEHOLDER$ role network-admin +username $CREDENTIAL_PLACEHOLDER$ password 0 $CREDENTIAL_PLACEHOLDER$ role network-admin + + +no feature ssh +no ssh key ecdsa +no ssh key rsa +ssh key rsa 2048 force +ssh key ecdsa 256 force +feature ssh + + +line console + exec-timeout 10 +line vty + exec-timeout 10 + session-limit 3 + + +! Replace [TACACS_SERVER_IP], [TACACS_KEY], [TACACS_GROUP],[MGMT_VLAN] with actual values. +tacacs-server key [TACACS_KEY] +tacacs-server timeout 2 +ip tacacs source-interface [MGMT_VLAN] + +tacacs-server host [TACACS_SERVER_IP] +tacacs-server host [TACACS_SERVER_IP] + +aaa group server tacacs+ [TACACS_GROUP] + server [TACACS_SERVER_IP] + server [TACACS_SERVER_IP] + source-interface [MGMT_VLAN] + +aaa authentication login default group [TACACS_GROUP] +aaa authentication login console group [TACACS_GROUP] +aaa accounting default group [TACACS_GROUP] + +! qos.j2 + +policy-map type network-qos AZLOCAL-NWQOS + class type network-qos AZLOCAL-NWQOS-RDMA + pause pfc-cos 3 + mtu 9216 + class type network-qos AZLOCAL-NWQOS-DEFAULT + mtu 9216 + class type network-qos AZLOCAL-NWQOS-CLUSTER + mtu 9216 + + +class-map type qos match-all AZLOCAL-QOS-RDMA + match cos 3 +class-map type qos match-all AZLOCAL-QOS-CLUSTER + match cos 7 + +policy-map type qos AZLOCAL-QOS-MAP + class AZLOCAL-QOS-RDMA + set qos-group 3 + class AZLOCAL-QOS-CLUSTER + set qos-group 7 + + +policy-map type queuing AZLOCAL-QUEUE-OUT + class type queuing c-out-8q-q3 + bandwidth remaining percent 50 + random-detect minimum-threshold 300 kbytes maximum-threshold 300 kbytes drop-probability 100 weight 0 ecn + class type queuing c-out-8q-q-default + bandwidth remaining percent 48 + class type queuing c-out-8q-q7 + bandwidth percent 2 + + +system qos + service-policy type network-qos AZLOCAL-NWQOS + service-policy type queuing output AZLOCAL-QUEUE-OUT + +! vlan.j2 + +vlan 2 + name UNUSED_VLAN + shutdown +vlan 6 + name HNVPA_6 + +vlan 7 + name Infra_7 + +vlan 99 + name NativeVlan + +vlan 125 + name BMC_Mgmt_125 + +vlan 201 + name Tenant_201 + +vlan 301 + name LogicalTenant_301 + +vlan 401 + name DhcpTenant_401 + +vlan 501 + name L3forward_501 + +vlan 502 + name L3forward_502 + +vlan 503 + name L3forward_503 + +vlan 504 + name L3forward_504 + +vlan 505 + name L3forward_505 + +vlan 506 + name L3forward_506 + +vlan 507 + name L3forward_507 + +vlan 508 + name L3forward_508 + +vlan 509 + name L3forward_509 + +vlan 510 + name L3forward_510 + +vlan 511 + name L3forward_511 + +vlan 512 + name L3forward_512 + +vlan 513 + name L3forward_513 + +vlan 514 + name L3forward_514 + +vlan 515 + name L3forward_515 + +vlan 516 + name L3forward_516 + +vlan 711 + name Storage_711_TOR1 + +vlan 712 + name Storage_712_TOR2 + + + +interface vlan6 + description HNVPA_6 + mtu 9216 + no shutdown + ip address 100.71.131.2/25 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 6 + priority 150 + ip 100.71.131.1 + +interface vlan7 + description Infra_7 + mtu 9216 + no shutdown + ip address 100.69.176.2/24 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 7 + priority 150 + ip 100.69.176.1 + +interface vlan125 + description BMC_Mgmt_125 + mtu 9216 + no shutdown + ip address 100.71.85.123/26 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 125 + priority 150 + ip 100.71.85.65 + +interface vlan201 + description Tenant_201 + mtu 9216 + no shutdown + ip address 100.69.177.2/24 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 201 + priority 150 + ip 100.69.177.1 + +interface vlan301 + description LogicalTenant_301 + mtu 9216 + no shutdown + ip address 100.69.178.2/25 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 301 + priority 150 + ip 100.69.178.1 + +interface vlan401 + description DhcpTenant_401 + mtu 9216 + no shutdown + ip address 100.69.178.130/25 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 401 + priority 150 + ip 100.69.178.129 + +interface vlan501 + description L3forward_501 + mtu 9216 + no shutdown + ip address 100.69.179.2/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 501 + priority 150 + ip 100.69.179.1 + +interface vlan502 + description L3forward_502 + mtu 9216 + no shutdown + ip address 100.69.179.18/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 502 + priority 150 + ip 100.69.179.17 + +interface vlan503 + description L3forward_503 + mtu 9216 + no shutdown + ip address 100.69.179.34/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 503 + priority 150 + ip 100.69.179.33 + +interface vlan504 + description L3forward_504 + mtu 9216 + no shutdown + ip address 100.69.179.50/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 504 + priority 150 + ip 100.69.179.49 + +interface vlan505 + description L3forward_505 + mtu 9216 + no shutdown + ip address 100.69.179.66/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 505 + priority 150 + ip 100.69.179.65 + +interface vlan506 + description L3forward_506 + mtu 9216 + no shutdown + ip address 100.69.179.82/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 506 + priority 150 + ip 100.69.179.81 + +interface vlan507 + description L3forward_507 + mtu 9216 + no shutdown + ip address 100.69.179.98/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 507 + priority 150 + ip 100.69.179.97 + +interface vlan508 + description L3forward_508 + mtu 9216 + no shutdown + ip address 100.69.179.114/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 508 + priority 150 + ip 100.69.179.113 + +interface vlan509 + description L3forward_509 + mtu 9216 + no shutdown + ip address 100.69.179.130/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 509 + priority 150 + ip 100.69.179.129 + +interface vlan510 + description L3forward_510 + mtu 9216 + no shutdown + ip address 100.69.179.145/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 510 + priority 150 + ip + +interface vlan511 + description L3forward_511 + mtu 9216 + no shutdown + ip address 100.69.179.162/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 511 + priority 150 + ip 100.69.179.161 + +interface vlan512 + description L3forward_512 + mtu 9216 + no shutdown + ip address 100.69.179.178/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 512 + priority 150 + ip 100.69.179.177 + +interface vlan513 + description L3forward_513 + mtu 9216 + no shutdown + ip address 100.69.179.194/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 513 + priority 150 + ip 100.69.179.193 + +interface vlan514 + description L3forward_514 + mtu 9216 + no shutdown + ip address 100.69.179.210/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 514 + priority 150 + ip 100.69.179.209 + +interface vlan515 + description L3forward_515 + mtu 9216 + no shutdown + ip address 100.69.179.226/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 515 + priority 150 + ip 100.69.179.225 + +interface vlan516 + description L3forward_516 + mtu 9216 + no shutdown + ip address 100.69.179.242/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 516 + priority 150 + ip 100.69.179.241 + + + +! interface.j2 + +interface Ethernet 1/1-1/54 + description Unused + no cdp enable + switchport + switchport mode access + switchport access vlan 2 + spanning-tree port type edge + no logging event port link-status + mtu 9216 + shutdown + + +interface Ethernet 1/49 + description Trunk_TO_BMC_SWITCH + no cdp enable + switchport + switchport mode trunk + switchport trunk native vlan 99 + switchport trunk allowed vlan 125 + priority-flow-control mode on send-tlv + spanning-tree port type edge trunk + no logging event port link-status + mtu 9216 + no shutdown + +interface Ethernet 1/1-1/16 + description Switched_Compute_To_Host + no cdp enable + switchport + switchport mode trunk + switchport trunk native vlan 7 + switchport trunk allowed vlan 7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516 + priority-flow-control mode on send-tlv + spanning-tree port type edge trunk + no logging event port link-status + mtu 9216 + no shutdown + +interface Ethernet 1/17-1/32 + description Switched_Storage_To_Host + no cdp enable + switchport + switchport mode trunk + switchport trunk native vlan 99 + switchport trunk allowed vlan 711 + priority-flow-control mode on send-tlv + spanning-tree port type edge trunk + no logging event port link-status + mtu 9216 + service-policy type qos input AZLOCAL-QOS-MAP + no shutdown + + +interface Ethernet 1/48 + description P2P_Border1 + no cdp enable + no switchport + ip address 100.71.85.2/30 + no ip redirects + no ipv6 redirects + mtu 9216 + no shutdown + +interface Ethernet 1/47 + description P2P_Border2 + no cdp enable + no switchport + ip address 100.71.85.10/30 + no ip redirects + no ipv6 redirects + mtu 9216 + no shutdown + + +interface loopbackloopback0 + description Loopback0 + ip address 100.71.85.21/32 + mtu 9216 + no shutdown + + + +! port-channel.j2 + + +interface port-channel50 + description P2P_IBGP + no switchport + ip address 100.71.85.17 + logging event port link-status + mtu 9216 + no shutdown + + +interface Ethernet 1/41 + description P2P_IBGP + no cdp enable + logging event port link-status + mtu 9216 + channel-group 50 mode active + no shutdown + +interface Ethernet 1/42 + description P2P_IBGP + no cdp enable + logging event port link-status + mtu 9216 + channel-group 50 mode active + no shutdown + + + +interface port-channel101 + description ToR_Peer_Link + switchport + switchport mode trunk + switchport trunk native vlan 99 + spanning-tree port type network + logging event port link-status + mtu 9216 + no shutdown + + +interface Ethernet 1/49 + description ToR_Peer_Link + no cdp enable + switchport + switchport mode trunk + switchport trunk native vlan 99 + spanning-tree port type network + logging event port link-status + mtu 9216 + channel-group 101 mode active + no shutdown + +interface Ethernet 1/50 + description ToR_Peer_Link + no cdp enable + switchport + switchport mode trunk + switchport trunk native vlan 99 + spanning-tree port type network + logging event port link-status + mtu 9216 + channel-group 101 mode active + no shutdown + +interface Ethernet 1/51 + description ToR_Peer_Link + no cdp enable + switchport + switchport mode trunk + switchport trunk native vlan 99 + spanning-tree port type network + logging event port link-status + mtu 9216 + channel-group 101 mode active + no shutdown + + + + + +! prefix_list.j2 +ip prefix-list DefaultRoute seq 10 permit 0.0.0.0/0 +ip prefix-list DefaultRoute seq 50 deny 0.0.0.0/0 le 32 + + + + +! bgp.j2 +router bgp 65242 + router-id 100.71.85.21 + bestpath as-path multipath-relax + log-neighbor-changes + address-family ipv4 unicast + network 100.71.85.2/30 + network 100.71.85.10/30 + network 100.71.85.21/32 + network 100.69.177.0/24 + network 100.69.178.0/25 + network 100.69.178.128/25 + network 100.69.179.0/28 + network 100.69.179.16/28 + network 100.69.179.32/28 + network 100.69.179.48/28 + network 100.69.179.64/28 + network 100.69.179.80/28 + network 100.69.179.96/28 + network 100.69.179.112/28 + network 100.69.179.128/28 + network 100.69.179.144/28 + network 100.69.179.160/28 + network 100.69.179.176/28 + network 100.69.179.192/28 + network 100.69.179.208/28 + network 100.69.179.224/28 + network 100.69.179.240/28 + maximum-paths 8 + maximum-paths ibgp 8 + + neighbor 100.71.85.1 + description TO_Border1 + remote-as 64846 + address-family ipv4 unicast + maximum-prefix 12000 warning-only + prefix-list DefaultRoute in + + neighbor 100.71.85.9 + description TO_Border2 + remote-as 64846 + address-family ipv4 unicast + maximum-prefix 12000 warning-only + prefix-list DefaultRoute in + + neighbor 100.71.85.18 + description iBGP_PEER + remote-as 65242 + address-family ipv4 unicast + maximum-prefix 12000 warning-only + + neighbor 100.71.131.0/25 + description TO_HNVPA + remote-as 65112 + update-source Loopback0 + ebgp-multihop 3 + address-family ipv4 unicast + maximum-prefix 12000 warning-only + prefix-list DefaultRoute out + + diff --git a/tests/test_cases/std_cisco_nxos_switched/expected_interface.cfg b/tests/test_cases/std_cisco_nxos_switched/expected_interface.cfg new file mode 100644 index 0000000..4446c0d --- /dev/null +++ b/tests/test_cases/std_cisco_nxos_switched/expected_interface.cfg @@ -0,0 +1,82 @@ +! interface.j2 + +interface Ethernet 1/1-1/54 + description Unused + no cdp enable + switchport + switchport mode access + switchport access vlan 2 + spanning-tree port type edge + no logging event port link-status + mtu 9216 + shutdown + + +interface Ethernet 1/49 + description Trunk_TO_BMC_SWITCH + no cdp enable + switchport + switchport mode trunk + switchport trunk native vlan 99 + switchport trunk allowed vlan 125 + priority-flow-control mode on send-tlv + spanning-tree port type edge trunk + no logging event port link-status + mtu 9216 + no shutdown + +interface Ethernet 1/1-1/16 + description Switched_Compute_To_Host + no cdp enable + switchport + switchport mode trunk + switchport trunk native vlan 7 + switchport trunk allowed vlan 7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516 + priority-flow-control mode on send-tlv + spanning-tree port type edge trunk + no logging event port link-status + mtu 9216 + no shutdown + +interface Ethernet 1/17-1/32 + description Switched_Storage_To_Host + no cdp enable + switchport + switchport mode trunk + switchport trunk native vlan 99 + switchport trunk allowed vlan 711 + priority-flow-control mode on send-tlv + spanning-tree port type edge trunk + no logging event port link-status + mtu 9216 + service-policy type qos input AZLOCAL-QOS-MAP + no shutdown + + +interface Ethernet 1/48 + description P2P_Border1 + no cdp enable + no switchport + ip address 100.71.85.2/30 + no ip redirects + no ipv6 redirects + mtu 9216 + no shutdown + +interface Ethernet 1/47 + description P2P_Border2 + no cdp enable + no switchport + ip address 100.71.85.10/30 + no ip redirects + no ipv6 redirects + mtu 9216 + no shutdown + + +interface loopbackloopback0 + description Loopback0 + ip address 100.71.85.21/32 + mtu 9216 + no shutdown + diff --git a/tests/test_cases/std_cisco_nxos_switched/expected_login.cfg b/tests/test_cases/std_cisco_nxos_switched/expected_login.cfg new file mode 100644 index 0000000..21fb6d9 --- /dev/null +++ b/tests/test_cases/std_cisco_nxos_switched/expected_login.cfg @@ -0,0 +1,41 @@ +! login.j2 + +fips mode enable +user max-logins 1 +password prompt username +userpassphrase min-length 15 max-length 80 +username admin password 0 $CREDENTIAL_PLACEHOLDER$ role network-admin +username $CREDENTIAL_PLACEHOLDER$ password 0 $CREDENTIAL_PLACEHOLDER$ role network-admin + + +no feature ssh +no ssh key ecdsa +no ssh key rsa +ssh key rsa 2048 force +ssh key ecdsa 256 force +feature ssh + + +line console + exec-timeout 10 +line vty + exec-timeout 10 + session-limit 3 + + +! Replace [TACACS_SERVER_IP], [TACACS_KEY], [TACACS_GROUP],[MGMT_VLAN] with actual values. +tacacs-server key [TACACS_KEY] +tacacs-server timeout 2 +ip tacacs source-interface [MGMT_VLAN] + +tacacs-server host [TACACS_SERVER_IP] +tacacs-server host [TACACS_SERVER_IP] + +aaa group server tacacs+ [TACACS_GROUP] + server [TACACS_SERVER_IP] + server [TACACS_SERVER_IP] + source-interface [MGMT_VLAN] + +aaa authentication login default group [TACACS_GROUP] +aaa authentication login console group [TACACS_GROUP] +aaa accounting default group [TACACS_GROUP] \ No newline at end of file diff --git a/tests/test_cases/std_cisco_nxos_switched/expected_port_channel.cfg b/tests/test_cases/std_cisco_nxos_switched/expected_port_channel.cfg new file mode 100644 index 0000000..8e7caed --- /dev/null +++ b/tests/test_cases/std_cisco_nxos_switched/expected_port_channel.cfg @@ -0,0 +1,78 @@ +! port-channel.j2 + + +interface port-channel50 + description P2P_IBGP + no switchport + ip address 100.71.85.17 + logging event port link-status + mtu 9216 + no shutdown + + +interface Ethernet 1/41 + description P2P_IBGP + no cdp enable + logging event port link-status + mtu 9216 + channel-group 50 mode active + no shutdown + +interface Ethernet 1/42 + description P2P_IBGP + no cdp enable + logging event port link-status + mtu 9216 + channel-group 50 mode active + no shutdown + + + +interface port-channel101 + description ToR_Peer_Link + switchport + switchport mode trunk + switchport trunk native vlan 99 + spanning-tree port type network + logging event port link-status + mtu 9216 + no shutdown + + +interface Ethernet 1/49 + description ToR_Peer_Link + no cdp enable + switchport + switchport mode trunk + switchport trunk native vlan 99 + spanning-tree port type network + logging event port link-status + mtu 9216 + channel-group 101 mode active + no shutdown + +interface Ethernet 1/50 + description ToR_Peer_Link + no cdp enable + switchport + switchport mode trunk + switchport trunk native vlan 99 + spanning-tree port type network + logging event port link-status + mtu 9216 + channel-group 101 mode active + no shutdown + +interface Ethernet 1/51 + description ToR_Peer_Link + no cdp enable + switchport + switchport mode trunk + switchport trunk native vlan 99 + spanning-tree port type network + logging event port link-status + mtu 9216 + channel-group 101 mode active + no shutdown + + diff --git a/tests/test_cases/std_cisco_nxos_switched/expected_prefix_list.cfg b/tests/test_cases/std_cisco_nxos_switched/expected_prefix_list.cfg new file mode 100644 index 0000000..480b5ca --- /dev/null +++ b/tests/test_cases/std_cisco_nxos_switched/expected_prefix_list.cfg @@ -0,0 +1,5 @@ + +! prefix_list.j2 +ip prefix-list DefaultRoute seq 10 permit 0.0.0.0/0 +ip prefix-list DefaultRoute seq 50 deny 0.0.0.0/0 le 32 + diff --git a/tests/test_cases/std_cisco_nxos_switched/expected_qos.cfg b/tests/test_cases/std_cisco_nxos_switched/expected_qos.cfg new file mode 100644 index 0000000..d1da3ff --- /dev/null +++ b/tests/test_cases/std_cisco_nxos_switched/expected_qos.cfg @@ -0,0 +1,37 @@ +! qos.j2 + +policy-map type network-qos AZLOCAL-NWQOS + class type network-qos AZLOCAL-NWQOS-RDMA + pause pfc-cos 3 + mtu 9216 + class type network-qos AZLOCAL-NWQOS-DEFAULT + mtu 9216 + class type network-qos AZLOCAL-NWQOS-CLUSTER + mtu 9216 + + +class-map type qos match-all AZLOCAL-QOS-RDMA + match cos 3 +class-map type qos match-all AZLOCAL-QOS-CLUSTER + match cos 7 + +policy-map type qos AZLOCAL-QOS-MAP + class AZLOCAL-QOS-RDMA + set qos-group 3 + class AZLOCAL-QOS-CLUSTER + set qos-group 7 + + +policy-map type queuing AZLOCAL-QUEUE-OUT + class type queuing c-out-8q-q3 + bandwidth remaining percent 50 + random-detect minimum-threshold 300 kbytes maximum-threshold 300 kbytes drop-probability 100 weight 0 ecn + class type queuing c-out-8q-q-default + bandwidth remaining percent 48 + class type queuing c-out-8q-q7 + bandwidth percent 2 + + +system qos + service-policy type network-qos AZLOCAL-NWQOS + service-policy type queuing output AZLOCAL-QUEUE-OUT \ No newline at end of file diff --git a/tests/test_cases/std_cisco_nxos_switched/expected_system.cfg b/tests/test_cases/std_cisco_nxos_switched/expected_system.cfg new file mode 100644 index 0000000..37cade1 --- /dev/null +++ b/tests/test_cases/std_cisco_nxos_switched/expected_system.cfg @@ -0,0 +1,74 @@ +! system.j2 + +! Name: s46-r21-93180hl-24-1a +! Make: cisco +! Model: 93180yc-fx +hostname s46-r21-93180hl-24-1a + +banner motd # +NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE + +hostname s46-r21-93180hl-24-1a +Unauthorized access and/or use prohibited. +All access and/or use subject to monitoring. + +NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE +# + + +no feature telnet +feature scp-server +feature bgp +feature interface-vlan +feature lldp +feature dhcp +feature vpc +feature hsrp +feature lacp +feature ssh +feature tacacs+ + + +clock timezone PST -8 0 +clock summer-time PDT 2 Sun Apr 02:00 1 Sun Nov 02:00 60 +ntp server [NTP_SERVER_IP] +ntp source-interface [MGMT_VLAN] + + +logging server [LOG_SERVER_IP] 7 facility local7 use-vrf default +logging source-interface [MGMT_VLAN] +logging level local7 7 +no logging console +login on-success log +logging origin-id hostname + +logging level acllog 7 +logging level aclmgr 7 +logging level eth_port_channel 7 +logging level hsrp 7 +logging level icam 7 +logging level interface-vlan 7 +logging level ipqosmgr 7 +logging level vlan_mgr 7 +logging level vpc 7 +logging level netstack 7 +logging level bgp 7 + + +no cdp enable +lldp tlv-select dcbxp egress-queuing + +service dhcp +ip dhcp relay + +ip load-sharing address source-destination port source-destination + +ip icmp-errors source-interface [MGMT_VLAN] + +cli alias name wr copy running-config startup-config + + +snmp-server community [PLACEHOLDER] ro +snmp-server community [PLACEHOLDER] rW +snmp-server contact "Contact Support" +snmp-server location \ No newline at end of file diff --git a/tests/test_cases/std_cisco_nxos_switched/expected_vlan.cfg b/tests/test_cases/std_cisco_nxos_switched/expected_vlan.cfg new file mode 100644 index 0000000..3458aba --- /dev/null +++ b/tests/test_cases/std_cisco_nxos_switched/expected_vlan.cfg @@ -0,0 +1,346 @@ +! vlan.j2 + +vlan 2 + name UNUSED_VLAN + shutdown +vlan 6 + name HNVPA_6 + +vlan 7 + name Infra_7 + +vlan 99 + name NativeVlan + +vlan 125 + name BMC_Mgmt_125 + +vlan 201 + name Tenant_201 + +vlan 301 + name LogicalTenant_301 + +vlan 401 + name DhcpTenant_401 + +vlan 501 + name L3forward_501 + +vlan 502 + name L3forward_502 + +vlan 503 + name L3forward_503 + +vlan 504 + name L3forward_504 + +vlan 505 + name L3forward_505 + +vlan 506 + name L3forward_506 + +vlan 507 + name L3forward_507 + +vlan 508 + name L3forward_508 + +vlan 509 + name L3forward_509 + +vlan 510 + name L3forward_510 + +vlan 511 + name L3forward_511 + +vlan 512 + name L3forward_512 + +vlan 513 + name L3forward_513 + +vlan 514 + name L3forward_514 + +vlan 515 + name L3forward_515 + +vlan 516 + name L3forward_516 + +vlan 711 + name Storage_711_TOR1 + +vlan 712 + name Storage_712_TOR2 + + + +interface vlan6 + description HNVPA_6 + mtu 9216 + no shutdown + ip address 100.71.131.2/25 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 6 + priority 150 + ip 100.71.131.1 + +interface vlan7 + description Infra_7 + mtu 9216 + no shutdown + ip address 100.69.176.2/24 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 7 + priority 150 + ip 100.69.176.1 + +interface vlan125 + description BMC_Mgmt_125 + mtu 9216 + no shutdown + ip address 100.71.85.123/26 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 125 + priority 150 + ip 100.71.85.65 + +interface vlan201 + description Tenant_201 + mtu 9216 + no shutdown + ip address 100.69.177.2/24 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 201 + priority 150 + ip 100.69.177.1 + +interface vlan301 + description LogicalTenant_301 + mtu 9216 + no shutdown + ip address 100.69.178.2/25 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 301 + priority 150 + ip 100.69.178.1 + +interface vlan401 + description DhcpTenant_401 + mtu 9216 + no shutdown + ip address 100.69.178.130/25 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 401 + priority 150 + ip 100.69.178.129 + +interface vlan501 + description L3forward_501 + mtu 9216 + no shutdown + ip address 100.69.179.2/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 501 + priority 150 + ip 100.69.179.1 + +interface vlan502 + description L3forward_502 + mtu 9216 + no shutdown + ip address 100.69.179.18/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 502 + priority 150 + ip 100.69.179.17 + +interface vlan503 + description L3forward_503 + mtu 9216 + no shutdown + ip address 100.69.179.34/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 503 + priority 150 + ip 100.69.179.33 + +interface vlan504 + description L3forward_504 + mtu 9216 + no shutdown + ip address 100.69.179.50/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 504 + priority 150 + ip 100.69.179.49 + +interface vlan505 + description L3forward_505 + mtu 9216 + no shutdown + ip address 100.69.179.66/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 505 + priority 150 + ip 100.69.179.65 + +interface vlan506 + description L3forward_506 + mtu 9216 + no shutdown + ip address 100.69.179.82/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 506 + priority 150 + ip 100.69.179.81 + +interface vlan507 + description L3forward_507 + mtu 9216 + no shutdown + ip address 100.69.179.98/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 507 + priority 150 + ip 100.69.179.97 + +interface vlan508 + description L3forward_508 + mtu 9216 + no shutdown + ip address 100.69.179.114/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 508 + priority 150 + ip 100.69.179.113 + +interface vlan509 + description L3forward_509 + mtu 9216 + no shutdown + ip address 100.69.179.130/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 509 + priority 150 + ip 100.69.179.129 + +interface vlan510 + description L3forward_510 + mtu 9216 + no shutdown + ip address 100.69.179.145/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 510 + priority 150 + ip + +interface vlan511 + description L3forward_511 + mtu 9216 + no shutdown + ip address 100.69.179.162/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 511 + priority 150 + ip 100.69.179.161 + +interface vlan512 + description L3forward_512 + mtu 9216 + no shutdown + ip address 100.69.179.178/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 512 + priority 150 + ip 100.69.179.177 + +interface vlan513 + description L3forward_513 + mtu 9216 + no shutdown + ip address 100.69.179.194/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 513 + priority 150 + ip 100.69.179.193 + +interface vlan514 + description L3forward_514 + mtu 9216 + no shutdown + ip address 100.69.179.210/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 514 + priority 150 + ip 100.69.179.209 + +interface vlan515 + description L3forward_515 + mtu 9216 + no shutdown + ip address 100.69.179.226/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 515 + priority 150 + ip 100.69.179.225 + +interface vlan516 + description L3forward_516 + mtu 9216 + no shutdown + ip address 100.69.179.242/28 + no ip redirects + no ipv6 redirects + hsrp version 2 + hsrp 516 + priority 150 + ip 100.69.179.241 + diff --git a/tests/test_cases/std_dell_os10_fc/expected_bgp.cfg b/tests/test_cases/std_dell_os10_fc/expected_bgp.cfg new file mode 100644 index 0000000..42ce0ca --- /dev/null +++ b/tests/test_cases/std_dell_os10_fc/expected_bgp.cfg @@ -0,0 +1,64 @@ +! bgp.j2 + +router bgp 64556 + router-id 100.71.12.21 + bestpath as-path multipath-relax + log-neighbor-changes + maximum-paths ibgp 8 + maximum-paths ebgp 8 + address-family ipv4 unicast + network 100.71.12.2/30 + network 100.71.12.10/30 + network 100.71.12.21/32 + network 100.68.149.0/24 + network 100.68.150.0/25 + network 100.68.150.128/25 + network 100.68.151.0/28 + network 100.68.151.16/28 + network 100.68.151.32/28 + network 100.68.151.48/28 + network 100.68.151.64/28 + network 100.68.151.80/28 + network 100.68.151.96/28 + network 100.68.151.112/28 + network 100.68.151.128/28 + network 100.68.151.144/28 + network 100.68.151.160/28 + network 100.68.151.176/28 + network 100.68.151.192/28 + network 100.68.151.208/28 + network 100.68.151.224/28 + network 100.68.151.240/28 + + neighbor 100.71.12.1 + description TO_Border1 + remote-as 64846 + no shutdown + address-family ipv4 unicast + activate + prefix-list DefaultRoute in + next-hop-self + + neighbor 100.71.12.9 + description TO_Border2 + remote-as 64846 + no shutdown + address-family ipv4 unicast + activate + prefix-list DefaultRoute in + next-hop-self + + neighbor 100.71.12.18 + description iBGP_PEER + remote-as 64556 + no shutdown + address-family ipv4 unicast + activate + next-hop-self + + template TO_TO_HNVPA + ebgp-multihop 3 + listen 100.71.143.0/25 limit 5 + remote-as 65018 + update-source Loopback0 + diff --git a/tests/test_cases/std_dell_os10_fc/expected_full_config.cfg b/tests/test_cases/std_dell_os10_fc/expected_full_config.cfg new file mode 100644 index 0000000..5c6f3fc --- /dev/null +++ b/tests/test_cases/std_dell_os10_fc/expected_full_config.cfg @@ -0,0 +1,584 @@ +! system.j2 - hostname +! Name: s46-r06-5248hl-6-1a +! Make: dellemc +! Model: s5248f-on +hostname s46-r06-5248hl-6-1a + +banner motd # +NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE + +hostname s46-r06-5248hl-6-1a +Unauthorized access and/or use prohibited. +All access and/or use subject to monitoring. + +NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE +# + + +! system.j2 - features +lldp enable +dcbx enable + + +! system.j2 - ntp +clock timezone standard-timezone America/Los_Angeles +ntp server [NTP_SERVER_IP] +ntp source [MGMT_VLAN] + + +! system.j2 - syslog +logging server [LOG_SERVER_IP] +logging source-interface [MGMT_VLAN] +logging source-interface vlan125 +logging audit enable +logging console disable + + +! system.j2 - global_settings +ztd cancel +mac address-table aging-time 1000000 + +no ip dhcp-relay information-option +no ip dhcp snooping + + +vrrp version 3 +vrrp delay reload 180 + + +! system.j2 - snmp_settings +snmp-server community [SNMP_COMMUNITY_RO] ro +snmp-server community [SNMP_COMMUNITY_RW] rw +snmp-server contact "Contact Support" +snmp-server location + + +! system.j2 - management_vrf +ip vrf management + interface management + +management route 0.0.0.0/0 [MGMT_GATEWAY_IP] + +! login.j2 + +password-attributes character-restriction upper 1 lower 1 numeric 1 special-char 1 min-length 15 lockout-period 15 max-retry 3 +password-attributes lockout-period 5 + + +enable password 0 $CREDENTIAL_PLACEHOLDER$ priv-lvl 15 +username admin password $CREDENTIAL_PLACEHOLDER$ role sysadmin +username $CREDENTIAL_PLACEHOLDER$ password $CREDENTIAL_PLACEHOLDER$ role sysadmin + + +ip ssh server enable +ip ssh server cipher aes256-ctr aes192-ctr aes128-ctr +ip ssh server mac hmac-sha1 hmac-sha2-256 +ip ssh server max-auth-tries 3 +no ip telnet server enable + + +login concurrent-session limit 3 +login statistics enable + + +! Replace [TACACS_SERVER1], [TACACS_SERVER2], [TACACS_KEY], and [MGMT_VLAN] with actual values. +ip tacacs source-interface [MGMT_VLAN] +tacacs-server host [TACACS_SERVER1] key [TACACS_KEY] +tacacs-server host [TACACS_SERVER2] key [TACACS_KEY] + +aaa authentication login default group tacacs+ +aaa authentication login console group tacacs+ local +aaa accounting commands all default start-stop group tacacs+ + +! qos.j2 + +wred ecn + random-detect color green minimum-threshold 150 maximum-threshold 1500 drop-probability 100 + random-detect ecn + + +class-map type network-qos AZLOCAL_COS3 + match qos-group 3 + +class-map type network-qos AZLOCAL_COS7 + match qos-group 7 + + +class-map type queuing AZLOCAL_QUEUE0 + match queue 0 + +class-map type queuing AZLOCAL_QUEUE3 + match queue 3 + +class-map type queuing AZLOCAL_QUEUE7 + match queue 7 + + +trust dot1p-map AZLOCAL_DOT1P_TRUST + qos-group 0 dot1p 0-2,4-6 + qos-group 3 dot1p 3 + qos-group 7 dot1p 7 + + +qos-map traffic-class AZLOCAL_QOS_MAP + queue 0 qos-group 0-2,4-6 + queue 3 qos-group 3 + queue 7 qos-group 7 + + +policy-map type network-qos AZLOCAL_PFC + class AZLOCAL_COS3 + pause + pfc-cos 3 + + +policy-map type queuing AZLOCAL_ETS + class AZLOCAL_QUEUE0 + bandwidth percent 48 + + class AZLOCAL_QUEUE3 + bandwidth percent 50 + random-detect ecn + + class AZLOCAL_QUEUE7 + bandwidth percent 2 + + +system qos + trust-map dot1p AZLOCAL_DOT1P_TRUST + ets mode on + +! vlan.j2 +interface vlan2 + description UNUSED_VLAN + shutdown +interface vlan6 + description HNVPA_6 + mtu 9216 + no shutdown + ip address 100.71.143.2/25 + vrrp-group 6 + priority 150 + virtual-address 100.71.143.1 + no preempt +interface vlan7 + description Infra_7 + mtu 9216 + no shutdown + ip address 100.68.148.2/24 + vrrp-group 7 + priority 150 + virtual-address 100.68.148.1 + no preempt +interface vlan99 + description NativeVlan + no shutdown +interface vlan125 + description BMC_Mgmt_125 + mtu 9216 + no shutdown + ip address 100.71.12.123/26 + vrrp-group 125 + priority 150 + virtual-address 100.71.12.65 + no preempt +interface vlan201 + description Tenant_201 + mtu 9216 + no shutdown + ip address 100.68.149.2/24 + vrrp-group 201 + priority 150 + virtual-address 100.68.149.1 + no preempt +interface vlan301 + description LogicalTenant_301 + mtu 9216 + no shutdown + ip address 100.68.150.2/25 + vrrp-group 301 + priority 150 + virtual-address 100.68.150.1 + no preempt +interface vlan401 + description DhcpTenant_401 + mtu 9216 + no shutdown + ip address 100.68.150.130/25 + vrrp-group 401 + priority 150 + virtual-address 100.68.150.129 + no preempt +interface vlan501 + description L3forward_501 + mtu 9216 + no shutdown + ip address 100.68.151.2/28 + vrrp-group 501 + priority 150 + virtual-address 100.68.151.1 + no preempt +interface vlan502 + description L3forward_502 + mtu 9216 + no shutdown + ip address 100.68.151.18/28 + vrrp-group 502 + priority 150 + virtual-address 100.68.151.17 + no preempt +interface vlan503 + description L3forward_503 + mtu 9216 + no shutdown + ip address 100.68.151.34/28 + vrrp-group 503 + priority 150 + virtual-address 100.68.151.33 + no preempt +interface vlan504 + description L3forward_504 + mtu 9216 + no shutdown + ip address 100.68.151.50/28 + vrrp-group 504 + priority 150 + virtual-address 100.68.151.49 + no preempt +interface vlan505 + description L3forward_505 + mtu 9216 + no shutdown + ip address 100.68.151.66/28 + vrrp-group 505 + priority 150 + virtual-address 100.68.151.65 + no preempt +interface vlan506 + description L3forward_506 + mtu 9216 + no shutdown + ip address 100.68.151.82/28 + vrrp-group 506 + priority 150 + virtual-address 100.68.151.81 + no preempt +interface vlan507 + description L3forward_507 + mtu 9216 + no shutdown + ip address 100.68.151.98/28 + vrrp-group 507 + priority 150 + virtual-address 100.68.151.97 + no preempt +interface vlan508 + description L3forward_508 + mtu 9216 + no shutdown + ip address 100.68.151.114/28 + vrrp-group 508 + priority 150 + virtual-address 100.68.151.113 + no preempt +interface vlan509 + description L3forward_509 + mtu 9216 + no shutdown + ip address 100.68.151.130/28 + vrrp-group 509 + priority 150 + virtual-address 100.68.151.129 + no preempt +interface vlan510 + description L3forward_510 + mtu 9216 + no shutdown + ip address 100.68.151.145/28 + vrrp-group 510 + priority 150 + virtual-address 10.69.179.145 + no preempt +interface vlan511 + description L3forward_511 + mtu 9216 + no shutdown + ip address 100.68.151.162/28 + vrrp-group 511 + priority 150 + virtual-address 100.68.151.161 + no preempt +interface vlan512 + description L3forward_512 + mtu 9216 + no shutdown + ip address 100.68.151.178/28 + vrrp-group 512 + priority 150 + virtual-address 100.68.151.177 + no preempt +interface vlan513 + description L3forward_513 + mtu 9216 + no shutdown + ip address 100.68.151.194/28 + vrrp-group 513 + priority 150 + virtual-address 100.68.151.193 + no preempt +interface vlan514 + description L3forward_514 + mtu 9216 + no shutdown + ip address 100.68.151.210/28 + vrrp-group 514 + priority 150 + virtual-address 100.68.151.209 + no preempt +interface vlan515 + description L3forward_515 + mtu 9216 + no shutdown + ip address 100.68.151.226/28 + vrrp-group 515 + priority 150 + virtual-address 100.68.151.225 + no preempt +interface vlan516 + description L3forward_516 + mtu 9216 + no shutdown + ip address 100.68.151.242/28 + vrrp-group 516 + priority 150 + virtual-address 100.68.151.241 + no preempt +interface vlan711 + description Storage_711_TOR1 + no shutdown +interface vlan712 + description Storage_711_TOR2 + no shutdown + +! interface.j2 - dell + +! NOTE: This interface configuration initializes ports in shutdown state for security. +! This is a recommended best practice to prevent unauthorized access on unused ports. +! User may choose to apply this initial configuration or customize based on deployment requirements. +interface range Ethernet 1/1/1-1/1/56 + description Unused + switchport mode access + switchport access vlan 2 + spanning-tree bpduguard enable + spanning-tree guard root + spanning-tree port type edge + mtu 9216 + shutdown + + +interface Ethernet 1/1/44 + description Trunk_TO_BMC_SWITCH + switchport mode trunk + switchport access vlan 99 + switchport trunk allowed vlan 125 + mtu 9216 + no shutdown + +interface range Ethernet 1/1/1-1/1/18 + description HyperConverged_To_Host + switchport mode trunk + switchport access vlan 7 + switchport trunk allowed vlan 7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,711 + mtu 9216 + service-policy input type network-qos AZLOCAL-QOS-MAP + no shutdown + + + +interface Ethernet 1/1/48 + description P2P_Border1 + no switchport + ip address 100.71.12.2/30 + mtu 9216 + no shutdown + +interface Ethernet 1/1/47 + description P2P_Border2 + no switchport + ip address 100.71.12.10/30 + mtu 9216 + no shutdown + + +interface loopbackloopback0 + description Loopback0 + ip address 100.71.12.21/32 + mtu 9216 + no shutdown + + + +! port-channel.j2 + +interface port-channel50 + description P2P_IBGP + no shutdown + no switchport + mtu 9216 + ip address 100.71.12.17/30 + + +interface Ethernet 1/1/39 + description P2P_IBGP + no shutdown + channel-group 50 mode active + no switchport + mtu 9216 + flowcontrol receive off + +interface Ethernet 1/1/40 + description P2P_IBGP + no shutdown + channel-group 50 mode active + no switchport + mtu 9216 + flowcontrol receive off + + +interface port-channel101 + description ToR_Peer_Link + no shutdown + switchport mode trunk + switchport access vlan 99 + switchport trunk allowed vlan + vlt-port-channel 101 + priority-flow-control mode on + mtu 9216 + + +interface Ethernet 1/1/49 + description ToR_Peer_Link + no shutdown + channel-group 101 mode active + + switchport + switchport mode trunk + switchport trunk native vlan 99 + switchport trunk allowed vlan + spanning-tree port type network + mtu 9216 + flowcontrol receive off + +interface Ethernet 1/1/50 + description ToR_Peer_Link + no shutdown + channel-group 101 mode active + + switchport + switchport mode trunk + switchport trunk native vlan 99 + switchport trunk allowed vlan + spanning-tree port type network + mtu 9216 + flowcontrol receive off + +interface Ethernet 1/1/51 + description ToR_Peer_Link + no shutdown + channel-group 101 mode active + + switchport + switchport mode trunk + switchport trunk native vlan 99 + switchport trunk allowed vlan + spanning-tree port type network + mtu 9216 + flowcontrol receive off + +interface Ethernet 1/1/52 + description ToR_Peer_Link + no shutdown + channel-group 101 mode active + + switchport + switchport mode trunk + switchport trunk native vlan 99 + switchport trunk allowed vlan + spanning-tree port type network + mtu 9216 + flowcontrol receive off + + +! vlt.j2 - NOTICE: VLT configuration skipped - MLAG peer link interface not found + +! prefix_list.j2 + +ip prefix-list DefaultRoute seq 10 permit 0.0.0.0/0 +ip prefix-list DefaultRoute seq 50 deny 0.0.0.0/0 le 32 + +! bgp.j2 + +router bgp 64556 + router-id 100.71.12.21 + bestpath as-path multipath-relax + log-neighbor-changes + maximum-paths ibgp 8 + maximum-paths ebgp 8 + address-family ipv4 unicast + network 100.71.12.2/30 + network 100.71.12.10/30 + network 100.71.12.21/32 + network 100.68.149.0/24 + network 100.68.150.0/25 + network 100.68.150.128/25 + network 100.68.151.0/28 + network 100.68.151.16/28 + network 100.68.151.32/28 + network 100.68.151.48/28 + network 100.68.151.64/28 + network 100.68.151.80/28 + network 100.68.151.96/28 + network 100.68.151.112/28 + network 100.68.151.128/28 + network 100.68.151.144/28 + network 100.68.151.160/28 + network 100.68.151.176/28 + network 100.68.151.192/28 + network 100.68.151.208/28 + network 100.68.151.224/28 + network 100.68.151.240/28 + + neighbor 100.71.12.1 + description TO_Border1 + remote-as 64846 + no shutdown + address-family ipv4 unicast + activate + prefix-list DefaultRoute in + next-hop-self + + neighbor 100.71.12.9 + description TO_Border2 + remote-as 64846 + no shutdown + address-family ipv4 unicast + activate + prefix-list DefaultRoute in + next-hop-self + + neighbor 100.71.12.18 + description iBGP_PEER + remote-as 64556 + no shutdown + address-family ipv4 unicast + activate + next-hop-self + + template TO_TO_HNVPA + ebgp-multihop 3 + listen 100.71.143.0/25 limit 5 + remote-as 65018 + update-source Loopback0 + + + diff --git a/tests/test_cases/std_dell_os10_fc/expected_interface.cfg b/tests/test_cases/std_dell_os10_fc/expected_interface.cfg new file mode 100644 index 0000000..128d2e4 --- /dev/null +++ b/tests/test_cases/std_dell_os10_fc/expected_interface.cfg @@ -0,0 +1,56 @@ +! interface.j2 - dell + +! NOTE: This interface configuration initializes ports in shutdown state for security. +! This is a recommended best practice to prevent unauthorized access on unused ports. +! User may choose to apply this initial configuration or customize based on deployment requirements. +interface range Ethernet 1/1/1-1/1/56 + description Unused + switchport mode access + switchport access vlan 2 + spanning-tree bpduguard enable + spanning-tree guard root + spanning-tree port type edge + mtu 9216 + shutdown + + +interface Ethernet 1/1/44 + description Trunk_TO_BMC_SWITCH + switchport mode trunk + switchport access vlan 99 + switchport trunk allowed vlan 125 + mtu 9216 + no shutdown + +interface range Ethernet 1/1/1-1/1/18 + description HyperConverged_To_Host + switchport mode trunk + switchport access vlan 7 + switchport trunk allowed vlan 7,6,201,301,401,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,711 + mtu 9216 + service-policy input type network-qos AZLOCAL-QOS-MAP + no shutdown + + + +interface Ethernet 1/1/48 + description P2P_Border1 + no switchport + ip address 100.71.12.2/30 + mtu 9216 + no shutdown + +interface Ethernet 1/1/47 + description P2P_Border2 + no switchport + ip address 100.71.12.10/30 + mtu 9216 + no shutdown + + +interface loopbackloopback0 + description Loopback0 + ip address 100.71.12.21/32 + mtu 9216 + no shutdown + diff --git a/tests/test_cases/std_dell_os10_fc/expected_login.cfg b/tests/test_cases/std_dell_os10_fc/expected_login.cfg new file mode 100644 index 0000000..49b237f --- /dev/null +++ b/tests/test_cases/std_dell_os10_fc/expected_login.cfg @@ -0,0 +1,30 @@ +! login.j2 + +password-attributes character-restriction upper 1 lower 1 numeric 1 special-char 1 min-length 15 lockout-period 15 max-retry 3 +password-attributes lockout-period 5 + + +enable password 0 $CREDENTIAL_PLACEHOLDER$ priv-lvl 15 +username admin password $CREDENTIAL_PLACEHOLDER$ role sysadmin +username $CREDENTIAL_PLACEHOLDER$ password $CREDENTIAL_PLACEHOLDER$ role sysadmin + + +ip ssh server enable +ip ssh server cipher aes256-ctr aes192-ctr aes128-ctr +ip ssh server mac hmac-sha1 hmac-sha2-256 +ip ssh server max-auth-tries 3 +no ip telnet server enable + + +login concurrent-session limit 3 +login statistics enable + + +! Replace [TACACS_SERVER1], [TACACS_SERVER2], [TACACS_KEY], and [MGMT_VLAN] with actual values. +ip tacacs source-interface [MGMT_VLAN] +tacacs-server host [TACACS_SERVER1] key [TACACS_KEY] +tacacs-server host [TACACS_SERVER2] key [TACACS_KEY] + +aaa authentication login default group tacacs+ +aaa authentication login console group tacacs+ local +aaa accounting commands all default start-stop group tacacs+ \ No newline at end of file diff --git a/tests/test_cases/std_dell_os10_fc/expected_port_channel.cfg b/tests/test_cases/std_dell_os10_fc/expected_port_channel.cfg new file mode 100644 index 0000000..b6f0ae2 --- /dev/null +++ b/tests/test_cases/std_dell_os10_fc/expected_port_channel.cfg @@ -0,0 +1,90 @@ +! port-channel.j2 + +interface port-channel50 + description P2P_IBGP + no shutdown + no switchport + mtu 9216 + ip address 100.71.12.17/30 + + +interface Ethernet 1/1/39 + description P2P_IBGP + no shutdown + channel-group 50 mode active + no switchport + mtu 9216 + flowcontrol receive off + +interface Ethernet 1/1/40 + description P2P_IBGP + no shutdown + channel-group 50 mode active + no switchport + mtu 9216 + flowcontrol receive off + + +interface port-channel101 + description ToR_Peer_Link + no shutdown + switchport mode trunk + switchport access vlan 99 + switchport trunk allowed vlan + vlt-port-channel 101 + priority-flow-control mode on + mtu 9216 + + +interface Ethernet 1/1/49 + description ToR_Peer_Link + no shutdown + channel-group 101 mode active + + switchport + switchport mode trunk + switchport trunk native vlan 99 + switchport trunk allowed vlan + spanning-tree port type network + mtu 9216 + flowcontrol receive off + +interface Ethernet 1/1/50 + description ToR_Peer_Link + no shutdown + channel-group 101 mode active + + switchport + switchport mode trunk + switchport trunk native vlan 99 + switchport trunk allowed vlan + spanning-tree port type network + mtu 9216 + flowcontrol receive off + +interface Ethernet 1/1/51 + description ToR_Peer_Link + no shutdown + channel-group 101 mode active + + switchport + switchport mode trunk + switchport trunk native vlan 99 + switchport trunk allowed vlan + spanning-tree port type network + mtu 9216 + flowcontrol receive off + +interface Ethernet 1/1/52 + description ToR_Peer_Link + no shutdown + channel-group 101 mode active + + switchport + switchport mode trunk + switchport trunk native vlan 99 + switchport trunk allowed vlan + spanning-tree port type network + mtu 9216 + flowcontrol receive off + \ No newline at end of file diff --git a/tests/test_cases/std_dell_os10_fc/expected_prefix_list.cfg b/tests/test_cases/std_dell_os10_fc/expected_prefix_list.cfg new file mode 100644 index 0000000..c9f76e9 --- /dev/null +++ b/tests/test_cases/std_dell_os10_fc/expected_prefix_list.cfg @@ -0,0 +1,4 @@ +! prefix_list.j2 + +ip prefix-list DefaultRoute seq 10 permit 0.0.0.0/0 +ip prefix-list DefaultRoute seq 50 deny 0.0.0.0/0 le 32 \ No newline at end of file diff --git a/tests/test_cases/std_dell_os10_fc/expected_qos.cfg b/tests/test_cases/std_dell_os10_fc/expected_qos.cfg new file mode 100644 index 0000000..0730bb6 --- /dev/null +++ b/tests/test_cases/std_dell_os10_fc/expected_qos.cfg @@ -0,0 +1,57 @@ +! qos.j2 + +wred ecn + random-detect color green minimum-threshold 150 maximum-threshold 1500 drop-probability 100 + random-detect ecn + + +class-map type network-qos AZLOCAL_COS3 + match qos-group 3 + +class-map type network-qos AZLOCAL_COS7 + match qos-group 7 + + +class-map type queuing AZLOCAL_QUEUE0 + match queue 0 + +class-map type queuing AZLOCAL_QUEUE3 + match queue 3 + +class-map type queuing AZLOCAL_QUEUE7 + match queue 7 + + +trust dot1p-map AZLOCAL_DOT1P_TRUST + qos-group 0 dot1p 0-2,4-6 + qos-group 3 dot1p 3 + qos-group 7 dot1p 7 + + +qos-map traffic-class AZLOCAL_QOS_MAP + queue 0 qos-group 0-2,4-6 + queue 3 qos-group 3 + queue 7 qos-group 7 + + +policy-map type network-qos AZLOCAL_PFC + class AZLOCAL_COS3 + pause + pfc-cos 3 + + +policy-map type queuing AZLOCAL_ETS + class AZLOCAL_QUEUE0 + bandwidth percent 48 + + class AZLOCAL_QUEUE3 + bandwidth percent 50 + random-detect ecn + + class AZLOCAL_QUEUE7 + bandwidth percent 2 + + +system qos + trust-map dot1p AZLOCAL_DOT1P_TRUST + ets mode on \ No newline at end of file diff --git a/tests/test_cases/std_dell_os10_fc/expected_system.cfg b/tests/test_cases/std_dell_os10_fc/expected_system.cfg new file mode 100644 index 0000000..681fafe --- /dev/null +++ b/tests/test_cases/std_dell_os10_fc/expected_system.cfg @@ -0,0 +1,60 @@ +! system.j2 - hostname +! Name: s46-r06-5248hl-6-1a +! Make: dellemc +! Model: s5248f-on +hostname s46-r06-5248hl-6-1a + +banner motd # +NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE + +hostname s46-r06-5248hl-6-1a +Unauthorized access and/or use prohibited. +All access and/or use subject to monitoring. + +NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE +# + + +! system.j2 - features +lldp enable +dcbx enable + + +! system.j2 - ntp +clock timezone standard-timezone America/Los_Angeles +ntp server [NTP_SERVER_IP] +ntp source [MGMT_VLAN] + + +! system.j2 - syslog +logging server [LOG_SERVER_IP] +logging source-interface [MGMT_VLAN] +logging source-interface vlan125 +logging audit enable +logging console disable + + +! system.j2 - global_settings +ztd cancel +mac address-table aging-time 1000000 + +no ip dhcp-relay information-option +no ip dhcp snooping + + +vrrp version 3 +vrrp delay reload 180 + + +! system.j2 - snmp_settings +snmp-server community [SNMP_COMMUNITY_RO] ro +snmp-server community [SNMP_COMMUNITY_RW] rw +snmp-server contact "Contact Support" +snmp-server location + + +! system.j2 - management_vrf +ip vrf management + interface management + +management route 0.0.0.0/0 [MGMT_GATEWAY_IP] \ No newline at end of file diff --git a/tests/test_cases/std_dell_os10_fc/expected_vlan.cfg b/tests/test_cases/std_dell_os10_fc/expected_vlan.cfg new file mode 100644 index 0000000..bd54e29 --- /dev/null +++ b/tests/test_cases/std_dell_os10_fc/expected_vlan.cfg @@ -0,0 +1,211 @@ +! vlan.j2 +interface vlan2 + description UNUSED_VLAN + shutdown +interface vlan6 + description HNVPA_6 + mtu 9216 + no shutdown + ip address 100.71.143.2/25 + vrrp-group 6 + priority 150 + virtual-address 100.71.143.1 + no preempt +interface vlan7 + description Infra_7 + mtu 9216 + no shutdown + ip address 100.68.148.2/24 + vrrp-group 7 + priority 150 + virtual-address 100.68.148.1 + no preempt +interface vlan99 + description NativeVlan + no shutdown +interface vlan125 + description BMC_Mgmt_125 + mtu 9216 + no shutdown + ip address 100.71.12.123/26 + vrrp-group 125 + priority 150 + virtual-address 100.71.12.65 + no preempt +interface vlan201 + description Tenant_201 + mtu 9216 + no shutdown + ip address 100.68.149.2/24 + vrrp-group 201 + priority 150 + virtual-address 100.68.149.1 + no preempt +interface vlan301 + description LogicalTenant_301 + mtu 9216 + no shutdown + ip address 100.68.150.2/25 + vrrp-group 301 + priority 150 + virtual-address 100.68.150.1 + no preempt +interface vlan401 + description DhcpTenant_401 + mtu 9216 + no shutdown + ip address 100.68.150.130/25 + vrrp-group 401 + priority 150 + virtual-address 100.68.150.129 + no preempt +interface vlan501 + description L3forward_501 + mtu 9216 + no shutdown + ip address 100.68.151.2/28 + vrrp-group 501 + priority 150 + virtual-address 100.68.151.1 + no preempt +interface vlan502 + description L3forward_502 + mtu 9216 + no shutdown + ip address 100.68.151.18/28 + vrrp-group 502 + priority 150 + virtual-address 100.68.151.17 + no preempt +interface vlan503 + description L3forward_503 + mtu 9216 + no shutdown + ip address 100.68.151.34/28 + vrrp-group 503 + priority 150 + virtual-address 100.68.151.33 + no preempt +interface vlan504 + description L3forward_504 + mtu 9216 + no shutdown + ip address 100.68.151.50/28 + vrrp-group 504 + priority 150 + virtual-address 100.68.151.49 + no preempt +interface vlan505 + description L3forward_505 + mtu 9216 + no shutdown + ip address 100.68.151.66/28 + vrrp-group 505 + priority 150 + virtual-address 100.68.151.65 + no preempt +interface vlan506 + description L3forward_506 + mtu 9216 + no shutdown + ip address 100.68.151.82/28 + vrrp-group 506 + priority 150 + virtual-address 100.68.151.81 + no preempt +interface vlan507 + description L3forward_507 + mtu 9216 + no shutdown + ip address 100.68.151.98/28 + vrrp-group 507 + priority 150 + virtual-address 100.68.151.97 + no preempt +interface vlan508 + description L3forward_508 + mtu 9216 + no shutdown + ip address 100.68.151.114/28 + vrrp-group 508 + priority 150 + virtual-address 100.68.151.113 + no preempt +interface vlan509 + description L3forward_509 + mtu 9216 + no shutdown + ip address 100.68.151.130/28 + vrrp-group 509 + priority 150 + virtual-address 100.68.151.129 + no preempt +interface vlan510 + description L3forward_510 + mtu 9216 + no shutdown + ip address 100.68.151.145/28 + vrrp-group 510 + priority 150 + virtual-address 10.69.179.145 + no preempt +interface vlan511 + description L3forward_511 + mtu 9216 + no shutdown + ip address 100.68.151.162/28 + vrrp-group 511 + priority 150 + virtual-address 100.68.151.161 + no preempt +interface vlan512 + description L3forward_512 + mtu 9216 + no shutdown + ip address 100.68.151.178/28 + vrrp-group 512 + priority 150 + virtual-address 100.68.151.177 + no preempt +interface vlan513 + description L3forward_513 + mtu 9216 + no shutdown + ip address 100.68.151.194/28 + vrrp-group 513 + priority 150 + virtual-address 100.68.151.193 + no preempt +interface vlan514 + description L3forward_514 + mtu 9216 + no shutdown + ip address 100.68.151.210/28 + vrrp-group 514 + priority 150 + virtual-address 100.68.151.209 + no preempt +interface vlan515 + description L3forward_515 + mtu 9216 + no shutdown + ip address 100.68.151.226/28 + vrrp-group 515 + priority 150 + virtual-address 100.68.151.225 + no preempt +interface vlan516 + description L3forward_516 + mtu 9216 + no shutdown + ip address 100.68.151.242/28 + vrrp-group 516 + priority 150 + virtual-address 100.68.151.241 + no preempt +interface vlan711 + description Storage_711_TOR1 + no shutdown +interface vlan712 + description Storage_711_TOR2 + no shutdown \ No newline at end of file diff --git a/tests/test_cases/std_dell_os10_fc/expected_vlt.cfg b/tests/test_cases/std_dell_os10_fc/expected_vlt.cfg new file mode 100644 index 0000000..4f1c545 --- /dev/null +++ b/tests/test_cases/std_dell_os10_fc/expected_vlt.cfg @@ -0,0 +1 @@ +! vlt.j2 - NOTICE: VLT configuration skipped - MLAG peer link interface not found \ No newline at end of file diff --git a/tests/test_convertors.py b/tests/test_convertors.py index 15dbfa4..ddb17b0 100644 --- a/tests/test_convertors.py +++ b/tests/test_convertors.py @@ -3,6 +3,7 @@ import json import pytest import warnings +from collections import defaultdict # === Path setup === ROOT_DIR = Path(__file__).resolve().parent.parent @@ -18,8 +19,11 @@ from convertors import convert_lab_switches from loader import load_input_json +# === Test result tracking === +convertor_results = defaultdict(lambda: {"passed": 0, "skipped": 0, "failed": 0, "errors": []}) + # === Helper function for better diff reporting === -def find_json_differences(expected, actual, path=""): +def find_json_differences(expected, actual, path="", max_diff=10): """Find specific differences between two JSON structures.""" differences = [] @@ -29,7 +33,7 @@ def find_json_differences(expected, actual, path=""): if isinstance(expected, dict): all_keys = set(expected.keys()) | set(actual.keys()) - for key in all_keys: + for key in sorted(all_keys): current_path = f"{path}.{key}" if path else key if key not in expected: differences.append(f"Unexpected key at '{current_path}': {actual[key]}") @@ -37,6 +41,9 @@ def find_json_differences(expected, actual, path=""): differences.append(f"Missing key at '{current_path}'") else: differences.extend(find_json_differences(expected[key], actual[key], current_path)) + + if len(differences) >= max_diff: + break elif isinstance(expected, list): if len(expected) != len(actual): @@ -45,12 +52,57 @@ def find_json_differences(expected, actual, path=""): for i in range(min(len(expected), len(actual))): current_path = f"{path}[{i}]" if path else f"[{i}]" differences.extend(find_json_differences(expected[i], actual[i], current_path)) + + if len(differences) >= max_diff: + break else: if expected != actual: differences.append(f"Value mismatch at '{path}': expected '{expected}', got '{actual}'") - return differences + return differences[:max_diff] + + +def validate_json_structure(data, required_fields=None): + """Validate that JSON has expected structure.""" + errors = [] + + if not isinstance(data, dict): + errors.append(f"Expected dict, got {type(data).__name__}") + return errors + + if required_fields: + for field in required_fields: + if field not in data: + errors.append(f"Missing required field: '{field}'") + + return errors + + +def validate_lab_format(data): + """Validate that input JSON is in lab format.""" + required_keys = ["Version", "Description", "InputData"] + return validate_json_structure(data, required_keys) + + +def validate_standard_format(data): + """Validate that converted JSON is in standard format.""" + required_keys = ["switch"] + missing = [] + + for key in required_keys: + if key not in data: + missing.append(f"Missing required key: '{key}'") + + # Validate switch object has essential properties + if "switch" in data and isinstance(data["switch"], dict): + switch_required = ["make", "firmware"] + for key in switch_required: + if key not in data["switch"]: + missing.append(f"Missing in switch: '{key}'") + + return missing + # === Step 1: Find test folders with *_input.json === def find_input_cases(): @@ -77,6 +129,12 @@ def run_convert_and_compare(folder_name, input_file): input_data = load_input_json(input_file) assert input_data is not None, "Failed to load input JSON" + # Validate input format + format_errors = validate_lab_format(input_data) + if format_errors: + error_msg = f"Invalid lab format in {folder_name}:\n" + "\n".join(f" • {e}" for e in format_errors) + pytest.fail(error_msg, pytrace=False) + # Run convertor (writes JSON files into output_dir) # Suppress print output during testing import io, sys @@ -84,6 +142,11 @@ def run_convert_and_compare(folder_name, input_file): sys.stdout = io.StringIO() try: convert_lab_switches(input_data, output_dir) + except Exception as e: + sys.stdout = old_stdout + convertor_results[folder_name]["failed"] += 1 + convertor_results[folder_name]["errors"].append(str(e)) + pytest.fail(f"Convertor failed: {e}", pytrace=False) finally: sys.stdout = old_stdout @@ -91,13 +154,15 @@ def run_convert_and_compare(folder_name, input_file): generated_files = list(output_dir.glob("*.json")) if not generated_files: + convertor_results[folder_name]["skipped"] += 1 pytest.skip(f"No output files generated for {folder_name}") return compared_files = 0 missing_files = [] + format_issues = [] - for generated_file in generated_files: + for generated_file in sorted(generated_files): expected_file = expected_dir / generated_file.name if not expected_file.exists(): @@ -109,7 +174,12 @@ def run_convert_and_compare(folder_name, input_file): with open(generated_file, "r", encoding="utf-8") as f: generated_data = json.load(f) - # Better comparison with detailed error reporting + # Validate generated format + validation_errors = validate_standard_format(generated_data) + if validation_errors: + format_issues.extend([f"{generated_file.name}: {e}" for e in validation_errors]) + + # Content comparison if expected_data != generated_data: # Find and report specific differences differences = find_json_differences(expected_data, generated_data) @@ -121,29 +191,93 @@ def run_convert_and_compare(folder_name, input_file): # Print the error for immediate visibility, then fail print(error_msg) + convertor_results[folder_name]["failed"] += 1 + convertor_results[folder_name]["errors"].append(generated_file.name) pytest.fail(f"File comparison failed: {generated_file.name}", pytrace=False) compared_files += 1 + convertor_results[folder_name]["passed"] += 1 + + # Report format issues as warnings if content matched + if format_issues and compared_files > 0: + for issue in format_issues: + print(f"āš ļø {issue}") # Report results if compared_files == 0: if missing_files: skip_msg = f"All expected files missing: {', '.join(missing_files)}" print(f"ā­ļø {folder_name}: SKIPPED - {skip_msg}") + convertor_results[folder_name]["skipped"] += 1 pytest.skip(skip_msg) else: skip_msg = "No files to compare" print(f"ā­ļø {folder_name}: SKIPPED - {skip_msg}") + convertor_results[folder_name]["skipped"] += 1 pytest.skip(skip_msg) else: print(f"āœ… {folder_name}: {compared_files} file(s) verified") if missing_files: print(f"āš ļø {folder_name}: {len(missing_files)} expected file(s) missing: {', '.join(missing_files)}") + # === Step 3: Parametrize test for pytest === ALL_INPUT_CASES = find_input_cases() @pytest.mark.parametrize("input_case", ALL_INPUT_CASES, ids=lambda val: val[0]) def test_convert_switch_input_json(input_case): folder_name, input_file = input_case - run_convert_and_compare(folder_name, input_file) \ No newline at end of file + run_convert_and_compare(folder_name, input_file) + + +# === Additional validation tests === +@pytest.mark.parametrize("input_case", ALL_INPUT_CASES, ids=lambda val: f"input_format_{val[0]}") +def test_input_format_validation(input_case): + """Verify that input files conform to expected lab format.""" + folder_name, input_file = input_case + + input_data = load_input_json(input_file) + assert input_data is not None, f"Failed to load {input_file}" + + # Validate lab format structure + errors = validate_lab_format(input_data) + assert not errors, f"Format validation failed for {folder_name}:\n" + "\n".join(f" • {e}" for e in errors) + + +@pytest.mark.parametrize("input_case", ALL_INPUT_CASES, ids=lambda val: f"output_format_{val[0]}") +def test_output_format_validation(input_case): + """Verify that generated output conforms to standard format.""" + folder_name, input_file = input_case + folder_path = TEST_CASES_ROOT / folder_name + output_dir = folder_path / "generated_outputs" + + if not output_dir.exists() or not list(output_dir.glob("*.json")): + pytest.skip(f"No generated outputs for {folder_name}") + + # Validate each generated file + for output_file in output_dir.glob("*.json"): + with open(output_file, "r", encoding="utf-8") as f: + output_data = json.load(f) + + errors = validate_standard_format(output_data) + assert not errors, f"Format validation failed for {output_file.name}:\n" + "\n".join(f" • {e}" for e in errors) + + +def pytest_sessionfinish(session, exitstatus): + """Print final summary of convertor tests.""" + if convertor_results: + print(f"\nšŸ“Š Convertor Test Summary:") + total_passed = sum(r["passed"] for r in convertor_results.values()) + total_skipped = sum(r["skipped"] for r in convertor_results.values()) + total_failed = sum(r["failed"] for r in convertor_results.values()) + total_cases = len(convertor_results) + + print(f"šŸ“ˆ {total_cases} convertor cases: {total_passed} passed, {total_skipped} skipped, {total_failed} failed") + + if total_failed > 0: + print("\nāŒ Failed cases:") + for case_name, results in sorted(convertor_results.items()): + if results["failed"] > 0: + print(f" • {case_name}: {results['failed']} failure(s)") + for error in results["errors"][:3]: + print(f" - {error}") diff --git a/tests/test_generator.py b/tests/test_generator.py index 694593f..e8b95cb 100644 --- a/tests/test_generator.py +++ b/tests/test_generator.py @@ -3,6 +3,7 @@ import pytest import warnings from collections import defaultdict +import re # === Test result tracking === case_results = defaultdict(lambda: {"passed": 0, "skipped": 0, "failed": 0, "files": []}) @@ -35,13 +36,64 @@ def find_text_differences(expected, actual, max_lines=10): max_compare = min(len(expected_lines), len(actual_lines)) for i in range(max_compare): if expected_lines[i] != actual_lines[i]: - differences.append(f"Line {i+1}: expected '{expected_lines[i]}', got '{actual_lines[i]}'") + differences.append(f"Line {i+1}: expected '{expected_lines[i][:50]}...', got '{actual_lines[i][:50]}...'") if len(differences) >= max_lines: break return differences +def validate_config_syntax(content, file_type="cfg"): + """Validate configuration file syntax.""" + errors = [] + lines = content.split('\n') + + if file_type == "cfg": + # Basic validation for Cisco/Dell config files + bracket_stack = [] + for line_num, line in enumerate(lines, 1): + stripped = line.strip() + + # Skip comments and empty lines + if not stripped or stripped.startswith('!') or stripped.startswith('#'): + continue + + # Check for unbalanced brackets/braces + for char in stripped: + if char == '{': + bracket_stack.append('{') + elif char == '}': + if not bracket_stack or bracket_stack[-1] != '{': + errors.append(f"Line {line_num}: Unbalanced closing brace") + else: + bracket_stack.pop() + + if bracket_stack: + errors.append(f"Unclosed braces: {len(bracket_stack)} opening brace(s) without closing") + + # Check for common configuration errors + if 'interface' in content.lower(): + # Basic interface validation + interface_lines = [l for l in lines if 'interface' in l.lower()] + if interface_lines and len(interface_lines) < 2: + warnings.warn(f"Config may be incomplete: found {len(interface_lines)} interface definition(s)", UserWarning) + + return errors + + +def validate_generated_structure(output_folder): + """Validate that required output files were generated.""" + output_folder = Path(output_folder) + expected_file_types = [".cfg"] + generated_files = [] + + for file_type in expected_file_types: + generated_files.extend(output_folder.glob(f"*{file_type}")) + + return len(generated_files) > 0, len(generated_files) + + + # === Step 1: Find test folders with input === def find_input_cases(): input_cases = [] @@ -60,7 +112,7 @@ def find_input_cases(): return input_cases -# === Step 2: Generate configs using dynamic template selection === +# === Step 4: Render each template (compact single-line logging) === def generate_all_configs(input_case): folder_name, input_file = input_case folder_path = TEST_CASES_ROOT / folder_name @@ -96,8 +148,6 @@ def generate_all_configs(input_case): for output_file in sorted(output_folder.glob("generated_*.cfg")) ] - -# === Step 3: Discover all test pairs === def discover_test_cases(): all_cases = [] input_folders = find_input_cases() @@ -133,7 +183,19 @@ def test_generated_config_output(folder_name, case_name, generated_path, expecte generated = gen.read().strip() expected = exp.read().strip() - # Better comparison with detailed error reporting + # Validate syntax before comparison + syntax_errors = validate_config_syntax(generated, "cfg") + if syntax_errors: + case_results[folder_name]["failed"] += 1 + case_results[folder_name]["files"].append(f"āŒ {case_name} (syntax)") + error_msg = f"āŒ {test_name} - Syntax errors:\n" + for err in syntax_errors[:3]: + error_msg += f" • {err}\n" + print(error_msg) + show_case_summary_if_complete(folder_name) + pytest.fail(f"Config syntax validation failed", pytrace=False) + + # Content comparison if expected != generated: case_results[folder_name]["failed"] += 1 case_results[folder_name]["files"].append(f"āŒ {case_name}") @@ -175,12 +237,53 @@ def get_expected_file_count(folder_name): folder_path = TEST_CASES_ROOT / folder_name return len(list(folder_path.glob("generated_*.cfg"))) + +# === Additional validation tests === +@pytest.mark.parametrize("input_case", find_input_cases(), ids=lambda val: f"config_syntax_{val[0]}") +def test_config_syntax_validation(input_case): + """Verify that generated configuration files have valid syntax.""" + folder_name, input_file = input_case + folder_path = TEST_CASES_ROOT / folder_name + + # Generate configs + config_files = list(folder_path.glob("generated_*.cfg")) + + if not config_files: + pytest.skip(f"No generated configs for {folder_name}") + + # Validate syntax of each config + for config_file in config_files: + with open(config_file, "r", encoding="utf-8") as f: + content = f.read() + + errors = validate_config_syntax(content, "cfg") + assert not errors, f"Syntax errors in {config_file.name}:\n" + "\n".join(f" • {e}" for e in errors) + + +@pytest.mark.parametrize("input_case", find_input_cases(), ids=lambda val: f"output_generation_{val[0]}") +def test_output_file_generation(input_case): + """Verify that output files are generated correctly.""" + folder_name, input_file = input_case + folder_path = TEST_CASES_ROOT / folder_name + + has_output, file_count = validate_generated_structure(folder_path) + assert has_output, f"No output files generated for {folder_name}" + assert file_count > 0, f"Expected at least 1 output file, got {file_count}" + + def pytest_sessionfinish(session, exitstatus): """Print final summary""" if case_results: - print(f"\nšŸ“Š Final Summary:") + print(f"\nšŸ“Š Generator Test Summary:") total_passed = sum(r["passed"] for r in case_results.values()) total_skipped = sum(r["skipped"] for r in case_results.values()) total_failed = sum(r["failed"] for r in case_results.values()) total_cases = len(case_results) print(f"šŸ“ˆ {total_cases} test cases: {total_passed} passed, {total_skipped} skipped, {total_failed} failed") + + if total_failed > 0: + print("\nāŒ Failed tests:") + for folder_name, results in sorted(case_results.items()): + if results["failed"] > 0: + print(f" • {folder_name}: {results['failed']} failure(s)") +