├── .bandit.yml ├── .coveragerc ├── .dockerignore ├── .flake8 ├── .github └── workflows │ └── python-app.yml ├── .gitignore ├── .pydocstyle.ini ├── .pylintrc ├── .vscode └── settings.json ├── .yamllint ├── Dockerfile ├── LICENSE ├── README.md ├── codecov.yml ├── docker-compose.yml ├── docs ├── changelog.md └── methods.md ├── examples ├── __init__.py └── getter_example.py ├── poetry.lock ├── pyproject.toml ├── tests ├── __init__.py ├── conftest.py ├── fixtures │ ├── Jinja2 │ │ ├── sros_7750_python_configuration.j2 │ │ ├── sros_7750_python_declaration_configuration.j2 │ │ ├── sros_aaa_config.j2 │ │ ├── sros_aaa_declaration_config.j2 │ │ ├── sros_cflowd_config.j2 │ │ ├── sros_dhcp_config.j2 │ │ ├── sros_filter_configuration.j2 │ │ ├── sros_filter_log_configuration.j2 │ │ ├── sros_filter_match_list_configuration.j2 │ │ ├── sros_igmp_config_net.j2 │ │ ├── sros_igmp_config_srv.j2 │ │ ├── sros_l2tp_config.j2 │ │ ├── sros_ldp_config.j2 │ │ ├── sros_mgmt_router_config.j2 │ │ ├── sros_mirror_config.j2 │ │ ├── sros_multicast_path_management_policy_config.j2 │ │ ├── sros_pim_config_net.j2 │ │ ├── sros_port_cross-connect_config.j2 │ │ ├── sros_qos_policy_config1.j2 │ │ ├── sros_radius_config.j2 │ │ ├── sros_redundancy_config.j2 │ │ ├── sros_system_security_config.j2 │ │ ├── sros_twamp_light_config.j2 │ │ └── sros_vrrp_config.j2 │ ├── configs │ │ ├── example-config-7750-r2.txt │ │ ├── example-config-7750-r3.txt │ │ ├── example-config-7750.txt │ │ ├── example-config-sar.txt │ │ └── example-json.json │ ├── parsed_results │ │ ├── admin_display │ │ │ ├── aaa_configuration.json │ │ │ ├── aaa_declarations_configuration.json │ │ │ ├── cflowd.json │ │ │ ├── connectors.json │ │ │ ├── dhcp_configuration.json │ │ │ ├── ethcfm.json │ │ │ ├── filter_configuration.json │ │ │ ├── filter_log_configuration.json │ │ │ ├── filter_match_list_configuration.json │ │ │ ├── igmp_configuration.json │ │ │ ├── interfaces.json │ │ │ ├── isis_configuration.json │ │ │ ├── l2tp_configuration.json │ │ │ ├── lag.json │ │ │ ├── lag_1.json │ │ │ ├── ldp_configuration.json │ │ │ ├── log.json │ │ │ ├── mgmt_router_config.json │ │ │ ├── mirror_configuration.json │ │ │ ├── mpls_lsps.json │ │ │ ├── multicast_path_management_policy_configuration.json │ │ │ ├── pim_configuration.json │ │ │ ├── port_xc_configuration.json │ │ │ ├── ports.json │ │ │ ├── python_configuration.json │ │ │ ├── python_declaration.json │ │ │ ├── qos_policy_configuration.json │ │ │ ├── qos_policy_configuration1.json │ │ │ ├── qos_policy_configuration2.json │ │ │ ├── radius_configuration.json │ │ │ ├── redundancy_configuration.json │ │ │ ├── router_bgp_configuration.json │ │ │ ├── router_policy_configuration.json │ │ │ ├── static_routes.json │ │ │ ├── subscriber_mgmt_configuration.json │ │ │ ├── subscriber_mgmt_ss_configuration.json │ │ │ ├── system_begin.json │ │ │ ├── system_cards.json │ │ │ ├── system_configuration.json │ │ │ ├── system_interface.json │ │ │ ├── system_maf.json │ │ │ ├── system_profiles.json │ │ │ ├── system_sdp.json │ │ │ ├── system_security_configuration.json │ │ │ ├── system_time_ntp_config.json │ │ │ ├── twamp_light_config.json │ │ │ └── vrrp_configuration.json │ │ └── show_cmds │ │ │ ├── file_dir.json │ │ │ ├── show_bof.json │ │ │ ├── show_router_interface.json │ │ │ ├── show_router_route_table.json │ │ │ ├── show_service_service_using.json │ │ │ ├── show_static_route_v4.json │ │ │ └── show_static_route_v6.json │ └── show_output │ │ ├── file_dir.txt │ │ ├── show_bof.txt │ │ ├── show_route_table.txt │ │ ├── show_router_interface.txt │ │ ├── show_router_static_route_tag.txt │ │ ├── show_router_static_route_tag_v6.txt │ │ ├── show_router_vrf_route_table.txt │ │ ├── show_router_vrf_route_table_v6.txt │ │ ├── show_router_vrf_static_route_tag.txt │ │ └── show_service_service_using.txt ├── readme.txt └── unit │ ├── test_7750_only.py │ ├── test_helpers.py │ ├── test_srosparser_methods.py │ ├── test_ttp_sros_parser.py │ ├── test_ttp_sros_show_outputs.py │ ├── tests_sros_router_interfaces.py │ ├── tests_sros_show_router_interface.py │ └── tests_sros_system_configuration.py └── ttp_sros_parser ├── .gitignore ├── __init__.py ├── helpers.py ├── srosparser.py └── templates ├── __init__.py ├── admin_display_file ├── sros_7750_lag.ttp ├── sros_7750_mpls_lsp.ttp ├── sros_7750_python_configuration.ttp ├── sros_7750_python_declaration_configuration.ttp ├── sros_aaa_config.ttp ├── sros_aaa_declaration_config.ttp ├── sros_cflowd_config.ttp ├── sros_connector_configuration.ttp ├── sros_dhcp_config.ttp ├── sros_filter_configuration.ttp ├── sros_filter_log_configuration.ttp ├── sros_filter_match_list_configuration.ttp ├── sros_igmp_config.ttp ├── sros_isis_configuration.ttp ├── sros_l2tp_config.ttp ├── sros_ldp_config.ttp ├── sros_log_configuration.ttp ├── sros_mgmt_router_config.ttp ├── sros_mirror_config.ttp ├── sros_multicast_path_management_policy_config.ttp ├── sros_pim_config.ttp ├── sros_port_config.ttp ├── sros_port_cross-connect_config.ttp ├── sros_qos_policy_config.ttp ├── sros_qos_policy_config1.ttp ├── sros_qos_policy_config2.ttp ├── sros_radius_config.ttp ├── sros_redundancy_config.ttp ├── sros_router_bgp_config.ttp ├── sros_router_interface.ttp ├── sros_router_policy_config.ttp ├── sros_router_static_routes.ttp ├── sros_subscriber_mgmt_configuration.ttp ├── sros_subscriber_mgmt_ss_config.ttp ├── sros_system_begin.ttp ├── sros_system_cards.ttp ├── sros_system_configuration.ttp ├── sros_system_ethcfm.ttp ├── sros_system_maf.ttp ├── sros_system_profiles.ttp ├── sros_system_security_config.ttp ├── sros_system_service_customer.ttp ├── sros_system_service_sdp.ttp ├── sros_system_time_ntp.ttp ├── sros_twamp_light_config.ttp ├── sros_vrrp_config.ttp └── static-route-bkup ├── custom └── sros_custom_hostname_asn.ttp ├── full_config └── sros_full_config.ttp ├── helpers ├── sros_system_asn.ttp ├── sros_system_hostname.ttp └── sros_system_interface.ttp └── show_commands ├── show_router_router_table_general.ttp ├── sros_file_dir.ttp ├── sros_show_bof_cli.ttp ├── sros_show_router_interface.ttp ├── sros_show_router_route_table.ttp ├── sros_show_router_static_route_ipv4.ttp ├── sros_show_router_static_route_ipv6.ttp └── sros_show_service_service_using.ttp /.bandit.yml: -------------------------------------------------------------------------------- 1 | --- 2 | skips: ["B404", "B603"] 3 | # No need to check for security issues in the test scripts! 4 | exclude_dirs: 5 | - "./tests/" 6 | -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | branch = True 3 | source = ttp_sros_parser 4 | 5 | [report] 6 | show_missing = true 7 | 8 | exclude_lines = 9 | print.* 10 | return.* 11 | if self.debug: 12 | pragma: no cover 13 | raise NotImplementedError 14 | if __name__ == .__main__.: 15 | ignore_errors = True -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | *.tar.gz 2 | .env 3 | .venv 4 | .pytest_cache 5 | __pycache__/ 6 | .git/ 7 | .gitignore 8 | .gitlab-ci.yml 9 | Dockerfile 10 | docker-compose.yml 11 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | ignore = E203, E266, E501, W503, W605 3 | max-line-length = 88 4 | # McCabe complexity value for a block of code 5 | max-complexity = 31 6 | #select = B,C,E,F,W,T4,B9 7 | -------------------------------------------------------------------------------- /.github/workflows/python-app.yml: -------------------------------------------------------------------------------- 1 | # This workflow will install Python dependencies, run tests and lint with a single version of Python 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions 3 | 4 | --- 5 | name: "CI" 6 | on: # yamllint disable-line rule:truthy rule:comments 7 | - "push" 8 | - "pull_request" 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | python-version: ["3.8", "3.9", "3.10", "3.11"] 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: Set up Python 3.8 19 | uses: actions/setup-python@v2 20 | with: 21 | python-version: ${{ matrix.python-version }} 22 | architecture: x64 23 | - name: Install dependencies 24 | run: | 25 | python -m pip install --upgrade pip 26 | pip install poetry 27 | poetry install --no-interaction 28 | 29 | - name: Lint & Code Format 30 | run: | 31 | echo 'Running Black' && \ 32 | poetry run black --check --diff . && \ 33 | echo 'Running Yamllint' && \ 34 | poetry run yamllint . && \ 35 | echo 'Running Bandit' && \ 36 | poetry run bandit --recursive ./ --configfile pyproject.toml && \ 37 | echo 'Running MyPy' && \ 38 | poetry run mypy . 39 | 40 | - name: Test with pytest 41 | run: | 42 | poetry run pytest --cov=ttp_sros_parser --cov-report=xml -vv 43 | - name: Upload coverage to Codecov 44 | uses: codecov/codecov-action@v1 45 | with: 46 | token: ${{ secrets.CODECOV_TOKEN }} 47 | publish_gh: 48 | needs: 49 | - "build" 50 | name: "Publish to GitHub" 51 | runs-on: "ubuntu-20.04" 52 | if: "startsWith(github.ref, 'refs/tags/v')" 53 | steps: 54 | - name: "Check out repository code" 55 | uses: "actions/checkout@v2" 56 | - name: "Set up Python" 57 | uses: "actions/setup-python@v2" 58 | with: 59 | python-version: "3.8" 60 | - name: "Install Python Packages" 61 | run: "pip install poetry" 62 | - name: "Set env" 63 | run: "echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV" 64 | - name: "Run Poetry Version" 65 | run: "poetry version $RELEASE_VERSION" 66 | - name: "Run Poetry Build" 67 | run: "poetry build" 68 | - name: "Upload binaries to release" 69 | uses: "svenstaro/upload-release-action@v2" 70 | with: 71 | repo_token: "${{ secrets.GITHUB_TOKEN }}" 72 | file: "dist/*" 73 | tag: "${{ github.ref }}" 74 | overwrite: true 75 | file_glob: true 76 | publish_pypi: 77 | needs: 78 | - "build" 79 | name: "Push Package to PyPI" 80 | runs-on: "ubuntu-20.04" 81 | if: "startsWith(github.ref, 'refs/tags/v')" 82 | steps: 83 | - name: "Check out repository code" 84 | uses: "actions/checkout@v2" 85 | - name: "Set up Python" 86 | uses: "actions/setup-python@v2" 87 | with: 88 | python-version: "3.8" 89 | - name: "Install Python Packages" 90 | run: "pip install poetry" 91 | - name: "Set env" 92 | run: "echo RELEASE_VERSION=${GITHUB_REF:10} >> $GITHUB_ENV" 93 | - name: "Run Poetry Version" 94 | run: "poetry version $RELEASE_VERSION" 95 | - name: "Run Poetry Build" 96 | run: "poetry build" 97 | - name: "Push to PyPI" 98 | uses: "pypa/gh-action-pypi-publish@release/v1" 99 | with: 100 | user: "__token__" 101 | password: "${{ secrets.TTP_PYPI_API_TOKEN }}" 102 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | #Logs 10 | *.log 11 | 12 | #Configs 13 | *.cfg 14 | Parsed-Configs/*/*.txt 15 | Parsed-Configs/ 16 | # Visual Studio 17 | workspace.code-workspace 18 | .vscode 19 | 20 | # Distribution / packaging 21 | .Python 22 | build/ 23 | develop-eggs/ 24 | dist/ 25 | downloads/ 26 | eggs/ 27 | .eggs/ 28 | lib/ 29 | lib64/ 30 | parts/ 31 | sdist/ 32 | var/ 33 | wheels/ 34 | pip-wheel-metadata/ 35 | share/python-wheels/ 36 | *.egg-info/ 37 | .installed.cfg 38 | *.egg 39 | MANIFEST 40 | 41 | # PyInstaller 42 | # Usually these files are written by a python script from a template 43 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 44 | *.manifest 45 | *.spec 46 | 47 | # Installer logs 48 | pip-log.txt 49 | pip-delete-this-directory.txt 50 | 51 | # Unit test / coverage reports 52 | htmlcov/ 53 | .tox/ 54 | .nox/ 55 | .coverage 56 | .coverage.* 57 | .cache 58 | nosetests.xml 59 | coverage.xml 60 | *.cover 61 | *.py,cover 62 | .hypothesis/ 63 | .pytest_cache/ 64 | 65 | # Translations 66 | *.mo 67 | *.pot 68 | 69 | # Django stuff: 70 | *.log 71 | local_settings.py 72 | db.sqlite3 73 | db.sqlite3-journal 74 | 75 | # Flask stuff: 76 | instance/ 77 | .webassets-cache 78 | 79 | # Scrapy stuff: 80 | .scrapy 81 | 82 | # Sphinx documentation 83 | docs/_build/ 84 | 85 | # PyBuilder 86 | target/ 87 | 88 | # Jupyter Notebook 89 | .ipynb_checkpoints 90 | 91 | # IPython 92 | profile_default/ 93 | ipython_config.py 94 | 95 | # pyenv 96 | .python-version 97 | 98 | # pipenv 99 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 100 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 101 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 102 | # install all needed dependencies. 103 | #Pipfile.lock 104 | 105 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 106 | __pypackages__/ 107 | 108 | # Setup 109 | setup.py 110 | # Celery stuff 111 | celerybeat-schedule 112 | celerybeat.pid 113 | 114 | # SageMath parsed files 115 | *.sage.py 116 | 117 | # Environments 118 | .env 119 | .venv 120 | env/ 121 | venv/ 122 | ENV/ 123 | env.bak/ 124 | venv.bak/ 125 | 126 | # Spyder project settings 127 | .spyderproject 128 | .spyproject 129 | 130 | # Rope project settings 131 | .ropeproject 132 | 133 | # mkdocs documentation 134 | /site 135 | 136 | # mypy 137 | .mypy_cache/ 138 | .dmypy.json 139 | dmypy.json 140 | 141 | # Pyre type checker 142 | .pyre/ 143 | -------------------------------------------------------------------------------- /.pydocstyle.ini: -------------------------------------------------------------------------------- 1 | [pydocstyle] 2 | convention = google 3 | inherit = false 4 | match = (?!__init__).*\.py 5 | match-dir = (?!tests) -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "python.pythonPath": "/home/htinoco/.cache/pypoetry/virtualenvs/ttp-sros-parser-JRXJ3YFb-py3.8/bin/python", 3 | "workbench.colorCustomizations": { 4 | "activityBar.activeBackground": "#75aea7", 5 | "activityBar.activeBorder": "#f2ebf3", 6 | "activityBar.background": "#75aea7", 7 | "activityBar.foreground": "#15202b", 8 | "activityBar.inactiveForeground": "#15202b99", 9 | "activityBarBadge.background": "#f2ebf3", 10 | "activityBarBadge.foreground": "#15202b", 11 | "statusBar.background": "#599790", 12 | "statusBar.foreground": "#15202b", 13 | "statusBarItem.hoverBackground": "#467771", 14 | "titleBar.activeBackground": "#599790", 15 | "titleBar.activeForeground": "#15202b", 16 | "titleBar.inactiveBackground": "#59979099", 17 | "titleBar.inactiveForeground": "#15202b99", 18 | "sash.hoverBorder": "#75aea7", 19 | "statusBarItem.remoteBackground": "#599790", 20 | "statusBarItem.remoteForeground": "#15202b", 21 | "commandCenter.border": "#15202b99" 22 | }, 23 | "peacock.remoteColor": "#599790", 24 | "python.linting.pylintEnabled": true, 25 | "peacock.color": "#599790", 26 | "githubPullRequests.ignoredPullRequestBranches": ["develop"], 27 | "ansible.python.interpreterPath": "/home/codespace/.python/current/bin/python3" 28 | } 29 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | yaml-files: 4 | - '*.yaml' 5 | - '*.yml' 6 | - '.yamllint' 7 | 8 | rules: 9 | braces: 10 | min-spaces-inside: 0 11 | max-spaces-inside: 0 12 | min-spaces-inside-empty: -1 13 | max-spaces-inside-empty: -1 14 | brackets: 15 | min-spaces-inside: 0 16 | max-spaces-inside: 0 17 | min-spaces-inside-empty: -1 18 | max-spaces-inside-empty: -1 19 | colons: 20 | max-spaces-before: 0 21 | max-spaces-after: 1 22 | commas: 23 | max-spaces-before: 0 24 | min-spaces-after: 1 25 | max-spaces-after: 1 26 | comments: 27 | level: "warning" 28 | require-starting-space: true 29 | min-spaces-from-content: 2 30 | comments-indentation: 31 | level: "warning" 32 | document-end: "disable" 33 | document-start: 34 | present: true 35 | empty-lines: 36 | max: 2 37 | max-start: 0 38 | max-end: 0 39 | quoted-strings: 40 | quote-type: "double" 41 | empty-values: 42 | forbid-in-block-mappings: false 43 | forbid-in-flow-mappings: false 44 | hyphens: 45 | max-spaces-after: 1 46 | indentation: 47 | spaces: "consistent" 48 | indent-sequences: true 49 | check-multi-line-strings: false 50 | key-duplicates: "enable" 51 | key-ordering: "disable" 52 | line-length: 53 | max: 120 54 | allow-non-breakable-words: true 55 | allow-non-breakable-inline-mappings: false 56 | new-line-at-end-of-file: "enable" 57 | new-lines: 58 | type: "unix" 59 | octal-values: 60 | forbid-implicit-octal: false 61 | forbid-explicit-octal: false 62 | trailing-spaces: "enable" 63 | truthy: 64 | level: "warning" 65 | 66 | extends: default 67 | 68 | ignore: | 69 | .github/ 70 | .yamllint -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ############# 2 | # Dependencies 3 | # 4 | # This base stage just installs the dependencies required for production 5 | # without any development deps. 6 | ARG PYTHON_VER=3.8 7 | FROM python:${PYTHON_VER} AS base 8 | 9 | WORKDIR /usr/src/app 10 | 11 | RUN pip install -U pip && \ 12 | curl -sSL https://install.python-poetry.org | python3 - 13 | ENV PATH="/root/.local/bin:$PATH" 14 | 15 | RUN poetry config virtualenvs.create false 16 | 17 | # Install project manifest 18 | COPY pyproject.toml poetry.lock ./ 19 | 20 | RUN poetry install --no-root 21 | 22 | ############ 23 | # Unit Tests 24 | # 25 | # This test stage runs true unit tests (no outside services) at build time, as 26 | # well as enforcing codestyle and performing fast syntax checks. It is built 27 | # into an image with docker-compose for running the full test suite. 28 | FROM base AS test 29 | 30 | COPY . . 31 | 32 | RUN poetry install --no-interaction 33 | 34 | ############ 35 | # Linting 36 | # 37 | # Runs all necessary linting and code checks 38 | RUN echo 'Running Flake8' && \ 39 | flake8 . && \ 40 | echo 'Running Black' && \ 41 | black --check --diff . && \ 42 | echo 'Running Pylint' && \ 43 | find . -name '*.py' | xargs pylint && \ 44 | echo 'Running Yamllint' && \ 45 | yamllint . && \ 46 | echo 'Running pydocstyle' && \ 47 | pydocstyle . && \ 48 | echo 'Running Bandit' && \ 49 | bandit --recursive ./ --configfile .bandit.yml 50 | 51 | RUN pytest --color yes -vvv tests 52 | 53 | # Run full test suite including integration 54 | ENTRYPOINT ["pytest"] 55 | 56 | # Default to running colorful, verbose pytests 57 | CMD ["--cov=ttp_sros_parser", "--color=yes", "-vvv"] 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![codecov](https://codecov.io/gh/h4ndzdatm0ld/ttp_sros_parser/branch/main/graph/badge.svg?token=ZL8JDKLQJI)](https://codecov.io/gh/h4ndzdatm0ld/ttp_sros_parser) 2 | 3 | # TTP SrosParser 4 | 5 | A library to parse a Nokia SROS 7750 full hierarchical configuration text file into structured data. Show commands are also able to be parsed, if included in the file alongside the configuration. This library is still under development, but a lot of parsers are readily available (see below for supported features). Configurations used for testing have all been on release version higher than TiMOS 16. At the moment, there is no capability to specify release version to accommodate different parsing templates. 6 | 7 | ## What TTP SrosParser is not 8 | 9 | A library that connects and extracts information from a remote device. You, as the end-user must obtain a text file of the configuration. This file will be passed into the SrosParser class and you are able to convert a flat text configuration file into structure data using the built-in TTP parser templates. At this point, it's recommended to use a new instance of the srosparser with an individual show command as the text to parse to get the best results when parsing a show commands. 10 | 11 | ## Example 12 | 13 | ```python 14 | """SrosParser - Example.""" 15 | from ttp_sros_parser.srosparser import SrosParser 16 | 17 | EXAMPLE_CONFIG = "some/dir/path/to/7750-config.txt" 18 | 19 | # Instantiate class 20 | router = SrosParser(EXAMPLE_CONFIG) 21 | 22 | # Call `get_system_cards` method 23 | router.get_system_cards() 24 | ``` 25 | 26 | Results: 27 | 28 | ```json 29 | [ 30 | { 31 | "configure":{ 32 | "card":{ 33 | "card-type":{ 34 | "card-type":"iom-1", 35 | "subscription-level":"cr" 36 | }, 37 | "fail-on-error":true, 38 | "mda":{ 39 | "admin-state":true, 40 | "egress-xpl":{ 41 | "window":"10" 42 | }, 43 | "fail-on-error":true, 44 | "ingress-xpl":{ 45 | "window":"10" 46 | }, 47 | "mda-slot":"1", 48 | "mda-type":"me6-100gb-qsfp28" 49 | }, 50 | "slot-number":"1" 51 | } 52 | } 53 | } 54 | ] 55 | ``` 56 | 57 | ## Available Methods (Parsers) 58 | 59 | Current methods available (Automatically updated at build): 60 | 61 | [Methods](docs/methods.md) 62 | 63 | ## Full Config 64 | 65 | **SrosParser** allows you to parse the full configuration with a single method call, `get_full_config()` and receive the full JSON output of the device. 66 | 67 | ## Custom Templates 68 | 69 | SrosParser allows you to simply specify a custom template after you initialize a new class object. 70 | 71 | ```python 72 | router = SrosParser("path/to/config.txt") 73 | 74 | cool_ttp_template = router.get_custom_template("path/to/template") 75 | 76 | print(cool_ttp_template) 77 | ``` 78 | 79 | ## Contributing 80 | 81 | Any contribution to the project must include unit tests and pass all linting. 82 | 83 | Simply run: 84 | 85 | - `docker-compose build` 86 | - `docker-compose run test` 87 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | --- 2 | codecov: 3 | require_ci_to_pass: true 4 | 5 | coverage: 6 | precision: 2 7 | round: "down" 8 | range: "70...100" 9 | 10 | parsers: 11 | gcov: 12 | branch_detection: 13 | conditional: true 14 | loop: true 15 | method: false 16 | macro: false 17 | 18 | comment: 19 | layout: "reach,diff,flags,files,footer" 20 | behavior: "default" 21 | require_changes: false 22 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "3.8" 3 | services: 4 | test: 5 | build: 6 | context: "." 7 | target: "test" 8 | -------------------------------------------------------------------------------- /docs/changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [1.0.0] - 2023-XX-XX 8 | 9 | ### Added 10 | - Introduced Dataclasses and simplified the main class object SrosParser 11 | - Contributions from @Jeremy-Coder76. Test / parsing changes + additional parsers. PR#33 12 | Methods 13 | - get_system_begin 14 | - get_mgmt_router_config 15 | - get_cflowd 16 | - get_python_declaration_configuration 17 | - get_filter_log_configuration 18 | - get_filter_match_list_configuration 19 | - get_system_security_configuration 20 | - get_qos_policy_configuration 21 | - get_qos_policy_configuration1 22 | - get_qos_policy_configuration2 23 | - get_python_configuration 24 | - get_isis_configuration 25 | - get_subscriber_mgmt_configuration 26 | - get_aaa_declarations_configuration 27 | - get_multicast_path_management_policy_configuration 28 | - get_port_xc_configuration 29 | - get_redundancy_configuration 30 | - get_filter_configuration 31 | - get_vrrp_configuration 32 | - get_igmp_configuration 33 | - get_l2tp_configuration 34 | - get_router_policy_configuration 35 | - get_router_bgp_configuration 36 | - get_subscriber_mgmt_ss_configuration 37 | - get_mirror_configuration 38 | - get_radius_configuration 39 | - get_dhcp_configuration 40 | - get_twamp_light_config 41 | - get_aaa_configuration 42 | - get_pim_configuration 43 | - get_ldp_configuration 44 | - get_system_time_ntp_config 45 | ### Changed 46 | - Several parsing changes happened, which will break previously working parsers. PR#33 47 | - Private `_parse` method always returns Dict now 48 | - All unit tests reflect the above changes 49 | 50 | ## [0.1.6] - 2022-22-05 51 | 52 | ### Added 53 | - Better support for LAG parsing 54 | - CI Actions updated for easy release process on Pypi / GH 55 | 56 | ### Changed 57 | - Double quotes on LAG rendering stripped to single 58 | - Loosened development dependencies for local dev 59 | - Pinned TTP (0.7.2) as anything above breaks parsing 60 | 61 | ## [0.1.5] - 2021-24-12 62 | 63 | ### Added 64 | 65 | - Full Test Coverage 66 | - Project restructure 67 | - Docker/Docker-Compose for local project testing, linting, etc. 68 | - Github Actions updates 69 | - Documentation 70 | - Added Changelog 71 | - Created a develop branch as default 72 | 73 | ## [Unreleased] 74 | -------------------------------------------------------------------------------- /docs/methods.md: -------------------------------------------------------------------------------- 1 | ``` 2 | get_aaa_configuration 3 | get_aaa_declarations_configuration 4 | get_cflowd 5 | get_connectors 6 | get_custom_template 7 | get_dhcp_configuration 8 | get_filter_configuration 9 | get_filter_log_configuration 10 | get_filter_match_list_configuration 11 | get_full_config 12 | get_igmp_configuration 13 | get_isis_configuration 14 | get_l2tp_configuration 15 | get_lags 16 | get_ldp_configuration 17 | get_log_configuration 18 | get_lsps 19 | get_mgmt_router_config 20 | get_mirror_configuration 21 | get_multicast_path_management_policy_configuration 22 | get_pim_configuration 23 | get_port_xc_configuration 24 | get_ports 25 | get_python_configuration 26 | get_python_declaration_configuration 27 | get_qos_policy_configuration 28 | get_qos_policy_configuration1 29 | get_qos_policy_configuration2 30 | get_radius_configuration 31 | get_redundancy_configuration 32 | get_router_bgp_configuration 33 | get_router_interfaces 34 | get_router_policy_configuration 35 | get_router_static_routes 36 | get_subscriber_mgmt_configuration 37 | get_subscriber_mgmt_ss_configuration 38 | get_system_asn 39 | get_system_begin 40 | get_system_cards 41 | get_system_configuration 42 | get_system_ethcfm 43 | get_system_hostname 44 | get_system_interface 45 | get_system_maf 46 | get_system_profiles 47 | get_system_security_configuration 48 | get_system_service_sdp 49 | get_system_time_ntp_config 50 | get_twamp_light_config 51 | get_vrrp_configuration 52 | show_bof 53 | show_file_dir 54 | show_router_interface 55 | show_router_route_table 56 | show_router_static_route 57 | show_service_service_using 58 | ``` 59 | -------------------------------------------------------------------------------- /examples/__init__.py: -------------------------------------------------------------------------------- 1 | """Examples.""" 2 | -------------------------------------------------------------------------------- /examples/getter_example.py: -------------------------------------------------------------------------------- 1 | """SrosParser Example.""" 2 | from pprint import pprint 3 | 4 | from ttp_sros_parser.srosparser import SrosParser 5 | 6 | EXAMPLE_CONFIG = "tests/fixtures/configs/example-config-7750.txt" 7 | 8 | router = SrosParser(EXAMPLE_CONFIG) 9 | 10 | pprint(router.get_system_cards()) 11 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "ttp_sros_parser" 3 | version = "0.1.6" 4 | description = "Utility to parse a full SROS Configuration." 5 | authors = ["Hugo "] 6 | readme = "README.md" 7 | repository = "https://github.com/h4ndzdatm0ld/ttp_sros_parser" 8 | keywords = ["sros", "ttp", "ttp-templates", "network automation", "nokia", "7750"] 9 | 10 | [tool.poetry.dependencies] 11 | python = "^3.8" 12 | ttp = "0.7.2" 13 | 14 | [tool.poetry.group.dev.dependencies] 15 | mypy = "*" 16 | flake8 = "*" 17 | pylint = "*" 18 | pydocstyle = "*" 19 | bandit = "*" 20 | yamllint = "*" 21 | black = "*" 22 | pytest = "*" 23 | ipython = "*" 24 | pytest-cov = "*" 25 | coverage = "*" 26 | 27 | [build-system] 28 | requires = ["poetry-core>=1.0.0"] 29 | build-backend = "poetry.core.masonry.api" 30 | 31 | [tool.pytest.ini_options] 32 | testpaths = [ 33 | "tests" 34 | ] 35 | 36 | [tool.pylint.messages_control] 37 | # Line length is enforced by Black, so pylint doesn't need to check it. 38 | # Pylint and Black disagree about how to format multi-line arrays; Black wins. 39 | disable = """, 40 | line-too-long, 41 | bad-continuation, 42 | """ 43 | 44 | [tool.pylint.miscellaneous] 45 | # Don't flag TODO as a failure, let us commit with things that still need to be done in the code 46 | notes = """, 47 | FIXME, 48 | XXX, 49 | """ 50 | 51 | [tool.black] 52 | line-length = 120 53 | include = '\.pyi?$' 54 | exclude = ''' 55 | /( 56 | \.git 57 | | \.tox 58 | | \.venv 59 | | env/ 60 | | _build 61 | | build 62 | | dist 63 | )/ 64 | ''' 65 | 66 | 67 | [tool.mypy] 68 | namespace_packages = true 69 | explicit_package_bases = true 70 | show_error_codes = true 71 | enable_error_code = [ 72 | "ignore-without-code", 73 | "truthy-bool", 74 | ] 75 | check_untyped_defs = true 76 | ignore_errors = false 77 | ignore_missing_imports = true 78 | strict_optional = true 79 | warn_unused_ignores = true 80 | warn_redundant_casts = true 81 | warn_unused_configs = true 82 | disallow_untyped_calls = true 83 | disallow_untyped_defs = true 84 | disallow_incomplete_defs = true 85 | disallow_untyped_decorators = true 86 | disallow_any_generics = true 87 | warn_return_any = false 88 | python_version = 3.8 89 | disallow_subclassing_any = true 90 | no_implicit_optional = true 91 | implicit_reexport = true 92 | strict_equality = true 93 | exclude = "tests/" 94 | 95 | [tool.bandit] 96 | exclude_dirs = ["tests"] 97 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | """Tests.""" 2 | -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_7750_python_configuration.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "PYTHON Configuration" 3 | #-------------------------------------------------- 4 | python 5 | {%- for python_script in parsed_config[0]['configure']['python']['python-script'] %}{% if python_script['name'] %} 6 | python-script "{{python_script['name']}}" create 7 | {%- if python_script['description'] %} 8 | description "{{python_script['description']}}" 9 | {%- endif %} 10 | primary-url "{{python_script['primary-url']}}" 11 | {%- if python_script['admin_state']%} 12 | no shutdown 13 | {%- else %} 14 | shutdown 15 | {%- endif %} 16 | exit 17 | {%- endif %} 18 | {%- endfor %} 19 | {%- for python_policy in parsed_config[0]['configure']['python']['python-policy'] %}{% if python_policy['name'] %} 20 | python-policy "{{python_policy['name']}}" create 21 | {%- if python_policy['description'] %} 22 | description "{{python_policy['description']}}" 23 | {%- endif %} 24 | {%- for dhcp in python_policy['dhcp'] %}{% if dhcp['message'] %} 25 | dhcp {{dhcp['message']}} direction {{dhcp['direction']}} script "{{dhcp['script']}}" 26 | {%- endif %} 27 | {%- endfor %} 28 | {%- for dhcp6 in python_policy['dhcp6'] %}{% if dhcp6['message'] %} 29 | dhcp6 {{dhcp6['message']}} direction {{dhcp6['direction']}} script "{{dhcp6['script']}}" 30 | {%- endif %} 31 | {%- endfor %} 32 | exit 33 | {%- endif %} 34 | {%- endfor %} 35 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_7750_python_declaration_configuration.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "PYTHON (declaration) Configuration" 3 | #-------------------------------------------------- 4 | python 5 | {%- for python_policy in parsed_config[0]['configure']['python']['python-policy'] %}{% if python_policy['name'] %} 6 | python-policy {{python_policy['name']}} create 7 | exit 8 | {%- endif %} 9 | {%- endfor %} 10 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_aaa_config.j2: -------------------------------------------------------------------------------- 1 | aaa{% for radius_server_policy in parsed_config[0]['configure']['aaa']['radius-server-policy']%}{% if radius_server_policy.name %} 2 | radius-server-policy {{ radius_server_policy.name }} create 3 | description {{ radius_server_policy.description }} 4 | acct-request-server-policy {{ radius_server_policy['acct-request-server-policy'] }} 5 | 6 | servers 7 | retry {{ radius_server_policy['servers']['retry'] }} 8 | router {{ radius_server_policy['servers']['router'] }} 9 | server router {{ radius_server_policy['servers']['server-id'] }} name {{ radius_server_policy['servers']['server-name'] }} 10 | exit 11 | exit 12 | {% endif %}{%- endfor %} -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_aaa_declaration_config.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "AAA (Declarations) Configuration" 3 | #-------------------------------------------------- 4 | aaa 5 | {%- for server in parsed_config[0]['configure']['aaa_declarations']['radius-server-policy']%}{%- if server['name'] %} 6 | radius-server-policy "{{server['name']}}" create 7 | exit 8 | {%- endif %} 9 | {%- endfor %} 10 | {%- for script in parsed_config[0]['configure']['aaa_declarations']['radius-script-policy']%}{%- if script['name'] %} 11 | radius-script-policy "{{script['name']}}" create 12 | exit 13 | {%- endif %} 14 | {%- endfor %} 15 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_cflowd_config.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "Cflowd Configuration" 3 | #-------------------------------------------------- 4 | cflowd 5 | active-timeout {{parsed_config[0]['configure']['cflowd']['active-timeout']}} 6 | cache-size {{parsed_config[0]['configure']['cflowd']['cache-size']}} 7 | inactive-timeout {{parsed_config[0]['configure']['cflowd']['inactive-timeout']}} 8 | rate {{parsed_config[0]['configure']['cflowd']['rate']}} 9 | template-retransmit {{parsed_config[0]['configure']['cflowd']['template-retransmit']}} 10 | collector {{parsed_config[0]['configure']['cflowd']['collector']['collector_ip_address']}} version {{parsed_config[0]['configure']['cflowd']['collector']['version_id']}} 11 | description "{{parsed_config[0]['configure']['cflowd']['collector']['description']}}" 12 | template-set {{parsed_config[0]['configure']['cflowd']['collector']['collector_template-set']}} 13 | exit 14 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_dhcp_config.j2: -------------------------------------------------------------------------------- 1 | {%- set server = parsed_config[0]['configure']['router']['dhcp']['server'] %} 2 | #-------------------------------------------------- 3 | echo "Local DHCP Server (Base Router) Configuration" 4 | #-------------------------------------------------- 5 | router 6 | dhcp 7 | local-dhcp-server "{{server['name']}}" create 8 | user-db "{{server['user-db']}}" 9 | pool "{{server['pool']['name']}}" create 10 | min-lease-time {{server['pool']['min-lease-time']}} 11 | max-lease-time {{server['pool']['max-lease-time']}} 12 | options 13 | dns-server {% for dns in server['pool']['options']['dns-server']%}{{dns}} {% endfor %} 14 | {%- for option in server['pool']['options']['custom-option']%}{% if option['id'] %} 15 | custom-option {{option['id']}} address {{option['address']}} 16 | {%- endif %} 17 | {%- endfor %} 18 | exit 19 | subnet {{server['pool']['subnet']['prefix']}} create 20 | address-range {{server['pool']['subnet']['address-range']}} 21 | exit 22 | exit 23 | {%- if server['admin_state']%} 24 | no shutdown 25 | {%- else %} 26 | shutdown 27 | {%- endif %} 28 | exit 29 | exit 30 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_filter_configuration.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "Filter Configuration" 3 | #-------------------------------------------------- 4 | filter 5 | ip-filter 10 name "10" create 6 | embed-filter flowspec router "Base" 7 | exit 8 | ip-filter 1001 name "1001" create 9 | embed-filter flowspec router "Base" offset 2000 10 | exit 11 | ip-filter 1002 name "1002" create 12 | embed-filter 2000 13 | embed-filter 2100 14 | exit 15 | ip-filter 1003 name "1003" create 16 | embed-filter 2001 17 | embed-filter 2101 18 | exit 19 | ip-filter 1005 name "1005" create 20 | embed-filter 2001 21 | exit 22 | ip-filter 2002 name "2002" create 23 | embed-filter flowspec router "Base" offset 2000 24 | exit 25 | ipv6-filter 1002 name "1002" create 26 | embed-filter 2000 27 | embed-filter 2100 28 | exit 29 | ipv6-filter 1003 name "1003" create 30 | embed-filter 2001 31 | embed-filter 2101 32 | exit 33 | ipv6-filter 1004 name "1004" create 34 | embed-filter 2000 35 | exit 36 | ipv6-filter 1005 name "1005" create 37 | embed-filter 2001 38 | exit 39 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_filter_log_configuration.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "Filter Log Configuration" 3 | #-------------------------------------------------- 4 | filter 5 | {%- for log in parsed_config[0]['configure']['filter']['log'] %}{% if log['log-id'] %} 6 | log {{log['log-id']}} create 7 | {%- if log['description']%} 8 | description "{{log['description']}}" 9 | {%- endif %} 10 | exit 11 | {%- endif %} 12 | {%- endfor %} 13 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_filter_match_list_configuration.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "Filter Match lists Configuration" 3 | #-------------------------------------------------- 4 | filter 5 | match-list 6 | {%- for ip_pfx in parsed_config[0]['configure']['filter'][0]['match-list']['ip-prefix-list'] %}{% if ip_pfx['name'] %} 7 | ip-prefix-list "{{ip_pfx['name']}}" create 8 | {%- if ip_pfx['description'] %} 9 | description "{{ip_pfx['description']}}" 10 | {%- endif %} 11 | {%- for pfx in ip_pfx['prefix'] %} 12 | prefix {{pfx}} 13 | {%- endfor %} 14 | exit 15 | {%- endif %} 16 | {%- endfor %} 17 | {%- for ipv6_pfx in parsed_config[0]['configure']['filter'][0]['match-list']['ipv6-prefix-list'] %}{% if ipv6_pfx['name'] %} 18 | ipv6-prefix-list "{{ipv6_pfx['name']}}" create 19 | {%- if ipv6_pfx['description'] %} 20 | description "{{ipv6_pfx['description']}}" 21 | {%- endif %} 22 | {%- for pfx in ipv6_pfx['prefix'] %} 23 | prefix {{pfx}} 24 | {%- endfor %} 25 | exit 26 | {%- endif %} 27 | {%- endfor %} 28 | exit 29 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_igmp_config_net.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "IGMP Configuration" 3 | #-------------------------------------------------- 4 | igmp 5 | ssm-translate 6 | {%- for group in parsed_config[0]['configure']['router']['igmp'][0]['ssm-translate']['grp-range']%}{% if group['grp-range'] %} 7 | grp-range {{group['grp-range']}} 8 | source {{group['source']}} 9 | exit 10 | {%- endif %} 11 | {%- endfor %} 12 | exit 13 | {%- if parsed_config[0]['configure']['router']['igmp'][0]['admin_state']%} 14 | no shutdown 15 | {%- else %} 16 | shutdown 17 | {%- endif %} 18 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_igmp_config_srv.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "IGMP Configuration" 3 | #-------------------------------------------------- 4 | igmp 5 | ssm-translate 6 | {%- for group in parsed_config[0]['configure']['router']['igmp'][1]['ssm-translate']['grp-range']%}{% if group['grp-range'] %} 7 | grp-range {{group['grp-range']}} 8 | source {{group['source']}} 9 | exit 10 | {%- endif %} 11 | {%- endfor %} 12 | exit 13 | {%- for interface in parsed_config[0]['configure']['router']['igmp'][1]['interface']%}{% if interface['name'] %} 14 | interface "{{interface['name']}}" 15 | {%- if interface['admin_state']%} 16 | no shutdown 17 | {%- else %} 18 | shutdown 19 | {%- endif %} 20 | exit 21 | {%- endif %} 22 | {%- endfor %} 23 | query-interval {{parsed_config[0]['configure']['router']['igmp'][1]['query_interval']}} 24 | query-last-member-interval {{parsed_config[0]['configure']['router']['igmp'][1]['query-last-member-interval']}} 25 | {%- if parsed_config[0]['configure']['router']['igmp'][1]['admin_state']%} 26 | no shutdown 27 | {%- else %} 28 | shutdown 29 | {%- endif %} 30 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_l2tp_config.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "L2TP Configuration" 3 | #-------------------------------------------------- 4 | l2tp 5 | group "{{parsed_config[0]['configure']['router']['l2tp']['group']['group']}}" protocol {{parsed_config[0]['configure']['router']['l2tp']['group']['protocol']}} create 6 | tunnel "{{parsed_config[0]['configure']['router']['l2tp']['group']['tunnel']['tunnel']}}" create 7 | local-name "{{parsed_config[0]['configure']['router']['l2tp']['group']['tunnel']['local-name']}}" 8 | peer {{parsed_config[0]['configure']['router']['l2tp']['group']['tunnel']['peer']}} 9 | {%- if parsed_config[0]['configure']['router']['l2tp']['group']['tunnel']['admin_state']%} 10 | no shutdown 11 | {%- else %} 12 | shutdown 13 | {%- endif %} 14 | exit 15 | {%- if parsed_config[0]['configure']['router']['l2tp']['group']['admin_state']%} 16 | no shutdown 17 | {%- else %} 18 | shutdown 19 | {%- endif %} 20 | exit 21 | {%- if parsed_config[0]['configure']['router']['l2tp']['group']['admin_state']%} 22 | no shutdown 23 | {%- else %} 24 | shutdown 25 | {%- endif %} 26 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_ldp_config.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "LDP Configuration" 3 | #-------------------------------------------------- 4 | ldp 5 | export-tunnel-table "{{parsed_config[0]['configure']['router']['ldp']['export-tunnel-table']}}" 6 | {%- if parsed_config[0]['configure']['router']['ldp']['fast-reroute'] %} 7 | fast-reroute 8 | {%- endif %} 9 | fec-originate {{parsed_config[0]['configure']['router']['ldp']['fec-originate']}} {% if parsed_config[0]['configure']['router']['ldp']['pop']%}pop{% endif %} 10 | interface-parameters 11 | interface "{{parsed_config[0]['configure']['router']['ldp']['interface_parameters']['interface']['name']}}" {% if parsed_config[0]['configure']['router']['ldp']['interface_parameters']['interface']['dual-stack']%}dual-stack {% endif %} 12 | ipv4 13 | {%- if parsed_config[0]['configure']['router']['ldp']['interface_parameters']['interface']['ipv4']['admin_state']%} 14 | no shutdown 15 | {%- else %} 16 | shutdown 17 | {%- endif %} 18 | exit 19 | {%- if parsed_config[0]['configure']['router']['ldp']['interface_parameters']['interface']['admin_state']%} 20 | no shutdown 21 | {%- else %} 22 | shutdown 23 | {%- endif %} 24 | exit 25 | exit 26 | {%- if parsed_config[0]['configure']['router']['ldp']['targeted-session'] is defined%} 27 | targeted-session 28 | {%- if parsed_config[0]['configure']['router']['ldp']['admin_state'] == 'true'%} 29 | no shutdown 30 | {%- endif %} 31 | exit 32 | {%- endif %} 33 | {%- if parsed_config[0]['configure']['router']['ldp']['admin_state']%} 34 | no shutdown 35 | {%- else %} 36 | shutdown 37 | {%- endif %} 38 | exit 39 | -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_mgmt_router_config.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "Management Router Configuration" 3 | #-------------------------------------------------- 4 | router management 5 | {%- for route in parsed_config[0]['configure']['router']['router-name']['management']['entry']%}{% if route['address'] %} 6 | static-route-entry {{route['address']}}/{{route['prefix']}} 7 | next-hop {{route['next-hop']}} 8 | exit 9 | exit 10 | {%- endif %} 11 | {%- endfor %} 12 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_mirror_config.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "Mirror Configuration" 3 | #-------------------------------------------------- 4 | mirror 5 | {%- for mirror in parsed_config[0]['configure']['mirror']['mirror-conf'] %}{% if mirror['mirror-dest'] %} 6 | mirror-dest {{mirror['mirror-dest']}} name {{mirror['name']}} type {{mirror['type']}} create 7 | description {{mirror['description']}} 8 | encap 9 | {{mirror['encap']['l3-encap']['encap-type']}} create 10 | gateway create 11 | ip src {{mirror['encap']['l3-encap']['gateway']['src-ip']}} dest {{mirror['encap']['l3-encap']['gateway']['dest-ip']}} 12 | udp src {{mirror['encap']['l3-encap']['gateway']['src-udp']}} dest {{mirror['encap']['l3-encap']['gateway']['dest-udp']}} 13 | exit 14 | exit 15 | exit 16 | {%- if mirror['admin-state']%} 17 | no shutdown 18 | {%- else %} 19 | shutdown 20 | {%- endif %} 21 | exit 22 | {%- endif %} 23 | {%- endfor %} 24 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_multicast_path_management_policy_config.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "Multicast Path Management Policy Configuration" 3 | #-------------------------------------------------- 4 | mcast-management 5 | bandwidth-policy "{{parsed_config[0]['configure']['mcast-management']['bandwidth-policy']['name']}}" create 6 | t2-paths 7 | secondary-path 8 | number-paths {{parsed_config[0]['configure']['mcast-management']['bandwidth-policy']['t2-paths']['secondary-path']['number-paths']}} redundant-sfm {{parsed_config[0]['configure']['mcast-management']['bandwidth-policy']['t2-paths']['secondary-path']['redundant-sfm']}} 9 | exit 10 | exit 11 | exit 12 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_pim_config_net.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "PIM Configuration" 3 | #-------------------------------------------------- 4 | pim 5 | {%- for interface in parsed_config[0]['configure']['router']['pim'][0]['interface']%}{% if interface['name'] %} 6 | interface "{{interface['name']}}" 7 | exit 8 | {%- endif %} 9 | {%- endfor %} 10 | rp 11 | static 12 | {%- if parsed_config[0]['configure']['router']['pim'][0]['rp']['static']['admin_state'] == 'false'%} 13 | shutdown 14 | {%- endif %} 15 | exit 16 | bsr-candidate 17 | {%- if not parsed_config[0]['configure']['router']['pim'][0]['rp']['bsr-candidate']['admin_state']%} 18 | shutdown 19 | {%- endif %} 20 | exit 21 | rp-candidate 22 | {%- if not parsed_config[0]['configure']['router']['pim'][0]['rp']['rp-candidate']['admin_state']%} 23 | shutdown 24 | {%- endif %} 25 | exit 26 | exit 27 | {%- if parsed_config[0]['configure']['router']['pim'][0]['admin_state']%} 28 | no shutdown 29 | {%- endif %} 30 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_port_cross-connect_config.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "Port Cross-Connect Configuration" 3 | #-------------------------------------------------- 4 | port-xc 5 | {%- for pxc in parsed_config[0]['configure']['port-xc']['pxc'] %}{% if pxc['number'] %} 6 | pxc {{pxc['number']}} create 7 | description "{{pxc['description']}}" 8 | port {{pxc['port']}} 9 | {%- if pxc['admin_state']%} 10 | no shutdown 11 | {%- else %} 12 | shutdown 13 | {%- endif %} 14 | exit 15 | {%- endif %} 16 | {%- endfor %} 17 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_radius_config.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "RADIUS Server Configuration" 3 | #-------------------------------------------------- 4 | radius-server 5 | {%- for server in parsed_config[0]['configure']['router']['radius-server']['server']%}{% if server['name'] %} 6 | server "{{server['name']}}" address {{server['address']}} secret "{{server['secret']}}" {{server['hash-type']}} create 7 | description "{{server['description']}}" 8 | {%- if server['acct-port'] %} 9 | acct-port {{server['acct-port']}} 10 | {%- endif %} 11 | {%- if server['accept-coa'] %} 12 | accept-coa 13 | {%- endif %} 14 | {%- if server['auth-port'] %} 15 | auth-port {{server['auth-port']}} 16 | {%- endif %} 17 | {%- if server['coa-script-policy'] %} 18 | coa-script-policy "{{server['coa-script-policy']}}" 19 | {%- endif %} 20 | exit 21 | {%- endif %} 22 | {%- endfor %} 23 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_redundancy_config.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "Redundancy Configuration" 3 | #-------------------------------------------------- 4 | redundancy 5 | multi-chassis 6 | peer {{parsed_config[0]['configure']['redundancy']['multi-chassis']['peer']['peer-address']}} create 7 | description "{{parsed_config[0]['configure']['redundancy']['multi-chassis']['peer']['description']}}" 8 | sync 9 | {%- if parsed_config[0]['configure']['redundancy']['multi-chassis']['peer']['sync']['igmp'] %} 10 | igmp 11 | {%- endif %} 12 | {%- if parsed_config[0]['configure']['redundancy']['multi-chassis']['peer']['sync']['srrp'] %} 13 | srrp 14 | {%- endif %} 15 | {%- if parsed_config[0]['configure']['redundancy']['multi-chassis']['peer']['sync']['sub-mgmt'] %} 16 | sub-mgmt {{parsed_config[0]['configure']['redundancy']['multi-chassis']['peer']['sync']['sub-mgmt']}} 17 | {%- endif %} 18 | {%- for port in parsed_config[0]['configure']['redundancy']['multi-chassis']['peer']['sync']['port']%}{% if port['port'] %} 19 | port {{port['port']}} create 20 | {%- for range in port['range']%}{% if range['range'] %} 21 | range {{range['range']}} sync-tag "{{range['sync-tag']}}" 22 | {%- endif %} 23 | {%- endfor %} 24 | exit 25 | {%- endif %} 26 | {%- endfor %} 27 | {%- if parsed_config[0]['configure']['redundancy']['multi-chassis']['peer']['sync']['admin_state'] %} 28 | no shutdown 29 | {%- else %} 30 | shutdown 31 | {%- endif%} 32 | exit 33 | {%- if parsed_config[0]['configure']['redundancy']['multi-chassis']['peer']['admin_state'] %} 34 | no shutdown 35 | {%- else %} 36 | shutdown 37 | {%- endif%} 38 | exit 39 | exit 40 | synchronize {{parsed_config[0]['configure']['redundancy']['synchronize']}} 41 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_twamp_light_config.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "TWAMP Light Configuration" 3 | #-------------------------------------------------- 4 | twamp-light 5 | reflector udp-port {{parsed_config[0]['configure']['router']['twamp_light']['reflector']['udp_port']}} create 6 | description "{{parsed_config[0]['configure']['router']['twamp_light']['reflector']['description']}}" 7 | {%- for prefix in parsed_config[0]['configure']['router']['twamp_light']['reflector']['prefix']%}{% if prefix['prefix'] %} 8 | prefix {{prefix['prefix']}} create 9 | description "{{prefix['description']}}" 10 | exit 11 | {%- endif %} 12 | {%- endfor %} 13 | {%- if parsed_config[0]['configure']['router']['twamp_light']['reflector']['admin_state']%} 14 | no shutdown 15 | {%- else %} 16 | shutdown 17 | {%- endif %} 18 | exit 19 | exit 20 | exit -------------------------------------------------------------------------------- /tests/fixtures/Jinja2/sros_vrrp_config.j2: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- 2 | echo "Vrrp Configuration" 3 | #-------------------------------------------------- 4 | vrrp 5 | {%- for policy in parsed_config[0]['configure']['vrrp']['policy']%}{% if policy['id'] %} 6 | policy {{policy['id']}} 7 | {%- if policy['delta-in-use-limit'] %} 8 | delta-in-use-limit {{policy['delta-in-use-limit']}} 9 | {%- endif %} 10 | {%- if policy['priority-event'] %} 11 | priority-event 12 | lag-port-down {{policy['priority-event']['lag-port-down']['id']}} 13 | hold-clear {{policy['priority-event']['lag-port-down']['hold-clear']}} 14 | number-down {{policy['priority-event']['lag-port-down']['number-down']['id']}} 15 | priority {{policy['priority-event']['lag-port-down']['number-down']['priority']}} delta 16 | exit 17 | exit 18 | exit 19 | {%- endif %} 20 | exit 21 | {%- endif %} 22 | {%- endfor %} 23 | exit -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/aaa_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "aaa": { 4 | "radius-script-policy": [ 5 | { 6 | "name": "RADIUS-IN-DEF", 7 | "primary": { 8 | "admin_state": true, 9 | "script-url": "cf3:/SCRIPT_PYTHON/RADIUS-IN-DEF-v2.0.py" 10 | } 11 | }, 12 | { 13 | "name": "RADIUS-OUT-DEF", 14 | "primary": { 15 | "admin_state": true, 16 | "script-url": "cf3:/SCRIPT_PYTHON/RADIUS-OUT-DEF-v2.0.py" 17 | } 18 | }, 19 | { 20 | "name": "RADIUS-OUT-DSL-TES", 21 | "primary": { 22 | "admin_state": true, 23 | "script-url": "cf3:/SCRIPT_PYTHON/RADIUS-OUT-DSL-TES-v1.0.py" 24 | } 25 | }, 26 | { 27 | "name": "RADIUS-IN-DEF" 28 | }, { 29 | "name": "RADIUS-OUT-DEF" 30 | }, { 31 | "name": "RADIUS-OUT-DSL-TES" 32 | }, { 33 | "name": "RADIUS-REQUEST-DROP" 34 | }, { 35 | "name": "RADIUS-ACCEPT-BITSTREAM-RED" 36 | }, { 37 | "name": "RADIUS-REQUEST-MIGR-SRR-RED" 38 | }, { 39 | "description": "vers Route Explorer", 40 | "name": "RADIUS-REQUEST-BITSTREAM-RED" 41 | } 42 | ], 43 | "radius-server-policy": [ 44 | { 45 | "acct-request-script-policy": "RADIUS-REQUEST-BITSTREAM-RED", 46 | "description": "Radius Accounting pour Collecte Ethernet", 47 | "name": "RADIUS-ACCT-COLL-ETH-RED", 48 | "servers": { 49 | "retry": "1", 50 | "router": "Base", 51 | "server-id": "1", 52 | "server-name": "RADIUS-ACCT" 53 | } 54 | }, 55 | { 56 | "auth-request-script-policy": "RADIUS-REQUEST-DROP", 57 | "description": "But est de dropper les paquets pour utiliser le fallback accept", 58 | "name": "RADIUS-AUTH-TIMEOUT", 59 | "servers": { 60 | "retry": "1", 61 | "router": "Base", 62 | "server-id": "1", 63 | "server-name": "RADIUS-AUTH", 64 | "timeout": "sec 59" 65 | } 66 | }, 67 | { 68 | "name": "RADIUS-ACCT-COLL-ETH-RED" 69 | }, 70 | { 71 | "name": "RADIUS-ACCT-DEF" 72 | }, { 73 | "name": "RADIUS-ACCT-DSL-TES" 74 | }, { 75 | "name": "RADIUS-ACCT-MIGR-SRR-RED" 76 | }, { 77 | "name": "RADIUS-AUTH-COLL-ETH-RED" 78 | }, { 79 | "name": "RADIUS-AUTH-DEF" 80 | }, { 81 | "name": "RADIUS-AUTH-DSL-TES" 82 | }, { 83 | "name": "RADIUS-AUTH-MIGR-SRR-RED" 84 | }, { 85 | "name": "RADIUS-AUTH-TIMEOUT" 86 | } 87 | ] 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/aaa_declarations_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "aaa_declarations": { 4 | "radius-script-policy": [ 5 | { 6 | "name": "RADIUS-IN-DEF" 7 | }, 8 | { 9 | "name": "RADIUS-OUT-DEF" 10 | }, 11 | { 12 | "name": "RADIUS-OUT-DSL-TES" 13 | }, 14 | { 15 | "name": "RADIUS-REQUEST-DROP" 16 | }, { 17 | "name": "RADIUS-ACCEPT-BITSTREAM-RED" 18 | }, { 19 | "name": "RADIUS-REQUEST-MIGR-SRR-RED" 20 | }, { 21 | "name": "RADIUS-REQUEST-BITSTREAM-RED" 22 | } 23 | ], 24 | "radius-server-policy": [ 25 | { 26 | "name": "RADIUS-ACCT-COLL-ETH-RED" 27 | }, 28 | { 29 | "name": "RADIUS-ACCT-DEF" 30 | }, 31 | { 32 | "name": "RADIUS-ACCT-DSL-TES" 33 | }, 34 | { 35 | "name": "RADIUS-ACCT-MIGR-SRR-RED" 36 | }, { 37 | "name": "RADIUS-AUTH-COLL-ETH-RED" 38 | }, { 39 | "name": "RADIUS-AUTH-DEF" 40 | }, { 41 | "name": "RADIUS-AUTH-DSL-TES" 42 | }, { 43 | "name": "RADIUS-AUTH-MIGR-SRR-RED" 44 | }, { 45 | "name": "RADIUS-AUTH-TIMEOUT" 46 | } 47 | ] 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/cflowd.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "cflowd": { 4 | "active-timeout": "1", 5 | "cache-size": "128000", 6 | "collector": [ 7 | { 8 | "collector_ip_address": "10.61.221.151:3000", 9 | "collector_template-set": "mpls-ip", 10 | "description": "vers Route Explorer", 11 | "version_id": "9" 12 | }, { 13 | "collector_ip_address": "218.152.120.60", 14 | "collector_template-set": "mpls-ip", 15 | "description": "Collecteur Peakflow", 16 | "version_id": "10" 17 | } 18 | ], 19 | "inactive-timeout": "30", 20 | "rate": "2000", 21 | "template-retransmit": "120" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/connectors.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "connector": { 4 | "port": { 5 | "1/1/c1": { 6 | "admin-state": true, 7 | "breakout": "c4-10g" 8 | }, 9 | "1/1/c1/1": { 10 | "admin-state": true 11 | }, 12 | "1/1/c1/3": { 13 | "admin-state": true 14 | }, 15 | "1/1/c1/4": { 16 | "admin-state": true 17 | }, 18 | "1/1/c2": { 19 | "admin-state": true, 20 | "breakout": "c4-10g" 21 | }, 22 | "1/1/c3": { 23 | "admin-state": true, 24 | "breakout": "c4-10g" 25 | } 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/dhcp_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "router": { 4 | "dhcp": { 5 | "_ignore_": "management", 6 | "server": { 7 | "admin_state": true, 8 | "name": "SERVEUR-DHCP-GENERIQUE", 9 | "pool": { 10 | "max-lease-time": "hrs 4", 11 | "min-lease-time": "hrs 4", 12 | "name": "POOL-LOCAL-MIGRATION-3P", 13 | "options": { 14 | "custom-option": [ 15 | { 16 | "address": "195.85.32.97", 17 | "id": "42" 18 | }, { 19 | "address": "195.85.32.97", 20 | "id": "72" 21 | } 22 | ], 23 | "dns-server": ["195.85.40.10", "195.85.40.15"] 24 | }, 25 | "subnet": { 26 | "address-range": "10.98.115.2 10.98.123.254", 27 | "prefix": "10.98.115.0/20" 28 | } 29 | }, 30 | "user-db": "SRV-DHCP-LOCAL" 31 | } 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/ethcfm.json: -------------------------------------------------------------------------------- 1 | { 2 | "system": { 3 | "eth-cfm": { 4 | "domain": [ 5 | { 6 | "associations": [ 7 | { 8 | "association-id": "1", 9 | "bridge-id": "420691", 10 | "format": "icc-based", 11 | "name": "epipe-7750-01", 12 | "remote-mepid": "420" 13 | }, { 14 | "association-id": "2", 15 | "bridge-id": "420692", 16 | "format": "icc-based", 17 | "name": "epipe-7750-02", 18 | "remote-mepid": "1420" 19 | } 20 | ], 21 | "domain-id": "1", 22 | "format": "none", 23 | "level": "1" 24 | }, { 25 | "associations": [ 26 | { 27 | "association-id": "1", 28 | "bridge-id": "11111", 29 | "format": "icc-based", 30 | "name": "epipe-7750-01", 31 | "remote-mepid": "4201" 32 | }, { 33 | "association-id": "2", 34 | "bridge-id": "2222", 35 | "format": "icc-based", 36 | "name": "epipe-7750-02", 37 | "remote-mepid": "14202" 38 | } 39 | ], 40 | "domain-id": "2", 41 | "format": "none", 42 | "level": "1" 43 | } 44 | ] 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/filter_log_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "filter": { 4 | "log": [ 5 | { 6 | "description": "IPV4-FILTER-LOG", 7 | "log-id": "104" 8 | }, { 9 | "description": "IPV6-FILTER-LOG", 10 | "log-id": "106" 11 | } 12 | ] 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/filter_match_list_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "filter": { 4 | "match-list": { 5 | "ip-prefix-list": [ 6 | { 7 | "description": "DEEPFIELD", 8 | "name": "DEEPFIELD", 9 | "prefix": ["10.61.29.241/32", "10.61.29.242/32"] 10 | }, { 11 | "description": "EQUIPMENTS", 12 | "name": "EQUIPEMENTS", 13 | "prefix": [ 14 | "172.26.101.3/32", 15 | "172.26.42.48/32", 16 | "172.26.15.65/32", 17 | "172.25.100.108/32", 18 | "172.24.49.17/32", 19 | "172.24.48.5/32" 20 | ] 21 | }, { 22 | "description": "TOTO1", 23 | "name": "TOTO1", 24 | "prefix": ["218.152.120.58/32", "218.152.120.60/32", "218.152.144.6/32", "218.141.22.128/25"] 25 | }, { 26 | "description": "FLOW", 27 | "name": "FLOW", 28 | "prefix": [ 29 | "10.48.122.153/32", 30 | "10.48.122.169/32", 31 | "218.152.120.58/32", 32 | "218.152.120.59/32", 33 | "218.152.120.60/32", 34 | "218.152.144.6/32" 35 | ] 36 | } 37 | ], 38 | "ipv6-prefix-list": { 39 | "name": "PAR", 40 | "prefix": ["d910:f180:2a7f:358f:6f50:4084:75d5:101/128", "d910:f180:2a7f:358e:985c:15ea:6a75:4401/128", "d910:f180:2a7f:3589:75b5:7f9e:9b85:7001/128", "d910:f180:2a7f:3588:885c:1fdb:fce8:4f01/128"] 41 | } 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/igmp_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "router": { 4 | "igmp": { 5 | "interface": [ 6 | { 7 | "name": "to-7750-01" 8 | }, { 9 | "name": "to-BTS0475-7750-H2" 10 | } 11 | ] 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/interfaces.json: -------------------------------------------------------------------------------- 1 | { 2 | "router": { 3 | "interfaces": [ 4 | { 5 | "admin_state": true, 6 | "ingress_stats": true, 7 | "interface_name": "system", 8 | "ipv4": { 9 | "primary": { 10 | "address": "199.199.9.1", 11 | "prefix_length": "32" 12 | } 13 | }, 14 | "ipv6": { 15 | "address": { 16 | "ipv6_address": "2001:1111:3333:0:420:2a0::", 17 | "prefix_length": "128" 18 | } 19 | } 20 | }, { 21 | "admin_state": true, 22 | "description": "LINK-TO-EXAMPLEPHX-P-AL-0420-01", 23 | "interface_name": "TO-42069-7705", 24 | "ipv4": { 25 | "bfd": { 26 | "ipv4_bfd": "500 receive 500 multiplier 3" 27 | }, 28 | "primary": { 29 | "address": "172.25.199.132", 30 | "prefix_length": "31" 31 | } 32 | }, 33 | "ipv6": { 34 | "address": [ 35 | { 36 | "ipv6_address": "2001:2222:3333:33e3:645:4a0::", 37 | "prefix_length": "64" 38 | }, { 39 | "ipv6_bfd": "500 receive 500 multiplier 3 type cpm-np" 40 | } 41 | ] 42 | }, 43 | "port": "lag-92:3482", 44 | "qos": { 45 | "network-policy": "10120" 46 | } 47 | } 48 | ] 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/isis_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "router": { 4 | "isis": { 5 | "interface": [ 6 | { 7 | "name": "to-7750-01" 8 | }, { 9 | "name": "to-BTS0475-7750-H2" 10 | } 11 | ], 12 | "timers": [ 13 | { 14 | "spf-initial-wait": "10", 15 | "spf-second-wait": "100", 16 | "spf-wait": "1500" 17 | }, { 18 | "spf-initial-wait": "10", 19 | "spf-second-wait": "100", 20 | "spf-wait": "1500" 21 | } 22 | ] 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/l2tp_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "router": { 4 | "l2tp": { 5 | "admin_state": true, 6 | "group": { 7 | "admin_state": true, 8 | "group": "LNS", 9 | "protocol": "v2", 10 | "tunnel": { 11 | "admin_state": true, 12 | "local-name": "BNG-ATHENA", 13 | "peer": "195.185.47.234", 14 | "tunnel": "LNS" 15 | } 16 | } 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/lag.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "lag": [ 4 | { 5 | "admin-state": true, 6 | "description": "LINK-TO-TNTNMADO91A-P-AL-7750-01", 7 | "encap-type": "dot1q", 8 | "lacp": { 9 | "administrative-key": "11125", 10 | "hold-time": "down 250", 11 | "mode": "active" 12 | }, 13 | "lag-index": "125", 14 | "mode": "hybrid", 15 | "port": ["1/1/c1/1"] 16 | }, { 17 | "admin-state": true, 18 | "description": "LAG-11-to-TNTNMADOT1A-P-AL-7750-060475-H2", 19 | "encap-type": "dot1q", 20 | "lacp": { 21 | "administrative-key": "10011", 22 | "hold-time": "down 250", 23 | "mode": "active" 24 | }, 25 | "lag-index": "11", 26 | "mode": "hybrid", 27 | "port": ["1/1/c1/3", "1/1/c1/4"] 28 | } 29 | ] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/lag_1.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "lag": [ 4 | { 5 | "admin-state": true, 6 | "bfd": { 7 | "ipv4": { 8 | "admin-state": true, 9 | "family": "ipv4", 10 | "local-ip": "1.1.1.1", 11 | "multiplier": "4", 12 | "remote-ip-address": "1.1.1.2" 13 | } 14 | }, 15 | "description": "####LAG####", 16 | "lacp": { 17 | "administrative-key": "32100", 18 | "mode": "active" 19 | }, 20 | "lag-index": "100", 21 | "port": [ 22 | "9/1/c1/1", 23 | "9/1/c2/1", 24 | "9/1/c3/1", 25 | "9/1/c4/1", 26 | "9/1/c5/1", 27 | "9/1/c6/1", 28 | "9/1/c17/1", 29 | "9/1/c18/1", 30 | "9/1/c19/1", 31 | "9/1/c20/1", 32 | "9/1/c21/1", 33 | "9/1/c22/1", 34 | "9/1/c23/1", 35 | "8/1/c21/1", 36 | "8/1/c25/1", 37 | "8/1/c26/1", 38 | "8/1/c27/1" 39 | ] 40 | }, 41 | { 42 | "admin-state": true, 43 | "bfd": { 44 | "ipv4": { 45 | "admin-state": true, 46 | "family": "ipv4", 47 | "local-ip": "2.2.2.2", 48 | "multiplier": "4", 49 | "remote-ip-address": "2.2.2.3" 50 | } 51 | }, 52 | "description": "####LAG####", 53 | "lacp": { 54 | "administrative-key": "32101", 55 | "mode": "active" 56 | }, 57 | "lag-index": "101", 58 | "port": [ 59 | "8/1/c1/1", 60 | "8/1/c2/1", 61 | "8/1/c3/1", 62 | "8/1/c4/1", 63 | "8/1/c5/1", 64 | "8/1/c6/1", 65 | "8/1/c7/1", 66 | "8/1/c8/1", 67 | "8/1/c9/1", 68 | "8/1/c10/1" 69 | ] 70 | }, 71 | { 72 | "admin-state": true, 73 | "description": "####LAG####", 74 | "encap-type": "dot1q", 75 | "lacp": { 76 | "administrative-key": "32102", 77 | "mode": "active" 78 | }, 79 | "lag-index": "102", 80 | "mode": "hybrid", 81 | "port": [ 82 | "9/1/c26/1", 83 | "9/1/c27/1", 84 | "9/1/c30/1", 85 | "9/1/c31/1", 86 | "9/1/c32/1", 87 | "9/1/c33/1", 88 | "9/1/c34/1", 89 | "9/1/c35/1", 90 | "9/1/c36/1", 91 | "8/1/c28/1", 92 | "8/1/c35/1", 93 | "8/1/c36/1" 94 | ] 95 | }, 96 | { 97 | "description": "####LAG####", 98 | "lag-index": "103", 99 | "mode": "access", 100 | "name": "myLag103", 101 | "port": ["9/1/c24/1"] 102 | }, { 103 | "admin-state": true, 104 | "description": "####LAG####", 105 | "encap-type": "dot1q", 106 | "lacp": { 107 | "administrative-key": "32104", 108 | "mode": "passive" 109 | }, 110 | "lag-index": "104", 111 | "mode": "access", 112 | "name": "myLag104", 113 | "port": ["8/1/c11/1", "8/1/c12/1"] 114 | }, { 115 | "admin-state": true, 116 | "description": "####LAG####", 117 | "encap-type": "dot1q", 118 | "lacp": { 119 | "administrative-key": "32105", 120 | "mode": "passive" 121 | }, 122 | "lag-index": "105", 123 | "mode": "access", 124 | "name": "myLag105", 125 | "port": ["8/1/c13/1", "8/1/c14/1"] 126 | } 127 | ] 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/ldp_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "router": { 4 | "ldp": { 5 | "export-tunnel-table": "EXPORT", 6 | "fast-reroute": true, 7 | "fec-originate": "218.152.120.207/32", 8 | "interface_parameters": { 9 | "interface": [ 10 | { 11 | "dual-stack": true, 12 | "ipv4": {}, 13 | "name": "to-7750-01" 14 | }, { 15 | "dual-stack": true, 16 | "ipv4": {}, 17 | "name": "to-BTS0475-7750-H2" 18 | } 19 | ] 20 | }, 21 | "pop": true, 22 | "targeted-session": {} 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/log.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "log": [ 4 | { 5 | "file": [ 6 | { 7 | "file-id": "10" 8 | }, { 9 | "compact-flash-location": { 10 | "primary": "cf3" 11 | }, 12 | "description": "Syslog-storage", 13 | "file-id": "20", 14 | "retention": "350", 15 | "rollover": "1440" 16 | }, { 17 | "compact-flash-location": { 18 | "primary": "cf3" 19 | }, 20 | "description": "Change-storage", 21 | "file-id": "30", 22 | "retention": "350", 23 | "rollover": "1440" 24 | } 25 | ], 26 | "log-events": { 27 | "chassis": [ 28 | { 29 | "event": "system", 30 | "event-id": "2103", 31 | "generate": true 32 | }, { 33 | "event": "system", 34 | "event-id": "2104", 35 | "generate": true 36 | }, { 37 | "event": "vrtr", 38 | "event-id": "2034", 39 | "generate": true 40 | } 41 | ] 42 | }, 43 | "snmp-trap-group": [ 44 | { 45 | "log-id": "10" 46 | }, { 47 | "log-id": "7", 48 | "trap-target": { 49 | "address": "10.141.128.78", 50 | "name": "SW_INC", 51 | "notify-community": "2Y2LHTZP31", 52 | "snmp-version": "snmpv2c" 53 | } 54 | }, { 55 | "description": "5620sam", 56 | "log-id": "98", 57 | "trap-target": [ 58 | { 59 | "address": "99.194.69.164", 60 | "name": "0017A4770C06:main1", 61 | "notify-community": "snmpuser3", 62 | "security-level": "privacy", 63 | "snmp-version": "snmpv3" 64 | }, { 65 | "address": "99.215.238.164", 66 | "name": "0017A4770C06:main2", 67 | "notify-community": "snmpuser3", 68 | "security-level": "privacy", 69 | "snmp-version": "snmpv3" 70 | }, { 71 | "address": "99.194.69.164", 72 | "name": "99.194.69.164:162", 73 | "notify-community": "snmpuser3", 74 | "security-level": "privacy", 75 | "snmp-version": "snmpv3" 76 | }, { 77 | "address": "99.215.238.164", 78 | "name": "99.215.238.164:162", 79 | "notify-community": "snmpuser3", 80 | "security-level": "privacy", 81 | "snmp-version": "snmpv3" 82 | } 83 | ] 84 | } 85 | ], 86 | "syslog": { 87 | "address": "10.215.141.147", 88 | "description": "Syslog Server", 89 | "syslog-id": "5" 90 | } 91 | }, 92 | { 93 | "log-id": "5", 94 | "source": { 95 | "change": true, 96 | "main": true, 97 | "security": true, 98 | "source": "main" 99 | } 100 | }, 101 | { 102 | "description": "SW_INC", 103 | "destination": "snmp", 104 | "log-id": "7", 105 | "source": { 106 | "main": true, 107 | "security": true, 108 | "source": "main" 109 | } 110 | }, 111 | { 112 | "log-id": "20", 113 | "source": { 114 | "main": true, 115 | "security": true, 116 | "source": "main" 117 | } 118 | }, { 119 | "log-id": "30", 120 | "source": { 121 | "change": true, 122 | "source": "change" 123 | } 124 | }, { 125 | "log-id": "98", 126 | "source": { 127 | "main": true, 128 | "security": true, 129 | "source": "main" 130 | } 131 | } 132 | ] 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/mgmt_router_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "router": { 4 | "router-name": { 5 | "management": { 6 | "entry": [ 7 | { 8 | "address": "10.205.205.66", 9 | "next-hop": "10.60.228.254", 10 | "prefix": "32" 11 | }, 12 | { 13 | "address": "10.205.204.0", 14 | "next-hop": "10.60.228.254", 15 | "prefix": "24" 16 | }, 17 | { 18 | "address": "10.53.105.241", 19 | "next-hop": "10.60.228.254", 20 | "prefix": "32" 21 | }, 22 | { 23 | "address": "10.61.221.151", 24 | "next-hop": "10.60.228.254", 25 | "prefix": "32" 26 | }, { 27 | "address": "172.26.15.65", 28 | "next-hop": "10.60.228.254", 29 | "prefix": "32" 30 | }, { 31 | "address": "172.29.80.0", 32 | "next-hop": "10.60.228.254", 33 | "prefix": "24" 34 | }, { 35 | "address": "172.17.110.238", 36 | "next-hop": "10.60.228.254", 37 | "prefix": "32" 38 | }, { 39 | "address": "172.17.110.249", 40 | "next-hop": "10.60.228.254", 41 | "prefix": "32" 42 | }, { 43 | "address": "172.17.110.252", 44 | "next-hop": "10.60.228.254", 45 | "prefix": "32" 46 | } 47 | ] 48 | } 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/mirror_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "mirror": { 4 | "mirror-conf": { 5 | "admin-state": true, 6 | "description": "\"TPLALIS-d01-1\"", 7 | "encap": { 8 | "l3-encap": { 9 | "encap-type": "layer-3-encap ip-udp-shim", 10 | "gateway": { 11 | "dest-ip": "218.141.22.146", 12 | "dest-udp": "23000", 13 | "src-ip": "218.152.120.74", 14 | "src-udp": "23457" 15 | } 16 | } 17 | }, 18 | "mirror-dest": "19001", 19 | "name": "\"19001\"", 20 | "type": "ip-only" 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/mpls_lsps.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "mpls": { 4 | "auto-lsp": { 5 | "policy": "Remote-PEz", 6 | "template": "Full-Mesh" 7 | }, 8 | "lsp": [ 9 | { 10 | "admin-state": "true", 11 | "fast-reroute": "facility", 12 | "path-computation-method": "local-cspf", 13 | "primary": "loose", 14 | "secondary": "loose-2", 15 | "standby": "standby", 16 | "to": "10.10.10.8" 17 | }, { 18 | "admin-state": "true", 19 | "fast-reroute": "facility", 20 | "path-computation-method": "local-cspf", 21 | "primary": "loose", 22 | "secondary": "loose-2", 23 | "standby": "standby", 24 | "to": "10.10.10.1" 25 | }, { 26 | "admin-state": "true", 27 | "fast-reroute": "facility", 28 | "path-computation-method": "local-cspf", 29 | "primary": "loose", 30 | "secondary": "loose-2", 31 | "standby": "standby", 32 | "to": "10.10.10.2" 33 | }, { 34 | "admin-state": "true", 35 | "fast-reroute": "facility", 36 | "path-computation-method": "local-cspf", 37 | "primary": "loose", 38 | "secondary": "loose-2", 39 | "standby": "standby", 40 | "to": "10.10.10.4" 41 | } 42 | ], 43 | "path": [ 44 | { 45 | "admin-state": "true", 46 | "name": "loose" 47 | }, { 48 | "admin-state": "true", 49 | "name": "loose-2" 50 | } 51 | ], 52 | "templates": { 53 | "entry": { 54 | "admin-state": "true", 55 | "default-path": "loose", 56 | "fast-reroute": "facility", 57 | "name": "Full-Mesh", 58 | "path-computation-method": "local-cspf", 59 | "type": "mesh-p2p" 60 | } 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/multicast_path_management_policy_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "mcast-management": { 4 | "bandwidth-policy": { 5 | "name": "14-SEC-PATHS", 6 | "t2-paths": { 7 | "secondary-path": { 8 | "number-paths": "14", 9 | "redundant-sfm": "14" 10 | } 11 | } 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/pim_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "router": { 4 | "pim": { 5 | "interface": [ 6 | { 7 | "name": "to-7750-01" 8 | }, { 9 | "name": "to-BTS0475-7750-H2" 10 | } 11 | ] 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/port_xc_configuration.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/ports.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "port": [ 4 | { 5 | "admin_state": true, 6 | "description": "7705-MGMT-CSMA", 7 | "ethernet": { 8 | "autonegotiate": false 9 | }, 10 | "port-id": "1/5/1" 11 | }, 12 | { 13 | "admin_state": true, 14 | "description": "BTS0215-1X-URC01", 15 | "ethernet": { 16 | "autonegotiate": false, 17 | "encap-type": "dot1q" 18 | }, 19 | "port-id": "1/5/2" 20 | }, 21 | { 22 | "admin_state": false, 23 | "ethernet": {}, 24 | "port-id": "1/5/3" 25 | }, 26 | { 27 | "admin_state": false, 28 | "ethernet": {}, 29 | "port-id": "1/5/4" 30 | }, { 31 | "admin_state": true, 32 | "description": "LINK-TO-LOOPBACK-7705PORT", 33 | "ethernet": { 34 | "encap-type": "dot1q", 35 | "loopback": true, 36 | "mtu": "2106" 37 | }, 38 | "port-id": "1/5/5" 39 | }, { 40 | "admin_state": false, 41 | "ethernet": { 42 | "autonegotiate": false, 43 | "encap-type": "dot1q" 44 | }, 45 | "port-id": "1/5/6" 46 | }, { 47 | "admin_state": true, 48 | "description": "eNodeB0215-LTE-eCCM01-1", 49 | "ethernet": { 50 | "autonegotiate": "limited", 51 | "encap-type": "dot1q", 52 | "hold-time": { 53 | "down": "50" 54 | }, 55 | "mtu": "2106" 56 | }, 57 | "port-id": "1/5/7" 58 | }, { 59 | "admin_state": true, 60 | "description": "Link-to-TEMPE-AZ-EXAMPLE-P-AL-0415-H1-1/2/8", 61 | "ethernet": { 62 | "autonegotiate": false, 63 | "egress-rate": "96260", 64 | "encap-type": "dot1q", 65 | "hold-time": { 66 | "down": "25", 67 | "up": "50" 68 | }, 69 | "mode": "network", 70 | "mtu": "2106" 71 | }, 72 | "port-id": "1/5/8" 73 | }, { 74 | "admin_state": true, 75 | "description": "7705-MGMT-CSMB", 76 | "ethernet": { 77 | "autonegotiate": false 78 | }, 79 | "port-id": "1/6/1" 80 | }, { 81 | "admin_state": true, 82 | "description": "BTS0215-1X-URC02", 83 | "ethernet": { 84 | "autonegotiate": false, 85 | "encap-type": "dot1q" 86 | }, 87 | "port-id": "1/6/2" 88 | }, { 89 | "admin_state": false, 90 | "ethernet": { 91 | "autonegotiate": false, 92 | "encap-type": "dot1q" 93 | }, 94 | "port-id": "1/6/3" 95 | }, { 96 | "admin_state": false, 97 | "ethernet": {}, 98 | "port-id": "1/6/4" 99 | }, { 100 | "admin_state": false, 101 | "ethernet": {}, 102 | "port-id": "1/6/5" 103 | }, { 104 | "admin_state": true, 105 | "description": "BTS0215-DO-URC03", 106 | "ethernet": { 107 | "autonegotiate": false, 108 | "encap-type": "dot1q" 109 | }, 110 | "port-id": "1/6/6" 111 | }, { 112 | "admin_state": true, 113 | "description": "eNodeB324215-LTE-eCCM01-1", 114 | "ethernet": { 115 | "autonegotiate": "limited", 116 | "encap-type": "dot1q", 117 | "hold-time": { 118 | "down": "50" 119 | }, 120 | "mtu": "2106" 121 | }, 122 | "port-id": "1/6/7" 123 | }, { 124 | "admin_state": true, 125 | "description": "Link-to-TEMPE-AZ-EXAMPLE-P-AL-0415-H2-1/2/8", 126 | "ethernet": { 127 | "autonegotiate": false, 128 | "egress-rate": "96260", 129 | "encap-type": "dot1q", 130 | "mode": "network", 131 | "mtu": "2106" 132 | }, 133 | "port-id": "1/6/8" 134 | } 135 | ] 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/python_configuration.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/python_declaration.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/radius_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "router": { 4 | "radius-server": { 5 | "server": [ 6 | { 7 | "acct-port": "1646", 8 | "address": "195.85.40.21", 9 | "description": "Radius serveR", 10 | "hash-type": "hash2", 11 | "name": "RADIUS-ACCT", 12 | "secret": "netconanRemoved16" 13 | }, { 14 | "accept-coa": true, 15 | "address": "195.85.40.20", 16 | "auth-port": "1645", 17 | "coa-script-policy": "RADIUS-IN-DEF", 18 | "description": "Radius server", 19 | "hash-type": "hash2", 20 | "name": "RADIUS-AUTH", 21 | "secret": "netconanRemoved17" 22 | } 23 | ] 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/redundancy_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "redundancy": { 4 | "multi-chassis": { 5 | "peer": { 6 | "admin_state": true, 7 | "description": "BNG02-PAR", 8 | "peer-address": "218.152.120.75", 9 | "sync": { 10 | "admin_state": true, 11 | "igmp": true, 12 | "port": [ 13 | { 14 | "port": "lag-30", 15 | "range": [ 16 | { 17 | "range": "100.1-100.499", 18 | "sync-tag": "tag1110" 19 | }, 20 | { 21 | "range": "100.1000-100.1000", 22 | "sync-tag": "tag1110" 23 | }, 24 | { 25 | "range": "835.1-835.24", 26 | "sync-tag": "tag1310" 27 | }, 28 | { 29 | "range": "835.1000-835.1000", 30 | "sync-tag": "tag1310" 31 | }, { 32 | "range": "836.1-836.24", 33 | "sync-tag": "tag1410" 34 | }, { 35 | "range": "836.1000-836.1000", 36 | "sync-tag": "tag1410" 37 | }, { 38 | "range": "1000.1-1000.499", 39 | "sync-tag": "tag1010" 40 | }, { 41 | "range": "1000.1000-1000.1000", 42 | "sync-tag": "tag1510" 43 | }, { 44 | "range": "1001.1-1001.499", 45 | "sync-tag": "tag1510" 46 | } 47 | ] 48 | }, { 49 | "port": "lag-36", 50 | "range": [ 51 | { 52 | "range": "100.1-100.499", 53 | "sync-tag": "tag1106" 54 | }, 55 | { 56 | "range": "100.1000-100.1000", 57 | "sync-tag": "tag1106" 58 | }, 59 | { 60 | "range": "1000.1-1000.499", 61 | "sync-tag": "tag1006" 62 | }, 63 | { 64 | "range": "1000.1000-1000.1000", 65 | "sync-tag": "tag1006" 66 | }, { 67 | "range": "1001.1-1001.499", 68 | "sync-tag": "tag1506" 69 | }, { 70 | "range": "1001.1000-1001.1000", 71 | "sync-tag": "tag1506" 72 | } 73 | ] 74 | } 75 | ], 76 | "srrp": true, 77 | "sub-mgmt": "ipoe pppoe" 78 | } 79 | } 80 | }, 81 | "synchronize": "boot-env" 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/router_bgp_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "router": { 4 | "bgp": { 5 | "advertise-external": [ 6 | ["ipv4", "ipv6", "label-ipv4", "label-ipv6"] 7 | ], 8 | "backup-path": [ 9 | ["ipv4", "ipv6", "label-ipv4", "label-ipv6"] 10 | ], 11 | "enable-peer-tracking": true, 12 | "group": [ 13 | { 14 | "description": "Interco eBGP pour extension domaine PIM", 15 | "export": [ 16 | "EXPORT-ALL-MULTICAST-SOURCES", "default-reject" 17 | ], 18 | "family": "ipv4", 19 | "import": ["default-reject"], 20 | "loop-detect": "discard-route", 21 | "name": "IP", 22 | "neighbor": { 23 | "description": "PTN00115_IP", 24 | "neighbor-id": "79.92.218.245" 25 | }, 26 | "peer-as": "65500", 27 | "ttl-security": "255", 28 | "type": "external" 29 | }, { 30 | "description": "acces pour Flux", 31 | "export": [ 32 | "EXPORT-ALL-SOURCES", "default-reject" 33 | ], 34 | "family": "ipv4", 35 | "import": [ 36 | "COLLECTE-IPv4-IMPORT", "default-accept-bgp" 37 | ], 38 | "loop-detect": "discard-route", 39 | "name": "EBGP", 40 | "neighbor": { 41 | "description": "PAR38-W01-AGR-IP", 42 | "neighbor-id": "78.197.9.157", 43 | "peer-as": "65510" 44 | }, 45 | "peer-as": "65500", 46 | "preference": "9", 47 | "ttl-security": "255", 48 | "type": "external" 49 | } 50 | ], 51 | "ibgp-multipath": true, 52 | "next-hop-resolution": { 53 | "policy": "NEXT-HOP-TRACKING", 54 | "shortcut-tunnel": { 55 | "family": [ 56 | { 57 | "resolution-filter": { 58 | "type": "ldp" 59 | }, 60 | "type": "ipv4" 61 | }, {} 62 | ] 63 | } 64 | }, 65 | "peer-tracking-policy": "PEER-TRACKING", 66 | "rib-management": { 67 | "ipv6": { 68 | "route-table-import": "RIB_LEAK" 69 | }, 70 | "label-ipv6": { 71 | "route-table-import": "RIB_LEAK" 72 | } 73 | } 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/router_policy_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "router": { 4 | "policy": { 5 | "policy-statement": [ 6 | { 7 | "default-action": "reject", 8 | "entry-list": { 9 | "action": {}, 10 | "entry-id": "10", 11 | "from": { 12 | "from": "prefix-list accept-7750-SR" 13 | } 14 | }, 15 | "name": "ldp-accept" 16 | }, { 17 | "default-action": "reject", 18 | "entry-list": [ 19 | { 20 | "action": { 21 | "addons": "type 1" 22 | }, 23 | "description": "advertise direct connect interfaces", 24 | "entry-id": "10", 25 | "from": { 26 | "from": "protocol direct" 27 | }, 28 | "to": { 29 | "to": "protocol ospf" 30 | } 31 | }, { 32 | "action": { 33 | "addons": "type 1" 34 | }, 35 | "description": "advertise static routes", 36 | "entry-id": "20", 37 | "from": { 38 | "from": "protocol static" 39 | }, 40 | "to": { 41 | "to": "protocol ospf" 42 | } 43 | } 44 | ], 45 | "name": "br-ospf-export" 46 | }, { 47 | "default-action": "reject", 48 | "entry-list": [ 49 | { 50 | "action": { 51 | "addons": "type 1" 52 | }, 53 | "description": "advertise direct connect interfaces", 54 | "entry-id": "10", 55 | "from": { 56 | "from": "protocol direct" 57 | }, 58 | "to": { 59 | "to": "protocol ospf3" 60 | } 61 | }, { 62 | "action": { 63 | "addons": "type 1" 64 | }, 65 | "description": "advertise static routes", 66 | "entry-id": "20", 67 | "from": { 68 | "from": "protocol static" 69 | }, 70 | "to": { 71 | "to": "protocol ospf3" 72 | } 73 | } 74 | ], 75 | "name": "br-ospf3-export" 76 | } 77 | ], 78 | "prefix-list": { 79 | "name": "accept-7750-SR", 80 | "prefix-list_cfg": "prefix 10.114.45.0/32 exact\nprefix 10.114.45.1/32 exact" 81 | } 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/subscriber_mgmt_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "subscriber-mgmt": { 4 | "authentication-policy": { 5 | "description": "Radius Authentification par defaut", 6 | "hash": "hash2", 7 | "include-radius-attribute": { 8 | "access-loop-options": true, 9 | "circuit-id": true, 10 | "dhcp-options": true, 11 | "dhcp6-options": true, 12 | "mac-address": true, 13 | "nas-identifier": true, 14 | "nas-port-id": true, 15 | "remote-id": true 16 | }, 17 | "name": "AUTH-DEF", 18 | "paswword": "netconanRemoved7", 19 | "pppoe-access-method": "none", 20 | "radius-authentication-server": {}, 21 | "user-name-format": "circuit-id" 22 | }, 23 | "auto-sub-id-key": { 24 | "ipoe-sub-id-key": "mac" 25 | }, 26 | "ipoe-session-policy": { 27 | "description": "IPoE Session policy par defaut", 28 | "name": "IPOE-DEF", 29 | "session-key": "sap,mac,cid" 30 | }, 31 | "local-user-db": [ 32 | { 33 | "name": "AAA-DHCP-RED" 34 | }, { 35 | "name": "AAA-PPP-RED" 36 | }, { 37 | "name": "SRV-DHCP-LOCAL" 38 | }, { 39 | "name": "AAA-DHCP" 40 | } 41 | ], 42 | "ppp-policy": { 43 | "description": "PPPoE", 44 | "max-sessions-per-mac": "2", 45 | "name": "PPP", 46 | "ppp-authentication": "chap", 47 | "ppp-mtu": "1492" 48 | }, 49 | "radius-accounting-policy": { 50 | "description": "Radius", 51 | "include-radius-attribute": { 52 | "access-loop-options": true, 53 | "acct-authentic": true, 54 | "circuit-id": true, 55 | "delegated-ipv6-prefix": true, 56 | "detailed-acct-attributes": false, 57 | "framed-ip-addr": true, 58 | "mac-address": true, 59 | "nas-identifier": true, 60 | "nas-port-id": true, 61 | "remote-id": true, 62 | "sla-profile": true, 63 | "std-acct-attributes": true, 64 | "sub-profile": true, 65 | "subscriber-id": true, 66 | "user-name": true 67 | }, 68 | "name": "ACCT-DEF", 69 | "queue-instance-accounting": false, 70 | "radius-server-policy": "RADIUS-ACCT-DEF", 71 | "session-accounting": "interim-update", 72 | "session-id-format": "number" 73 | }, 74 | "sla-profile": { 75 | "name": "QOS-DEFAUT-PROF" 76 | }, 77 | "sub-ident-policy": { 78 | "name": "COLLECTE", 79 | "sla-profile-map": { 80 | "use-direct-map-as-default": true 81 | }, 82 | "sub-profile-map": { 83 | "use-direct-map-as-default": true 84 | } 85 | }, 86 | "sub-profile": { 87 | "name": "MIGR", 88 | "radius-accounting": { 89 | "policy": "ACCT-RED" 90 | } 91 | } 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/subscriber_mgmt_ss_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "subscriber-mgmt": { 4 | "authentication-policy": { 5 | "name": "RADIUS", 6 | "radius-authentication-server": { 7 | "address": "195.85.40.20", 8 | "hashing-scheme": "hash2", 9 | "port": "1645", 10 | "router": "Base", 11 | "secret": "netconanRemoved18", 12 | "server-id": "1" 13 | } 14 | }, 15 | "local-user-db": { 16 | "name": "AAA-DHCP", 17 | "protocol": { 18 | "host": [ 19 | { 20 | "admin-state": true, 21 | "auth-policy": "AUTH-COLL-ETH-RED", 22 | "host-name": "default", 23 | "server": "195.85.40.22" 24 | }, { 25 | "admin-state": true, 26 | "auth-policy": "AUTH-MIGR", 27 | "host-identification": { 28 | "option60-string": "toto" 29 | }, 30 | "host-name": "IAD-Profil", 31 | "server": "218.152.120.74" 32 | } 33 | ], 34 | "match-list": "option60", 35 | "type": "ipoe" 36 | } 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/system_begin.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/system_cards.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "card": [ 4 | { 5 | "card-type": "imm-2pac-fp3", 6 | "fail-on-error": true, 7 | "mda": { 8 | "admin-state": true, 9 | "egress-xpl": { 10 | "window": "10" 11 | }, 12 | "fail-on-error": true, 13 | "ingress-xpl": { 14 | "window": "10" 15 | }, 16 | "mda-slot": "1", 17 | "mda-type": "p10-10g-sfp" 18 | }, 19 | "slot-number": "2" 20 | }, { 21 | "card-type": "imm5-10gb-xfp", 22 | "fail-on-error": true, 23 | "mda": { 24 | "admin-state": false, 25 | "fail-on-error": true, 26 | "mda-slot": "1" 27 | }, 28 | "slot-number": "4" 29 | } 30 | ] 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/system_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "system": { 4 | "contact": "Hugo Tinoco", 5 | "location": "Phoenix, AZ", 6 | "name": "EXAMPLEPHX-P-AL-7750-01", 7 | "rollback": { 8 | "cf_slot": "cf2", 9 | "directory": "Rollback", 10 | "rollback": true 11 | }, 12 | "snmp": { 13 | "packet_size": "9216" 14 | }, 15 | "time": { 16 | "ntp": [ 17 | { 18 | "server": [ 19 | { 20 | "ip-address": "8.8.8.8", 21 | "prefer": true 22 | }, { 23 | "ip-address": "8.8.4.4" 24 | } 25 | ] 26 | }, { 27 | "admin_state": true, 28 | "authentication-check": false, 29 | "dst-zone": { 30 | "end": { 31 | "day": "sunday", 32 | "hours-minute": "02:00", 33 | "month": "november", 34 | "week": "first" 35 | }, 36 | "start": { 37 | "day": "sunday", 38 | "hours-minute": "02:00", 39 | "month": "march", 40 | "week": "second" 41 | }, 42 | "summer-time-zone": "MDT" 43 | }, 44 | "zone": { 45 | "standard": { 46 | "name": "MST" 47 | } 48 | } 49 | } 50 | ], 51 | "sntp": { 52 | "admin_state": false 53 | } 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/system_interface.json: -------------------------------------------------------------------------------- 1 | { 2 | "router": { 3 | "interface": { 4 | "admin_state": true, 5 | "ingress_stats": true, 6 | "interface_name": "system", 7 | "ipv4": { 8 | "primary": { 9 | "address": "199.199.9.1", 10 | "prefix_length": "32" 11 | } 12 | }, 13 | "ipv6": { 14 | "address": { 15 | "ipv6_address": "2001:1111:3333:0:420:2a0::", 16 | "prefix_length": "128" 17 | } 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/system_maf.json: -------------------------------------------------------------------------------- 1 | { 2 | "system": { 3 | "management-access-filter": [ 4 | { 5 | "ip-filter-params": { 6 | "admin-state": true, 7 | "default-action": "deny", 8 | "ipv4-filter": true 9 | }, 10 | "ipv6-filter-params": { 11 | "admin-state": false, 12 | "default-action": "permit", 13 | "ipv6-filter": true 14 | } 15 | }, { 16 | "ip-filter": { 17 | "entry": [ 18 | { 19 | "action": "permit", 20 | "description": "SSH Traffic", 21 | "dst-port": "22 22", 22 | "entry-id": "10", 23 | "protocol": "tcp", 24 | "router-instance": "management" 25 | }, { 26 | "action": "permit", 27 | "description": "Some Syslog Server", 28 | "entry-id": "25", 29 | "router-instance": "management" 30 | } 31 | ] 32 | } 33 | }, { 34 | "ipv6-filter": { 35 | "entry": [ 36 | { 37 | "action-instance": "permit", 38 | "description": "SSH Traffic", 39 | "dst-port": "22 22", 40 | "entry-id": "10", 41 | "router-instance": "management" 42 | }, { 43 | "action-instance": "permit", 44 | "description": "Something Something Something", 45 | "entry-id": "25", 46 | "router-instance": "management", 47 | "src-ip": "1001:2000:a06:2130:f0:fef:0:147/128" 48 | } 49 | ] 50 | } 51 | } 52 | ] 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/system_profiles.json: -------------------------------------------------------------------------------- 1 | { 2 | "system": { 3 | "profile": [ 4 | { 5 | "default-action": "deny-all", 6 | "entry": [ 7 | { 8 | "action": "permit", 9 | "match": "back" 10 | }, { 11 | "action": "permit", 12 | "match": "exit" 13 | } 14 | ], 15 | "user-profile-name": "readonly" 16 | }, { 17 | "default-action": "permit-all", 18 | "entry": [ 19 | { 20 | "action": "deny", 21 | "match": "configure system security" 22 | }, { 23 | "action": "permit", 24 | "match": "show system security" 25 | } 26 | ], 27 | "user-profile-name": "administrative" 28 | }, { 29 | "default-action": "permit-all", 30 | "entry": [ 31 | { 32 | "action": "deny", 33 | "match": "configure system security" 34 | }, { 35 | "action": "permit", 36 | "match": "show system security" 37 | } 38 | ], 39 | "user-profile-name": "Test Profile 69" 40 | } 41 | ] 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/system_security_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "system": { 4 | "security": { 5 | "cpm-filter": [ 6 | { 7 | "ip-filter": { 8 | "admin_state": false 9 | }, 10 | "ipv6-filter": { 11 | "admin_state": false 12 | } 13 | }, {} 14 | ] 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/system_time_ntp_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "system": { 4 | "ntp": { 5 | "server": { 6 | "address": [ 7 | "10.114.45.0 prefer", 8 | "10.114.45.1", 9 | "1 name \"RADIUS-ACCT\"", 10 | "1 name \"RADIUS-AUTH\"", 11 | "1 address 195.85.40.20 secret \"netconanRemoved18\" hash2 port 1645" 12 | ] 13 | } 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/twamp_light_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "router": { 4 | "twamp_light": { 5 | "reflector": { 6 | "admin_state": true, 7 | "description": "Reflecteur TWAMP", 8 | "prefix": [ 9 | { 10 | "description": "sonde twamp sur zip intf eth5", 11 | "prefix": "10.185.13.74/32" 12 | }, { 13 | "description": "sonde twamp sur zip intf eth6", 14 | "prefix": "10.185.13.78/32" 15 | } 16 | ], 17 | "udp_port": "64364" 18 | } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/admin_display/vrrp_configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "configure": { 3 | "vrrp": { 4 | "policy": [ 5 | { 6 | "delta-in-use-limit": "100", 7 | "id": "1106", 8 | "priority-event": { 9 | "lag-port-down": { 10 | "hold-clear": "180", 11 | "id": "36", 12 | "number-down": { 13 | "id": "1", 14 | "priority": "100" 15 | } 16 | } 17 | } 18 | }, { 19 | "delta-in-use-limit": "100", 20 | "id": "4065", 21 | "priority-event": { 22 | "lag-port-down": { 23 | "hold-clear": "180", 24 | "id": "243", 25 | "number-down": { 26 | "id": "1", 27 | "priority": "100" 28 | } 29 | } 30 | } 31 | } 32 | ] 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/show_cmds/file_dir.json: -------------------------------------------------------------------------------- 1 | { 2 | "cf-contents": { 3 | "directory": { 4 | "cf-card": "cf3", 5 | "count": { 6 | "bytes-free": "789516288", 7 | "bytes-used": "14330", 8 | "total-dirs": "5", 9 | "total-files": "7" 10 | }, 11 | "directories": [ 12 | { 13 | "DIR": true, 14 | "date": "11/06/2020", 15 | "directory": ".ssh/", 16 | "time": "06:52a" 17 | }, 18 | { 19 | "DIR": true, 20 | "date": "06/17/2020", 21 | "directory": "SYSLINUX/", 22 | "time": "02:06p" 23 | }, 24 | { 25 | "DIR": true, 26 | "date": "06/17/2020", 27 | "directory": "TIMOS/", 28 | "time": "02:06p" 29 | }, 30 | { 31 | "DIR": true, 32 | "date": "12/30/2020", 33 | "directory": "certs/", 34 | "time": "06:32p" 35 | }, { 36 | "DIR": true, 37 | "date": "11/13/2020", 38 | "directory": "system-pki/", 39 | "time": "02:17a" 40 | } 41 | ], 42 | "files": [ 43 | { 44 | "date": "06/17/2020", 45 | "filename": "CONFIG.CFG", 46 | "size": "0", 47 | "time": "02:06p" 48 | }, 49 | { 50 | "date": "06/17/2020", 51 | "filename": "NVRAM.DAT", 52 | "size": "101", 53 | "time": "02:06p" 54 | }, 55 | { 56 | "date": "11/14/2020", 57 | "filename": "bof.cfg", 58 | "size": "682", 59 | "time": "02:53a" 60 | }, 61 | { 62 | "date": "12/26/2020", 63 | "filename": "bootlog.txt", 64 | "size": "6614", 65 | "time": "02:39p" 66 | }, { 67 | "date": "12/26/2020", 68 | "filename": "bootlog_prev.txt", 69 | "size": "6614", 70 | "time": "02:35p" 71 | }, { 72 | "date": "12/26/2020", 73 | "filename": "nvsys.info", 74 | "size": "317", 75 | "time": "02:38p" 76 | }, { 77 | "date": "12/26/2020", 78 | "filename": "restcntr.txt", 79 | "size": "2", 80 | "time": "02:38p" 81 | } 82 | ] 83 | }, 84 | "volume": [ 85 | { 86 | "slot": "A", 87 | "volume": "in drive cf3 on slot A is SROS VM." 88 | }, { 89 | "slot": "A", 90 | "volume": "in drive cf3 on slot A is formatted as FAT32" 91 | } 92 | ] 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/show_cmds/show_bof.json: -------------------------------------------------------------------------------- 1 | { 2 | "bof": { 3 | "address": [ 4 | { 5 | "address": "192.168.1.1", 6 | "prefix-length": "23" 7 | }, { 8 | "address": "1001:1000:2a65:2000:0FA:413::6", 9 | "prefix-length": "64" 10 | } 11 | ], 12 | "autonegotiate": true, 13 | "console-speed": "115200", 14 | "dns-domain": "admin-save.com", 15 | "duplex": "full", 16 | "image": { 17 | "cf-card": "cf3", 18 | "primary-image": "7705-TiMOS-9.0.R9" 19 | }, 20 | "persist": "off", 21 | "primary-config": { 22 | "cf-card": "cf3", 23 | "primary-config": "EXAMPLEPHX-P-AL-7705-01.txt.cfg" 24 | }, 25 | "primary-dns": "192.168.1.1", 26 | "secondary-dns": "8.8.8.8", 27 | "speed": "100", 28 | "static-route": [ 29 | { 30 | "network": "0.0.0.0/1", 31 | "next-hop": "192.168.100.1" 32 | }, { 33 | "network": "128.0.0.0/1", 34 | "next-hop": "192.168.100.1" 35 | }, { 36 | "network": "1001:1000:0A00::/40", 37 | "next-hop": "1001:1000:2a69:2000:0FA:420::FFFF" 38 | }, { 39 | "network": "1001:1000:2A00::/40", 40 | "next-hop": "1001:1000:2a69:2000:0FA:420::FFFF" 41 | } 42 | ], 43 | "wait": "3" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/show_cmds/show_router_route_table.json: -------------------------------------------------------------------------------- 1 | { 2 | "show_route_table": { 3 | "instance": "Base", 4 | "route_table": "Route Table", 5 | "router": "Router", 6 | "routes": [ 7 | { 8 | "age": "00h08m58s", 9 | "dest_prefix": "10.1.3.0/24", 10 | "pref": "0", 11 | "protocol": "Local", 12 | "type": "Local" 13 | }, 14 | { 15 | "metric": "0", 16 | "next_hop": "TO_R1" 17 | }, 18 | { 19 | "age": "00h08m58s", 20 | "dest_prefix": "10.3.4.0/24", 21 | "pref": "0", 22 | "protocol": "Local", 23 | "type": "Local" 24 | }, 25 | { 26 | "metric": "0", 27 | "next_hop": "TO_R4" 28 | }, { 29 | "age": "00h08m58s", 30 | "dest_prefix": "10.3.8.0/24", 31 | "pref": "0", 32 | "protocol": "Local", 33 | "type": "Local" 34 | }, { 35 | "metric": "0", 36 | "next_hop": "TO_IOSXR" 37 | }, { 38 | "age": "00h10m04s", 39 | "dest_prefix": "10.10.10.3/32", 40 | "pref": "0", 41 | "protocol": "Local", 42 | "type": "Local" 43 | }, { 44 | "metric": "0", 45 | "next_hop": "system" 46 | } 47 | ], 48 | "total_count": { 49 | "count": "4" 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/show_cmds/show_service_service_using.json: -------------------------------------------------------------------------------- 1 | { 2 | "service-using": { 3 | "count": { 4 | "total-services": "3" 5 | }, 6 | "services": [ 7 | { 8 | "admin-state": "Down", 9 | "customer-id": "1", 10 | "operational-state": "Down", 11 | "service-id": "100", 12 | "service-name": "100", 13 | "service-type": "VPRN" 14 | }, { 15 | "admin-state": "Up", 16 | "customer-id": "1", 17 | "operational-state": "Down", 18 | "service-id": "2147483648", 19 | "service-name": "_tmnx_InternalIesService", 20 | "service-type": "IES" 21 | }, { 22 | "admin-state": "Up", 23 | "customer-id": "1", 24 | "operational-state": "Down", 25 | "service-id": "2147483649", 26 | "service-name": "_tmnx_InternalVplsService", 27 | "service-type": "intVpls" 28 | } 29 | ] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/show_cmds/show_static_route_v4.json: -------------------------------------------------------------------------------- 1 | { 2 | "static_route": { 3 | "ipv4": { 4 | "count": { 5 | "total_routes": "3" 6 | }, 7 | "entry": [ 8 | { 9 | "active": "Y", 10 | "ipaddress": "10.115.5.0/24", 11 | "metric": "1", 12 | "preference": "5", 13 | "tag": "1000", 14 | "type": "BH" 15 | }, { 16 | "active": "Y", 17 | "ipaddress": "10.115.46.0/24", 18 | "metric": "1", 19 | "preference": "5", 20 | "tag": "1000", 21 | "type": "BH" 22 | }, { 23 | "active": "Y", 24 | "ipaddress": "10.119.238.0/24", 25 | "metric": "1", 26 | "preference": "5", 27 | "tag": "1000", 28 | "type": "BH" 29 | } 30 | ] 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tests/fixtures/parsed_results/show_cmds/show_static_route_v6.json: -------------------------------------------------------------------------------- 1 | { 2 | "static_route": { 3 | "ipv6": { 4 | "count": { 5 | "total-routes": "3" 6 | }, 7 | "entry": [ 8 | { 9 | "active": "Y", 10 | "ipaddress": "2001:4888:26f:4500::/56", 11 | "metric": "1", 12 | "next-hop": { 13 | "interface": "n/a", 14 | "next-hop": "n/a" 15 | }, 16 | "preference": "5", 17 | "tag": "1000", 18 | "type": "BH" 19 | }, { 20 | "active": "Y", 21 | "ipaddress": "2001:4888:2000:0:646:2a0::/112", 22 | "metric": "1", 23 | "next-hop": { 24 | "interface": "n/a", 25 | "next-hop": "n/a" 26 | }, 27 | "preference": "5", 28 | "tag": "1000", 29 | "type": "BH" 30 | }, { 31 | "active": "Y", 32 | "ipaddress": "2001:4888:2062::/52", 33 | "metric": "1", 34 | "next-hop": { 35 | "interface": "n/a", 36 | "next-hop": "n/a" 37 | }, 38 | "preference": "5", 39 | "tag": "1000", 40 | "type": "BH" 41 | } 42 | ] 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/fixtures/show_output/file_dir.txt: -------------------------------------------------------------------------------- 1 | A:vSIM# file dir 2 | 3 | Volume in drive cf3 on slot A is SROS VM. 4 | 5 | Volume in drive cf3 on slot A is formatted as FAT32 6 | 7 | Directory of cf3:\ 8 | 9 | 11/06/2020 06:52a .ssh/ 10 | 06/17/2020 02:06p 0 CONFIG.CFG 11 | 06/17/2020 02:06p 101 NVRAM.DAT 12 | 06/17/2020 02:06p SYSLINUX/ 13 | 06/17/2020 02:06p TIMOS/ 14 | 11/14/2020 02:53a 682 bof.cfg 15 | 12/26/2020 02:39p 6614 bootlog.txt 16 | 12/26/2020 02:35p 6614 bootlog_prev.txt 17 | 12/30/2020 06:32p certs/ 18 | 12/26/2020 02:38p 317 nvsys.info 19 | 12/26/2020 02:38p 2 restcntr.txt 20 | 11/13/2020 02:17a system-pki/ 21 | 7 File(s) 14330 bytes. 22 | 5 Dir(s) 789516288 bytes free. -------------------------------------------------------------------------------- /tests/fixtures/show_output/show_bof.txt: -------------------------------------------------------------------------------- 1 | *A:R1-SANDBOX# show bof 2 | =============================================================================== 3 | BOF (Memory) 4 | =============================================================================== 5 | primary-image cf3:\7705-TiMOS-9.0.R9\ 6 | primary-config cf3:\EXAMPLEPHX-P-AL-7705-01.txt.cfg 7 | address 192.168.1.1/23 active 8 | address 1001:1000:2a65:2000:0FA:413::6/64 active 9 | primary-dns 192.168.1.1 10 | secondary-dns 8.8.8.8 11 | dns-domain admin-save.com 12 | static-route 0.0.0.0/1 next-hop 192.168.100.1 13 | static-route 128.0.0.0/1 next-hop 192.168.100.1 14 | static-route 1001:1000:0A00::/40 next-hop 1001:1000:2a69:2000:0FA:420::FFFF 15 | static-route 1001:1000:2A00::/40 next-hop 1001:1000:2a69:2000:0FA:420::FFFF 16 | autonegotiate 17 | duplex full 18 | speed 100 19 | wait 3 20 | persist off 21 | no li-local-save 22 | no li-separate 23 | no fips-140-2 24 | console-speed 115200 25 | =============================================================================== 26 | -------------------------------------------------------------------------------- /tests/fixtures/show_output/show_route_table.txt: -------------------------------------------------------------------------------- 1 | =============================================================================== 2 | Route Table (Router: Base) 3 | =============================================================================== 4 | Dest Prefix[Flags] Type Proto Age Pref 5 | Next Hop[Interface Name] Metric 6 | ------------------------------------------------------------------------------- 7 | 10.1.3.0/24 Local Local 00h08m58s 0 8 | TO_R1 0 9 | 10.3.4.0/24 Local Local 00h08m58s 0 10 | TO_R4 0 11 | 10.3.8.0/24 Local Local 00h08m58s 0 12 | TO_IOSXR 0 13 | 10.10.10.3/32 Local Local 00h10m04s 0 14 | system 0 15 | ------------------------------------------------------------------------------- 16 | No. of Routes: 4 17 | Flags: n = Number of times nexthop is repeated 18 | B = BGP backup route available 19 | L = LFA nexthop available 20 | S = Sticky ECMP requested 21 | =============================================================================== 22 | -------------------------------------------------------------------------------- /tests/fixtures/show_output/show_router_interface.txt: -------------------------------------------------------------------------------- 1 | *A:TEMPE-AZ-HUB-EXAMPLE-7750-01>config>service>ies>if>ipv6>vrrp# show router interface 2 | 3 | =============================================================================== 4 | Interface Table (Router: Base) 5 | =============================================================================== 6 | Interface-Name Adm Opr(v4/v6) Mode Port/SapId 7 | IP-Address PfxState 8 | ------------------------------------------------------------------------------- 9 | L3-TELCO-IXR01-1 Up Down/Down IES lag-1:300 10 | 2001:1000:2062:357a:646:100:0:1/64 INACCESSIBLE 11 | 2001:1666:2062:357a:646:100:0:1/64 INACCESSIBLE 12 | fe80::645:100:0:1/64 INACCESSIBLE 13 | L3-TELCO-IXR02-1 Up Down/Up IES lag-2:300 14 | 2001:1666:2062:4222:649:100:0:1/64 PREFERRED 15 | fe80::645:100:0:1/64 PREFERRED 16 | L3-TELCO-eNodeB0420-DUL-01 Up Up/Up IES 1/1/c2/1:301 17 | 10.0.0.0/31 n/a 18 | 2001:1000:2062:24ae:649:100::/64 PREFERRED 19 | fe80::c8:ffff:fe00:0/64 PREFERRED 20 | system Up Up/Up Network system 21 | 10.100.43.69/32 n/a 22 | 2001:4777:2062:2000:645:100:0:19f/128 PREFERRED 23 | to-7750-01 Up Up/Up Network 1/1/c4/1:3415 24 | 172.20.200.69/31 n/a 25 | 2001:1666:206a:335d:645:100:0:1/64 PREFERRED 26 | fe80::c8:ffff:fe00:0/64 PREFERRED 27 | to-BTS0420-7750-H2 Up Down/Down Network lag-11:4094 28 | 172.20.200.1/31 n/a 29 | 2001:1666:206a:335f:645:100::/64 INACCESSIBLE 30 | fe80::c8:ffff:fe00:14b/64 INACCESSIBLE 31 | ------------------------------------------------------------------------------- 32 | Interfaces : 6 33 | =============================================================================== 34 | -------------------------------------------------------------------------------- /tests/fixtures/show_output/show_router_static_route_tag.txt: -------------------------------------------------------------------------------- 1 | =============================================================================== 2 | Static Route Table (Router: Base) Family: IPv4 3 | =============================================================================== 4 | Prefix Tag Met Pref Type Act 5 | Next Hop Interface 6 | ------------------------------------------------------------------------------- 7 | 10.115.5.0/24 1000 1 5 BH Y 8 | n/a n/a 9 | 10.115.46.0/24 1000 1 5 BH Y 10 | n/a n/a 11 | 10.119.238.0/24 1000 1 5 BH Y 12 | n/a n/a 13 | ------------------------------------------------------------------------------- 14 | No. of Static Routes: 3 15 | =============================================================================== 16 | -------------------------------------------------------------------------------- /tests/fixtures/show_output/show_router_static_route_tag_v6.txt: -------------------------------------------------------------------------------- 1 | =============================================================================== 2 | Static Route Table (Router: Base) Family: IPv6 3 | =============================================================================== 4 | Prefix Tag Met Pref Type Act 5 | Next Hop Interface 6 | ------------------------------------------------------------------------------- 7 | 2001:4888:26f:4500::/56 1000 1 5 BH Y 8 | n/a n/a 9 | 2001:4888:2000:0:646:2a0::/112 1000 1 5 BH Y 10 | n/a n/a 11 | 2001:4888:2062::/52 1000 1 5 BH Y 12 | n/a n/a 13 | ------------------------------------------------------------------------------- 14 | No. of Static Routes: 3 15 | =============================================================================== 16 | -------------------------------------------------------------------------------- /tests/fixtures/show_output/show_router_vrf_route_table.txt: -------------------------------------------------------------------------------- 1 | A:PHOENIX-P-AL-7750-02# show router 4 route-table 2 | 3 | =============================================================================== 4 | Route Table (Service: 4) 5 | =============================================================================== 6 | Dest Prefix[Flags] Type Proto Age Pref 7 | Next Hop[Interface Name] Metric 8 | ------------------------------------------------------------------------------- 9 | 0.0.0.0/0 Remote Static 0314d23h 5 10 | 10.141.37.1 1 11 | 10.90.164.0/29 Remote OSPF 0181d22h 150 12 | 10.203.13.252 1 13 | 10.203.13.244/31 Local Local 19d08h06m 0 14 | L3-EDN-BTS0270 0 15 | 10.203.13.246/31 Local Local 0203d22h 0 16 | L3-EDN-BTS0272 0 17 | 10.203.13.252/31 Local Local 0314d23h 0 18 | L3-VLAN460 0 19 | 10.249.204.190/32 Remote OSPF 0314d23h 10 20 | 10.203.13.252 25 21 | 10.249.204.191/32 Local Local 0314d23h 0 22 | loopback 0 23 | ------------------------------------------------------------------------------- 24 | No. of Routes: 468 25 | Flags: n = Number of times nexthop is repeated 26 | B = BGP backup route available 27 | L = LFA nexthop available 28 | S = Sticky ECMP requested 29 | =============================================================================== 30 | -------------------------------------------------------------------------------- /tests/fixtures/show_output/show_router_vrf_static_route_tag.txt: -------------------------------------------------------------------------------- 1 | A:PHOENIX-P-AL-7750-02# show router 3 static-route tag 100 2 | 3 | =============================================================================== 4 | Static Route Table (Service: 3) Family: IPv4 5 | =============================================================================== 6 | Prefix Tag Met Pref Type Act 7 | Next Hop Interface 8 | ------------------------------------------------------------------------------- 9 | 10.122.38.0/23 100 1 5 BH Y 10 | n/a n/a 11 | 10.122.74.0/23 100 1 5 BH Y 12 | n/a n/a 13 | 10.204.204.0/24 100 1 5 BH Y 14 | n/a n/a 15 | 10.205.83.128/26 100 1 5 NH Y 16 | 10.205.83.228 L3-VLAN341 17 | 10.205.83.192/27 100 1 5 NH Y 18 | 10.205.83.244 L3-VLAN347 19 | 10.221.148.0/23 100 1 5 BH Y 20 | n/a n/a 21 | 10.221.178.0/23 100 1 5 BH Y 22 | n/a n/a 23 | 10.221.180.0/23 100 1 5 BH Y 24 | n/a n/a 25 | 10.224.154.0/23 100 1 5 BH Y 26 | n/a n/a 27 | 10.248.252.128/26 100 1 5 BH Y 28 | n/a n/a 29 | 151.144.46.128/26 100 1 5 NH N 30 | 151.144.246.4 n/a 31 | 151.144.46.192/26 100 1 5 NH N 32 | 151.144.246.5 n/a 33 | ------------------------------------------------------------------------------- 34 | No. of Static Routes: 12 35 | =============================================================================== -------------------------------------------------------------------------------- /tests/fixtures/show_output/show_service_service_using.txt: -------------------------------------------------------------------------------- 1 | *A:vSIM>config>service>vprn$ show service service-using 2 | 3 | =============================================================================== 4 | Services 5 | =============================================================================== 6 | ServiceId Type Adm Opr CustomerId Service Name 7 | ------------------------------------------------------------------------------- 8 | 100 VPRN Down Down 1 100 9 | 2147483648 IES Up Down 1 _tmnx_InternalIesService 10 | 2147483649 intVpls Up Down 1 _tmnx_InternalVplsService 11 | ------------------------------------------------------------------------------- 12 | Matching Services : 3 13 | ------------------------------------------------------------------------------- 14 | =============================================================================== -------------------------------------------------------------------------------- /tests/readme.txt: -------------------------------------------------------------------------------- 1 | How to setup tests by importing ttp_templates: 2 | 3 | - Create the template following the guidelines which mimic the NTC Templates testing. 4 | for example, for the sros devices: 5 | 6 | result = parse_output( 7 | data=data, 8 | platform="sros", 9 | command="admin display router interfaces" 10 | ) 11 | 12 | The templates must exist and follow the platform naming 'sros_admin_display_router_interfaces.txt' 13 | and be put into the ttp_template folder after doing a pip3 install ttp_templats -------------------------------------------------------------------------------- /tests/unit/test_7750_only.py: -------------------------------------------------------------------------------- 1 | """Test specific 7750 configurations.""" 2 | 3 | 4 | def test_get_connectors(sros_parser_7750, parsed_connectors): 5 | """ 6 | Test extracting connector ports. 7 | """ 8 | result = sros_parser_7750.get_connectors() 9 | assert result == parsed_connectors 10 | 11 | 12 | def test_get_lags(sros_parser_7750, parsed_lags): 13 | """ 14 | Test extracting connector ports. 15 | """ 16 | result = sros_parser_7750.get_lags() 17 | assert result == parsed_lags 18 | 19 | 20 | def test_get_lsps(sros_parser_7750_R3, parsed_lsps): 21 | """ 22 | Test extracting MPLS LSPs. 23 | """ 24 | result = sros_parser_7750_R3.get_lsps() 25 | assert result == parsed_lsps 26 | 27 | 28 | def test_get_lags_group2(sros_parser_7750_R2, parsed_lags_1): 29 | """ 30 | Test extracting connector ports. 31 | """ 32 | result = sros_parser_7750_R2.get_lags() 33 | assert result == parsed_lags_1 34 | assert len(result["configure"]["lag"]) == 6 35 | assert result["configure"]["lag"][5]["name"] == "myLag105" 36 | 37 | 38 | # add testting for get_python_declaration_configuration 39 | def test_get_python_declaration_configuration(sros_parser_7750, parsed_python_declaration): 40 | """ 41 | Test extracting python declaration configuration. 42 | """ 43 | result = sros_parser_7750.get_python_declaration_configuration() 44 | assert result == parsed_python_declaration 45 | 46 | 47 | # add testting for get_python_configuration 48 | def test_get_python_configuration(sros_parser_7750, parsed_python_configuration): 49 | """ 50 | Test extracting python configuration. 51 | """ 52 | result = sros_parser_7750.get_python_configuration() 53 | assert result == parsed_python_configuration 54 | -------------------------------------------------------------------------------- /tests/unit/test_helpers.py: -------------------------------------------------------------------------------- 1 | """Test Helper Functions.""" 2 | import pytest 3 | 4 | from ttp_sros_parser.helpers import check_file, globfindfile 5 | 6 | 7 | def test_globfindfile_no_match(): 8 | """Test Failure.""" 9 | with pytest.raises(SystemExit) as exit_err: 10 | globfindfile(r"*.xyz") 11 | assert exit_err.value.code == "No *.xyz file found." 12 | 13 | 14 | def test_check_file_success(): 15 | """Test success.""" 16 | res = check_file("tests/fixtures/configs/example-config-7750.txt") 17 | assert res == "tests/fixtures/configs/example-config-7750.txt" 18 | 19 | 20 | def test_value_error(): 21 | """Test fail wrong extension.""" 22 | with pytest.raises(ValueError) as val_err: 23 | check_file("test.py") 24 | assert str(val_err.value) == "test.py must end with '.cfg', '.txt' or '.log'" 25 | 26 | 27 | def test_sys_exit_no_path(): 28 | """Test fail wrong path.""" 29 | with pytest.raises(SystemExit) as sys_err: 30 | check_file("test/some_config.cfg") 31 | assert str(sys_err.value) == "test/some_config.cfg doesn't exist." 32 | -------------------------------------------------------------------------------- /tests/unit/test_srosparser_methods.py: -------------------------------------------------------------------------------- 1 | """Test available methods and generate an update to the readmedocs.""" 2 | 3 | 4 | def test_methods(sros_parser_7750): 5 | """ 6 | Test extracting methods from class. 7 | """ 8 | methods = [m for m in dir(sros_parser_7750) if m.startswith(("show", "get"))] 9 | with open("docs/methods.md", "w") as methd: 10 | methd.write("```" + "\n") 11 | for x in methods: 12 | methd.write(f"{x}\n") 13 | methd.write("```" + "\n") 14 | 15 | assert len(methods) == 56 16 | -------------------------------------------------------------------------------- /tests/unit/test_ttp_sros_show_outputs.py: -------------------------------------------------------------------------------- 1 | """Test show command output parsing.""" 2 | from ttp_sros_parser.srosparser import SrosParser 3 | 4 | 5 | def test_file_dir_output(parsed_show_file_dir): 6 | """ 7 | Test parsing file dir output 8 | """ 9 | data = "tests/fixtures/show_output/file_dir.txt" 10 | parser = SrosParser(data) 11 | result = parser.show_file_dir() 12 | assert result == parsed_show_file_dir 13 | 14 | 15 | def test_get_show_bof(parsed_show_bof): 16 | """Test parsing show bof output.""" 17 | data = "tests/fixtures/show_output/show_bof.txt" 18 | 19 | sros_parser = SrosParser(data) 20 | result = sros_parser.show_bof() 21 | assert result == parsed_show_bof 22 | 23 | 24 | def test_show_router_interface(parsed_show_router_int): 25 | """ 26 | Test extracting router interfaces from show command 27 | """ 28 | data = "tests/fixtures/show_output/show_router_interface.txt" 29 | 30 | sros_parser = SrosParser(data) 31 | result = sros_parser.show_router_interface() 32 | assert result == parsed_show_router_int 33 | 34 | 35 | def test_show_service_service_using(parsed_show_service_using): 36 | """ 37 | Test parsing show service service using show command 38 | """ 39 | example_output = "tests/fixtures/show_output/show_service_service_using.txt" 40 | parser = SrosParser(example_output) 41 | result = parser.show_service_service_using() 42 | 43 | assert result, parsed_show_service_using 44 | 45 | 46 | def test_get_show_route_table(parsed_show_router_table): 47 | """Test general show router route table.""" 48 | data = "tests/fixtures/show_output/show_route_table.txt" 49 | sros_parser = SrosParser(data) 50 | result = sros_parser.show_router_route_table() 51 | assert result == parsed_show_router_table 52 | 53 | 54 | def test_get_show_router_static_route_v4(parsed_static_route_v4): 55 | """Test general show router static route.""" 56 | data = "tests/fixtures/show_output/show_router_static_route_tag.txt" 57 | sros_parser = SrosParser(data) 58 | result = sros_parser.show_router_static_route(protocol="ipv4") 59 | assert result == parsed_static_route_v4 60 | 61 | 62 | def test_get_show_router_static_route_v4_default(parsed_static_route_v4): 63 | """Test general show router static route, default v4 without protocol specified.""" 64 | data = "tests/fixtures/show_output/show_router_static_route_tag.txt" 65 | sros_parser = SrosParser(data) 66 | result = sros_parser.show_router_static_route() 67 | assert result == parsed_static_route_v4 68 | 69 | 70 | def test_get_show_router_static_route_v6(parsed_static_route_v6): 71 | """Test general show router static route, ipv6 specified.""" 72 | data = "tests/fixtures/show_output/show_router_static_route_tag_v6.txt" 73 | sros_parser = SrosParser(data) 74 | result = sros_parser.show_router_static_route(protocol="IPV6") 75 | assert result == parsed_static_route_v6 76 | -------------------------------------------------------------------------------- /tests/unit/tests_sros_router_interfaces.py: -------------------------------------------------------------------------------- 1 | """Tests router interfaces.""" 2 | import pprint 3 | 4 | from ttp_templates import parse_output 5 | 6 | data = """ 7 | #-------------------------------------------------- 8 | echo "Router (Network Side) Configuration" 9 | #-------------------------------------------------- 10 | router Base 11 | interface "L3-NGM-IDN-0165" 12 | no shutdown 13 | exit 14 | interface "L3-OAM-eNodeB0215" 15 | enable-ingress-stats 16 | no shutdown 17 | exit 18 | interface "L3-OAM-eNodeB0905" 19 | no shutdown 20 | exit 21 | interface "system" 22 | address 10.115.56.217/32 23 | ipv6 24 | address 2001:4888:1069:1222:699:400:0:d7/128 25 | exit 26 | no shutdown 27 | exit 28 | interface "to-BTS0420-7705-HUB-01-1" 29 | address 172.25.195.89/31 30 | description "DESCT-to-TEMQAZKWT1A-P-AL-0415-H1-1" 31 | ldp-sync-timer 45 32 | port 1/5/8:3215 33 | ipv6 34 | address 2001:1222:206a:21cd:699:400:0:1/64 35 | bfd 500 receive 500 multiplier 3 36 | exit 37 | qos 20120 38 | bfd 500 receive 500 multiplier 3 39 | no shutdown 40 | exit 41 | #-------------------------------------------------- 42 | echo "Static Route Configuration" 43 | #-------------------------------------------------- 44 | """ 45 | 46 | result = parse_output(data=data, platform="sros", command="admin display router interfaces") 47 | pprint.pprint(result) 48 | -------------------------------------------------------------------------------- /tests/unit/tests_sros_show_router_interface.py: -------------------------------------------------------------------------------- 1 | """Tests show router interfaces.""" 2 | 3 | import pprint 4 | 5 | from ttp_templates import parse_output 6 | 7 | data = """ 8 | *A:TEMPE-AZ-HUB-EXAMPLE-7750-01>config>service>ies>if>ipv6>vrrp# show router interface 9 | 10 | =============================================================================== 11 | Interface Table (Router: Base) 12 | =============================================================================== 13 | Interface-Name Adm Opr(v4/v6) Mode Port/SapId 14 | IP-Address PfxState 15 | ------------------------------------------------------------------------------- 16 | L3-TELCO-IXR01-1 Up Down/Down IES lag-1:300 17 | 2001:1000:2062:357a:646:100:0:1/64 INACCESSIBLE 18 | 2001:1666:2062:357a:646:100:0:1/64 INACCESSIBLE 19 | fe80::645:100:0:1/64 INACCESSIBLE 20 | L3-TELCO-IXR02-1 Up Down/Up IES lag-2:300 21 | 2001:1666:2062:4222:649:100:0:1/64 PREFERRED 22 | fe80::645:100:0:1/64 PREFERRED 23 | L3-TELCO-eNodeB0420-DUL-01 Up Up/Up IES 1/1/c2/1:301 24 | 10.0.0.0/31 n/a 25 | 2001:1000:2062:24ae:649:100::/64 PREFERRED 26 | fe80::c8:ffff:fe00:0/64 PREFERRED 27 | system Up Up/Up Network system 28 | 10.100.43.69/32 n/a 29 | 2001:4777:2062:2000:645:100:0:19f/128 PREFERRED 30 | to-7750-01 Up Up/Up Network 1/1/c4/1:3415 31 | 172.20.200.69/31 n/a 32 | 2001:1666:206a:335d:645:100:0:1/64 PREFERRED 33 | fe80::c8:ffff:fe00:0/64 PREFERRED 34 | to-BTS0420-7750-H2 Up Down/Down Network lag-11:4094 35 | 172.20.200.1/31 n/a 36 | 2001:1666:206a:335f:645:100::/64 INACCESSIBLE 37 | fe80::c8:ffff:fe00:14b/64 INACCESSIBLE 38 | ------------------------------------------------------------------------------- 39 | Interfaces : 6 40 | =============================================================================== 41 | """ 42 | 43 | result = parse_output(data=data, platform="sros", command="show_router_interface") 44 | pprint.pprint(result) 45 | -------------------------------------------------------------------------------- /tests/unit/tests_sros_system_configuration.py: -------------------------------------------------------------------------------- 1 | """Tests system configuration.""" 2 | 3 | import pprint 4 | 5 | from ttp_templates import parse_output 6 | 7 | data = """ 8 | 9 | # Generated MON NOV 02 20:33:16 2020 UTC 10 | 11 | exit all 12 | configure 13 | #-------------------------------------------------- 14 | echo "System Configuration" 15 | #-------------------------------------------------- 16 | system 17 | name "EXAMPLEPHX-P-AL-7750-01" 18 | contact "Hugo Tinoco" 19 | location "Phoenix, AZ" 20 | rollback 21 | rollback-location "cf2:\Rollback" 22 | exit 23 | snmp 24 | streaming 25 | no shutdown 26 | exit 27 | packet-size 9216 28 | exit 29 | time 30 | ntp 31 | ntp-server 32 | server 8.8.8.8 33 | server 8.8.4.4 34 | no authentication-check 35 | no shutdown 36 | exit 37 | sntp 38 | shutdown 39 | exit 40 | zone MST 41 | exit 42 | script-control 43 | script "EHS-Egress-FCS-Errors" owner "EHS" 44 | description "EHS FCS Errors - generate TS file" 45 | location "cf2:\EHS\EHS-Script-FCS-Errors_7750_1.txt" 46 | no shutdown 47 | exit 48 | script-policy "EHS-script-policy" owner "EHS" 49 | results "cf2:\EHS\EHS-FCS-Script-Results" 50 | script "EHS-Egress-FCS-Errors" owner "EHS" 51 | max-completed 255 52 | expire-time 7776000 53 | no shutdown 54 | exit 55 | exit 56 | exit 57 | #-------------------------------------------------- 58 | """ 59 | 60 | result = parse_output(data=data, platform="sros", command="admin display system configuration") 61 | pprint.pprint(result) 62 | -------------------------------------------------------------------------------- /ttp_sros_parser/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | #Logs 10 | *.log 11 | 12 | #Configs 13 | *.cfg 14 | Parsed-Configs/*/*.txt 15 | Parsed-Configs/ 16 | # Visual Studio 17 | workspace.code-workspace 18 | 19 | # Distribution / packaging 20 | .Python 21 | build/ 22 | develop-eggs/ 23 | dist/ 24 | downloads/ 25 | eggs/ 26 | .eggs/ 27 | lib/ 28 | lib64/ 29 | parts/ 30 | sdist/ 31 | var/ 32 | wheels/ 33 | pip-wheel-metadata/ 34 | share/python-wheels/ 35 | *.egg-info/ 36 | .installed.cfg 37 | *.egg 38 | MANIFEST 39 | 40 | # PyInstaller 41 | # Usually these files are written by a python script from a template 42 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 43 | *.manifest 44 | *.spec 45 | 46 | # Installer logs 47 | pip-log.txt 48 | pip-delete-this-directory.txt 49 | 50 | # Unit test / coverage reports 51 | htmlcov/ 52 | .tox/ 53 | .nox/ 54 | .cache 55 | nosetests.xml 56 | coverage.xml 57 | *.cover 58 | *.py,cover 59 | .hypothesis/ 60 | .pytest_cache/ 61 | 62 | # Translations 63 | *.mo 64 | *.pot 65 | 66 | # Django stuff: 67 | *.log 68 | local_settings.py 69 | db.sqlite3 70 | db.sqlite3-journal 71 | 72 | # Flask stuff: 73 | instance/ 74 | .webassets-cache 75 | 76 | # Scrapy stuff: 77 | .scrapy 78 | 79 | # Sphinx documentation 80 | docs/_build/ 81 | 82 | # PyBuilder 83 | target/ 84 | 85 | # Jupyter Notebook 86 | .ipynb_checkpoints 87 | 88 | # IPython 89 | profile_default/ 90 | ipython_config.py 91 | 92 | # pyenv 93 | .python-version 94 | 95 | # pipenv 96 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 97 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 98 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 99 | # install all needed dependencies. 100 | #Pipfile.lock 101 | 102 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 103 | __pypackages__/ 104 | 105 | # Celery stuff 106 | celerybeat-schedule 107 | celerybeat.pid 108 | 109 | # SageMath parsed files 110 | *.sage.py 111 | 112 | # Environments 113 | .env 114 | .venv 115 | env/ 116 | venv/ 117 | ENV/ 118 | env.bak/ 119 | venv.bak/ 120 | 121 | # Spyder project settings 122 | .spyderproject 123 | .spyproject 124 | 125 | # Rope project settings 126 | .ropeproject 127 | 128 | # mkdocs documentation 129 | /site 130 | 131 | # mypy 132 | .mypy_cache/ 133 | .dmypy.json 134 | dmypy.json 135 | 136 | # Pyre type checker 137 | .pyre/ 138 | -------------------------------------------------------------------------------- /ttp_sros_parser/__init__.py: -------------------------------------------------------------------------------- 1 | """TTP SROS Parser.""" 2 | __version__ = "0.1.5" 3 | -------------------------------------------------------------------------------- /ttp_sros_parser/helpers.py: -------------------------------------------------------------------------------- 1 | """Helper Functions.""" 2 | import glob 3 | import sys 4 | from pathlib import Path 5 | from typing import List 6 | 7 | 8 | def globfindfile(regex: str) -> List[str]: 9 | """Locate a file in the DIR by passing the regex value (ie:(*.log)). 10 | 11 | The returned value by calling the function is the file. If the path is passed in, the full path is returned back - 12 | not just the filename. 13 | 14 | Args: 15 | regex (str): Some regex pattern 16 | """ 17 | files = list(glob.glob(regex)) 18 | if len(files) == 0: 19 | sys.exit(f"No {regex} file found.") 20 | return files 21 | 22 | 23 | def check_file(file: str) -> str: 24 | """Check file exists.""" 25 | file_path = Path(file) 26 | 27 | if not file.endswith((".cfg", ".txt", ".log")): 28 | raise ValueError(f"{file_path} must end with '.cfg', '.txt' or '.log'") 29 | if not file_path.exists(): 30 | raise SystemExit(f"{file_path} doesn't exist.") 31 | return file 32 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/__init__.py: -------------------------------------------------------------------------------- 1 | """Templates.""" 2 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_7750_lag.ttp: -------------------------------------------------------------------------------- 1 | 2 | def lag_info(data): 3 | try: 4 | int(data) 5 | return data, {"lag-index": data} 6 | except ValueError: 7 | lag = data.split() 8 | return data, {"lag-index": lag[0], "name": lag[2].strip('"')} 9 | 10 | 11 | #-------------------------------------------------- {{ ignore }} 12 | echo "LAG Configuration" {{ _start_ }} 13 | #-------------------------------------------------- {{ ignore }} 14 | 15 | 16 | lag {{ lag-index | ORPHRASE | macro(lag_info) }} 17 | no shutdown {{ admin-state | set(false) }} 18 | description {{ description | ORPHRASE | strip('"')}} 19 | mode {{ mode }} 20 | encap-type {{ encap-type }} 21 | 22 | access {{ _start_ }} 23 | adapt-qos {{adapt-qos}} 24 | bandwidth {{bandwidth}} 25 | booking-factor {{booking-factor}} 26 | per-fp{{per-fp-queuing}} 27 | exit {{_end_}} 28 | 29 | 30 | port {{id}} 31 | 32 | 33 | lacp {{ mode }} administrative-key {{ administrative-key | DIGIT}} 34 | hold-time {{ hold-time | ORPHRASE }} 35 | 36 | 37 | family {{ family | contains("ipv4") }} 38 | shutdown {{ admin-state | set(false) }} 39 | local-ip-address {{ local-ip }} 40 | multiplier {{ multiplier }} 41 | remote-ip-address {{ remote-ip-address }} 42 | no shutdown {{ admin-state | set(true) }} 43 | exit {{ _end_ }} 44 | 45 | no shutdown {{ admin-state | set(true) }} 46 | 47 | exit {{ _end_ }} 48 | 49 | #-------------------------------------------------- {{ _end_ }} -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_7750_mpls_lsp.ttp: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- {{ ignore }} 2 | 3 | echo "MPLS LSP Configuration"{{ _start_ }} 4 | #-------------------------------------------------- {{ ignore }} 5 | 6 | mpls 7 | 8 | path "{{ name }}" 9 | no shutdown {{ admin-state | set('true') }} 10 | shutdown {{ admin-state | set('false') }} 11 | exit 12 | 13 | 14 | 15 | lsp-template "{{ name }}" {{ type }} 16 | default-path "{{ default-path }}" 17 | path-computation-method {{ path-computation-method }} 18 | fast-reroute {{ fast-reroute }} 19 | exit {{ ignore }} 20 | no shutdown {{ admin-state | set('true') }} 21 | shutdown {{ admin-state | set('false') }} 22 | 23 | exit {{ _end_ }} 24 | 25 | 26 | lsp "name" 27 | to {{ to }} 28 | path-computation-method {{ path-computation-method }} 29 | fast-reroute {{ fast-reroute }} 30 | exit {{ ignore }} 31 | primary "{{ primary }}" 32 | exit {{ ignore }} 33 | secondary "{{ secondary }}" 34 | {{ standby }} 35 | exit {{ ignore }} 36 | no shutdown {{ admin-state | set('true') }} 37 | shutdown {{ admin-state | set('false') }} 38 | exit {{ _end_ }} 39 | 40 | 41 | auto-lsp lsp-template "{{ template }}" policy "{{ policy }}" 42 | 43 | shutdown {{ admin-state | set('false') }} 44 | no shutdown {{ admin-state | set('true') }} 45 | exit {{ _end_ }} 46 | 47 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_7750_python_configuration.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ ignore }} 3 | echo "PYTHON Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ ignore }} 5 | python {{ ignore }} 6 | 7 | python-script "{{name | ORPHRASE | _start_}}" create 8 | description "{{description | ORPHRASE}}" 9 | primary-url "{{primary-url | ORPHRASE}}" 10 | no shutdown {{admin_state | set(true)}} 11 | exit {{_end_}} 12 | 13 | 14 | python-policy "{{name | ORPHRASE | _start_}}" create 15 | description "{{description | ORPHRASE}}" 16 | 17 | dhcp {{message | WORD}} direction {{direction}} script "{{script | ORPHRASE}}" 18 | 19 | 20 | dhcp6 {{message | WORD}} direction {{direction}} script "{{script | ORPHRASE}}" 21 | 22 | exit {{_end_}} 23 | 24 | exit {{_end_}} 25 | #-------------------------------------------------- 26 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_7750_python_declaration_configuration.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ ignore }} 3 | echo "PYTHON (declaration) Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ ignore }} 5 | python {{ ignore }} 6 | 7 | python-policy "{{name | ORPHRASE | _start_}}" create 8 | exit {{_end_}} 9 | 10 | exit {{_end_}} 11 | #-------------------------------------------------- {{ ignore }} 12 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_aaa_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ ignore }} 3 | echo "AAA Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ ignore }} 5 | 6 | 7 | aaa {{_ignore_}} 8 | 9 | radius-server-policy "{{name | _start_ | ORPHRASE}}" create 10 | description "{{description | ORPHRASE}}" 11 | acct-request-script-policy "{{acct-request-script-policy | ORPHRASE}}" 12 | auth-request-script-policy "{{auth-request-script-policy | ORPHRASE}}" 13 | accept-script-policy {{accept-script-policy | ORPHRASE}} 14 | 15 | servers {{_start_}} 16 | retry {{retry | DIGIT}} 17 | router "{{router | ORPHRASE}}" 18 | timeout {{timeout | ORPHRASE}} 19 | server {{server-id | DIGIT}} name "{{server-name | ORPHRASE}}" 20 | exit {{_ignore_}} 21 | 22 | exit {{_ignore_}} 23 | 24 | 25 | radius-script-policy "{{name | _start_ | ORPHRASE}}" create 26 | description "{{description | ORPHRASE}}" 27 | 28 | primary {{_start_}} 29 | script-url "{{script-url | ORPHRASE}}" 30 | no shutdown {{admin_state | set(true)}} 31 | exit {{_ignore_}} 32 | 33 | exit {{_ignore_}} 34 | 35 | 36 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_aaa_declaration_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ignore}} 3 | echo "AAA (Declarations) Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ignore}} 5 | aaa {{ignore}} 6 | 7 | radius-server-policy "{{name | ORPHRASE | _start_}}" create 8 | exit {{_end_}} 9 | 10 | 11 | radius-script-policy "{{name | ORPHRASE | _start_ }}" create 12 | exit {{_end_}} 13 | 14 | exit {{ignore}} 15 | #-------------------------------------------------- {{ignore}} 16 | echo "Multicast Path Management Policy Configuration" {{_end_}} 17 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_cflowd_config.ttp: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- {{ignore}} 2 | echo "Cflowd Configuration" {{_start_}} 3 | #-------------------------------------------------- {{ignore}} 4 | 5 | cflowd {{_start_}} 6 | active-timeout {{active-timeout}} 7 | cache-size {{cache-size}} 8 | inactive-timeout {{inactive-timeout}} 9 | rate {{rate}} 10 | template-retransmit {{template-retransmit}} 11 | 12 | collector {{collector_ip_address | _start_}} version {{version_id}} 13 | description "{{description | ORPHRASE}}" 14 | template-set {{collector_template-set}} 15 | exit {{_end_}} 16 | 17 | exit {{_end_}} 18 | 19 | #-------------------------------------------------- {{_end_}} -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_connector_configuration.ttp: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- {{ ignore }} 2 | echo "Connector Configuration" {{ _start_ }} 3 | #-------------------------------------------------- {{ ignore }} 4 | 5 | 6 | port {{ port }} 7 | connector {{ ignore }} 8 | breakout {{ breakout }} 9 | exit {{ ignore }} 10 | no shutdown {{ admin-state | set(true) }} 11 | 12 | exit {{ _end_ }} 13 | 14 | #-------------------------------------------------- {{ _end_ }} -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_dhcp_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ ignore }} 3 | echo "Local DHCP Server (Base Router) Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ ignore }} 5 | router {{_ignore_}} 6 | dhcp {{_ignore_}} 7 | 8 | local-dhcp-server "{{name | ORPHRASE | _start_}}" create 9 | user-db "{{user-db | ORPHRASE}}" 10 | 11 | pool "{{name | ORPHRASE | _start_}}" create 12 | min-lease-time {{min-lease-time | ORPHRASE}} 13 | max-lease-time {{max-lease-time | ORPHRASE}} 14 | 15 | options {{_start_}} 16 | dns-server {{dns-server | ORPHRASE | split(" ")}} 17 | 18 | custom-option {{id | DIGIT}} address {{address | IP}} 19 | 20 | exit {{_end_}} 21 | 22 | 23 | subnet {{prefix | PREFIX}} create 24 | address-range {{address-range | ORPHRASE}} 25 | exit {{_end_}} 26 | 27 | exit {{_end_}} 28 | 29 | no shutdown {{admin_state | set (true)}} 30 | exit {{_end_}} 31 | 32 | exit{{_ignore_}} 33 | exit{{_ignore_}} 34 | 35 | #-------------------------------------------------- {{_end_}} 36 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_filter_log_configuration.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ignore}} 3 | echo "Filter Log Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ignore}} 5 | filter {{ignore}} 6 | 7 | log {{log-id}} create 8 | description "{{description}}" 9 | exit {{_end_}} 10 | 11 | exit {{_end_}} 12 | 13 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_filter_match_list_configuration.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ignore}} 3 | echo "Filter Match lists Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ignore}} 5 | filter {{ignore}} 6 | 7 | match-list {{_start_}} 8 | 9 | ip-prefix-list "{{name | _start_}}" create 10 | description "{{description | ORPHRASE}}" 11 | {{ prefix | _line_ | contains ("prefix") | joinmatches | resub(old = '^prefix ', new = '') | to_list}} 12 | exit{{_end_}} 13 | 14 | 15 | ipv6-prefix-list "{{name | _start_}}" create 16 | description "{{description | ORPHRASE}}" 17 | {{ prefix | _line_ | contains ("prefix") | joinmatches | resub(old = '^prefix ', new = '') | to_list}} 18 | exit{{_end_}} 19 | 20 | exit {{_end_}} 21 | 22 | exit {{_end_}} 23 | #---{{_end_}} 24 | 25 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_igmp_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ignore}} 3 | echo "IGMP Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ignore}} 5 | igmp {{ignore}} 6 | 7 | ssm-translate {{_start_}} 8 | 9 | grp-range {{grp-range | ORPHRASE}} 10 | source {{source | IP}} 11 | exit {{_end_}} 12 | 13 | exit {{_ignore_}} 14 | 15 | 16 | interface "{{name | _start_}}" 17 | no shutdown {{admin_state | set(true)}} 18 | exit {{_end_}} 19 | 20 | query-interval {{query_interval | DIGIT}} 21 | query-last-member-interval {{query-last-member-interval | DIGIT}} 22 | no shutdown {{admin_state | set(true)}} 23 | exit {{_end_}} 24 | 25 | #-------------------------------------------------- {{_end_}} 26 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_isis_configuration.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ ignore }} 3 | echo "ISIS Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ ignore }} 5 | isis {{process}} 6 | area-id {{area-id}} 7 | lsp-lifetime {{lsp-lifetime | DIGIT }} 8 | lsp-refresh-interval {{lsp-refresh-interval | DIGIT }} half-lifetime {{half-lifetime | WORD}} 9 | overload-on-boot timeout {{overload-on-boot-timeout}} 10 | export {{ export | ORPHRASE | replace('"', '') |split(' ') | join(',')}} 11 | rib-priority {{rib-priority | WORD}} "{{rib-priority-name}}" 12 | ipv6-routing {{ipv6-routing}} 13 | 14 | multi-topology {{_start_}} 15 | ipv6-unicast {{ipv6-unicast | set(true)}} 16 | exit {{_end_}} 17 | 18 | 19 | timers {{_start_}} 20 | spf-wait {{spf-wait | DIGIT}} spf-initial-wait {{spf-initial-wait | DIGIT}} spf-second-wait {{spf-second-wait | DIGIT}} 21 | exit {{_end_}} 22 | 23 | 24 | level {{number | DIGIT | _start_}} 25 | wide-metrics-only {{wide-metrics-only | set(true)}} 26 | exit {{_end_}} 27 | 28 | 29 | interface "{{name | ORPHRASE | _start_}}" 30 | level-capability {{level-capability}} 31 | hello-authentication-key "{{hello-authentication-key}}" {{hash-type}} 32 | hello-authentication-type {{hello-authentication-type}} 33 | passive {{passive | set(true)}} 34 | tag {{tag | DIGIT }} 35 | interface-type {{interface-type}} 36 | 37 | level {{number | DIGIT | _start_}} 38 | ipv6-unicast-metric {{ipv6-unicast-metric | DIGIT }} 39 | metric {{metric | DIGIT}} 40 | exit {{_end_}} 41 | 42 | no shutdown {{admin-state | set(true)}} 43 | no shutdown {{admin-state | set(true)}} 44 | exit {{_end_}} 45 | 46 | exit {{_end_}} 47 | #-------------------------------------------------- {{ ignore }} 48 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_l2tp_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ignore}} 3 | echo "L2TP Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ignore}} 5 | l2tp {{_start_}} 6 | 7 | group "{{group}}" protocol {{protocol}} create 8 | 9 | tunnel "{{tunnel}}" create 10 | local-name "{{local-name}}" 11 | peer {{peer | IP}} 12 | no shutdown {{admin_state | set(true)}} 13 | exit {{_end_}} 14 | 15 | no shutdown {{admin_state | set(true)}} 16 | exit {{_end_}} 17 | 18 | no shutdown {{admin_state | set(true)}} 19 | exit {{ignore}} 20 | #-------------------------------------------------- {{_end_}} 21 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_ldp_config.ttp: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- {{ ignore }} 2 | echo "LDP Configuration" {{_start_}} 3 | #-------------------------------------------------- {{ ignore }} 4 | 5 | ldp {{_start_}} 6 | export-tunnel-table "{{export-tunnel-table}}" 7 | fast-reroute {{fast-reroute | set(true)}} 8 | fec-originate {{fec-originate | PREFIX}} {{pop | let(true)}} 9 | 10 | interface-parameters {{_start_}} 11 | 12 | interface "{{name | ORPHRASE}}" {{dual-stack | let(true)}} 13 | 14 | ipv4 {{_start_}} 15 | no shutdown {{admin_state | set (true)}} 16 | exit {{_end_}} 17 | 18 | no shutdown {{admin_state | set (true)}} 19 | exit {{_end_}} 20 | 21 | exit {{_end_}} 22 | 23 | 24 | targeted-session {{_start_}} 25 | no shutdown {{admin_state | set (true)}} 26 | exit {{_end_}} 27 | 28 | no shutdown {{admin_state | set (true)}} 29 | exit {{_end_}} 30 | 31 | 32 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_log_configuration.ttp: -------------------------------------------------------------------------------- 1 | 2 | def macro_gen(data): 3 | if 'generate' in data: 4 | return data, {"generate": True} 5 | 6 | def macro_source(data): 7 | if 'main' in data: 8 | return data, {"main": True} 9 | elif 'change' in data: 10 | return data, {"change": True} 11 | elif 'security' in data: 12 | return data, {"security": True} 13 | 14 | 15 | #-------------------------------------------------- {{ignore}} 16 | echo "Log Configuration" {{_start_}} 17 | #-------------------------------------------------- {{ignore}} 18 | log {{ignore}} 19 | 20 | file-id {{file-id}} 21 | description "{{description}}" 22 | 23 | location {{primary}}: 24 | 25 | rollover {{rollover}} retention {{retention}} 26 | exit {{ignore}} 27 | 28 | 29 | event-control "{{event}}" {{event-id}} {{generate | re(r'generate') | macro('macro_gen')}} 30 | 31 | 32 | syslog {{syslog-id | DIGIT}} 33 | description "{{description | PHRASE}}" 34 | address {{address}} 35 | 36 | exit {{_end_}} 37 | 38 | snmp-trap-group {{log-id | DIGIT | _start_ }} 39 | description "{{description}}" 40 | 41 | trap-target "{{name | _start_ }}" address {{address}} {{snmp-version}} notify-community "{{notify-community}}" security-level {{security-level}} 42 | trap-target "{{name | _start_ }}" address {{address}} {{snmp-version}} notify-community "{{notify-community}}" 43 | 44 | 45 | exit {{_end_}} 46 | 47 | log-id {{log-id}} 48 | description "{{description}}" 49 | 50 | from {{source | _start_ | macro('macro_source')}} 51 | from {{source | _start_ | macro('macro_source')}} {{security | macro('macro_source')}} 52 | from {{source | _start_ | macro('macro_source')}} {{security | macro('macro_source')}} {{change | macro('macro_source')}} 53 | 54 | to {{destination}} 55 | exit {{_end_}} 56 | 57 | exit {{_end_}} 58 | 59 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_mgmt_router_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | def set_true(data): 3 | if 'bfd-enable' in data: 4 | return data, {"bfd-enable": True} 5 | elif 'black-hole' in data: 6 | return data, {"black-hole": True} 7 | 8 | 9 | 10 | #-------------------------------------------------- {{ ignore }} 11 | echo "Management Router Configuration" {{ _start_ }} 12 | #-------------------------------------------------- {{ ignore }} 13 | 14 | router {{ router | _start_ }} 15 | 16 | static-route-entry {{ address | is_ip }}/{{ prefix }} 17 | next-hop {{ next-hop | is_ip }} 18 | exit {{_ignore_}} 19 | 20 | exit {{ _ignore_ }} 21 | exit {{ _end_ }} 22 | 23 | 24 | #-------------------------------------------------- {{ _end_ }} 25 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_mirror_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ ignore }} 3 | echo "Mirror Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ ignore }} 5 | 6 | mirror {{_ignore_}} 7 | 8 | mirror-dest {{ mirror-dest | _start_ | DIGIT }} name {{name | ORPHRASE}} type {{type | ORPHRASE}} create 9 | description {{description | ORPHRASE}} 10 | 11 | encap {{_start_}} 12 | 13 | {{encap-type | _start_ | ORPHRASE}} create 14 | 15 | gateway create {{_start_}} 16 | ip src {{src-ip | IP }} dest {{dest-ip | IP }} 17 | udp src {{src-udp | DIGIT }} dest {{dest-udp | DIGIT }} 18 | exit {{_ignore_}} 19 | 20 | exit {{_ignore_}} 21 | 22 | exit {{_ignore_}} 23 | 24 | no shutdown {{admin-state | set(true)}} 25 | exit {{_end_}} 26 | 27 | 28 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_multicast_path_management_policy_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ignore}} 3 | echo "Multicast Path Management Policy Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ignore}} 5 | mcast-management {{ignore}} 6 | 7 | bandwidth-policy "{{name | ORPHRASE | _start_}}" create 8 | 9 | t2-paths {{_start_}} 10 | 11 | secondary-path {{_start_}} 12 | number-paths {{number-paths | DIGIT}} redundant-sfm {{redundant-sfm | DIGIT}} 13 | exit {{_end_}} 14 | 15 | exit {{_end_}} 16 | 17 | exit {{_end_}} 18 | 19 | exit {{ignore}} 20 | #-------------------------------------------------- {{ignore}} 21 | echo "Switch Fabric Configuration" {{_end_}} 22 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_pim_config.ttp: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- {{ ignore }} 2 | echo "PIM Configuration" {{_start_}} 3 | #-------------------------------------------------- {{ ignore }} 4 | 5 | pim {{_start_}} 6 | 7 | interface "{{name | ORPHRASE }}" 8 | bfd-enable {{bfd_enable | set(true)}} 9 | no shutdown {{admin_state | set(true)}} 10 | priority {{priority | DIGIT}} 11 | sticky-dr {{sticky-dr | set(true)}} 12 | exit {{_ignore_}} 13 | 14 | 15 | 16 | rp {{_start_}} 17 | 18 | 19 | static {{_start_}} 20 | exit {{_ignore_}} 21 | 22 | 23 | 24 | bsr-candidate {{_start_}} 25 | shutdown {{admin-state | set (false)}} 26 | exit {{_ignore_}} 27 | 28 | 29 | 30 | rp-candidate {{_start_}} 31 | shutdown {{admin-state | set (false)}} 32 | exit {{_ignore_}} 33 | 34 | exit {{_ignore_}} 35 | 36 | no shutdown {{admin_state | set (true)}} 37 | exit {{_end_}} 38 | 39 | #-------------------------------------------------- 40 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_port_config.ttp: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- {{ignore}} 2 | echo "Port Configuration" {{_start_}} 3 | #-------------------------------------------------- {{ignore}} 4 | 5 | port {{port-id}} 6 | shutdown {{admin_state | set(false)}} 7 | description "{{description}}" 8 | 9 | ethernet {{_start_}} 10 | mode {{mode}} 11 | encap-type {{encap-type}} 12 | mtu {{mtu | DIGIT}} 13 | loopback internal persistent {{loopback | set(true)}} 14 | 15 | network {{ignore}} 16 | queue-policy "{{queue-policy | DIGIT}}" 17 | exit {{_end_}} 18 | 19 | 20 | hold-time down {{down}} 21 | 22 | 23 | hold-time up {{up| DIGIT}} down {{down | DIGIT}} 24 | 25 | no autonegotiate {{autonegotiate | set(false)}} 26 | autonegotiate {{autonegotiate}} 27 | egress-rate {{egress-rate | DIGIT}} 28 | exit {{_end_}} 29 | 30 | no shutdown {{admin_state | set(true)}} 31 | exit {{_end_}} 32 | 33 | #-------------------------------------------------- {{_end_}} 34 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_port_cross-connect_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ignore}} 3 | echo "Port Cross-Connect Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ignore}} 5 | port-xc {{ignore}} 6 | 7 | pxc {{number | DIGIT | _start_}} create 8 | description "{{description | ORPHRASE}}" 9 | port {{port}} 10 | no shutdown {{admin_state | set(true)}} 11 | shutdown {{admin_state | set(false)}} 12 | exit {{_end_}} 13 | 14 | exit {{ignore}} 15 | #-------------------------------------------------- {{ignore}} 16 | echo "Port Configuration" {{_end_}} 17 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_radius_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ ignore }} 3 | echo "RADIUS Server Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ ignore }} 5 | radius-server {{_ignore_}} 6 | 7 | server "{{name | ORPHRASE | _start_}}" address {{address | IP }} secret "{{secret | ORPHRASE}}" {{hash-type | WORD}} create 8 | description "{{description | ORPHRASE}}" 9 | acct-port {{acct-port | DIGIT}} 10 | accept-coa {{accept-coa | set (true)}} 11 | auth-port {{auth-port | DIGIT}} 12 | coa-script-policy "{{coa-script-policy | ORPHRASE}}" 13 | exit {{_end_}} 14 | 15 | exit {{_end_}} 16 | 17 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_redundancy_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ignore}} 3 | echo "Redundancy Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ignore}} 5 | redundancy {{ignore}} 6 | 7 | multi-chassis {{_start_}} 8 | 9 | peer {{peer-address | IP | _start_ }} create 10 | description "{{description | ORPHRASE}}" 11 | 12 | sync {{_start_}} 13 | igmp {{igmp | set(true)}} 14 | srrp {{srrp | set(true)}} 15 | sub-mgmt {{sub-mgmt | ORPHRASE}} 16 | 17 | port {{port | _start_}} create 18 | 19 | range {{range}} sync-tag "{{sync-tag | ORPHRASE }}" 20 | 21 | exit {{_end_}} 22 | 23 | no shutdown {{admin_state | set(true)}} 24 | shutdown {{admin_state | set(false)}} 25 | exit {{_end_}} 26 | 27 | no shutdown {{admin_state | set(true)}} 28 | shutdown {{admin_state | set(false)}} 29 | exit {{_end_}} 30 | 31 | exit {{_end_}} 32 | 33 | synchronize {{synchronize}} 34 | exit {{ignore}} 35 | #-------------------------------------------------- {{ignore}} 36 | echo "QoS Policy Configuration" {{_end_}} 37 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_router_interface.ttp: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- {{ ignore}} 2 | echo "Router (Network Side) Configuration" {{ _start_ }} 3 | #-------------------------------------------------- {{ ignore}} 4 | 5 | router {{ignore}} 6 | 7 | interface {{interface_name | strip('"')}} 8 | shutdown {{admin_state | set(false) }} 9 | description {{description | strip('"')}} 10 | enable-ingress-stats {{ingress_stats | set(true)}} 11 | 12 | address {{address | IP}}/{{prefix_length}} 13 | 14 | loopback {{loopback | set(true)}} 15 | 16 | bfd {{ipv4_bfd | re(r"\d.*")}} 17 | 18 | ldp_sync_timer {{ldp_sync_timer}} 19 | cpu_protection {{cpu_protection}} 20 | port {{port}} 21 | 22 | ipv6 {{_start_}} 23 | 24 | address {{ipv6_address | IPV6 }}/{{prefix_length}} 25 | 26 | 27 | bfd {{ipv6_bfd | re(r"\d.*")}} 28 | 29 | exit {{ignore}} 30 | 31 | exit {{ignore}} 32 | 33 | qos {{network-policy}} 34 | 35 | 36 | ingress {{_start_}} 37 | filter ip {{filter-acl-id}} 38 | filter ipv6 {{filter-acl-id-v6}} 39 | exit {{_end_}} 40 | 41 | 42 | egress {{_start_}} 43 | filter ip {{filter-acl-id}} 44 | filter ipv6 {{filter-acl-id-v6}} 45 | exit {{_end_}} 46 | 47 | 48 | cflowd-parameters {{_start_}} 49 | sampling {{cast}} type {{sampling-type}} 50 | exit {{_end_}} 51 | 52 | local-dhcp-server "{{local-dhcp-server-name}}" 53 | bfd {{ipv4_bfd | re(r"\d.*")}} 54 | no shutdown {{admin_state | set(true)}} 55 | autonomous-system {{autonomous-system-id}} 56 | ecmp {{ecmp-value}} 57 | exit {{_end_}} 58 | 59 | 60 | #-------------------------------------------------- {{_end_}} 61 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_router_policy_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ignore}} 3 | echo "Policy Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ignore}} 5 | policy-options {{ignore}} 6 | begin {{ignore}} 7 | 8 | prefix-list "{{ name | re(r'.*') }}" 9 | {{ prefix-list_cfg | _line_ | contains("prefix") | joinmatches }} 10 | exit {{_end_}} 11 | 12 | 13 | 14 | community {{ name | re(r'.*') }} 15 | members "{{ members | WORD }}" 16 | expression {{ expression | PHRASE }} 17 | exit {{_end_}} 18 | 19 | 20 | 21 | policy-statement "{{ name | re(r'.*') }}" 22 | 23 | entry {{entry-id | DIGIT}} 24 | description "{{description | re(r'.*')}}" 25 | 26 | from {{_start_}} 27 | {{ from | replace('"', '') | ORPHRASE | joinmatches }} 28 | exit {{_end_}} 29 | 30 | 31 | to {{_start_}} 32 | {{ to | ORPHRASE | joinmatches }} 33 | exit {{_end_}} 34 | 35 | 36 | 37 | action {{type | re (r'.*')}} {{_start_}} 38 | {{ addons | ORPHRASE | joinmatches }} 39 | exit {{_end_}} 40 | 41 | 42 | exit {{_end_}} 43 | 44 | default-action {{default-action | re (r'.*')}} 45 | exit {{_end_}} 46 | 47 | 48 | exit {{_end_}} 49 | 50 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_router_static_routes.ttp: -------------------------------------------------------------------------------- 1 | 2 | def set_true(data): 3 | if 'bfd-enable' in data: 4 | return data, {"bfd-enable": True} 5 | elif 'black-hole' in data: 6 | return data, {"black-hole": True} 7 | 8 | 9 | 10 | #-------------------------------------------------- {{ ignore }} 11 | echo "Management Router Configuration" {{ _start_ }} 12 | #-------------------------------------------------- {{ ignore }} 13 | 14 | router {{ router }} 15 | 16 | static-route {{ address | is_ip }}/{{ prefix }} next-hop {{ next-hop | is_ip }} 17 | 18 | 19 | exit {{ _end_ }} 20 | 21 | 22 | 23 | #-------------------------------------------------- {{ ignore }} 24 | echo "Static Route Configuration" {{ _start_ }} 25 | #-------------------------------------------------- {{ ignore }} 26 | 27 | static-route {{ address | IPV4}}/{{ prefix }} next-hop {{ next-hop | is_ip }} {{ bfd | macro('set_true') | _start_ }} 28 | static-route {{ address | IPV4 }}/{{ prefix }} next-hop {{ next-hop | is_ip }} preference {{ preference | DIGIT | _start_ }} 29 | static-route {{ address | IPV4 }}/{{ prefix }} {{ black-hole | macro('set_true') | _start_ }} 30 | 31 | 32 | #-------------------------------------------------- {{ _end_ }} 33 | echo "Static IPv6 Route Configuration" {{ _start_ }} 34 | 35 | #-------------------------------------------------- {{ ignore }} 36 | 37 | static-route {{ address | IPV6 }}/{{ prefix }} next-hop {{ next-hop | is_ip }} {{ bfd | macro('set_true') | _start_ }} 38 | static-route {{ address | IPV6 }}/{{ prefix }} next-hop {{ next-hop | is_ip }} preference {{ preference | DIGIT | _start_ }} 39 | static-route {{ address | IPV6 }}/{{ prefix }} {{ black-hole | macro('set_true') | _start_ }} 40 | 41 | #-------------------------------------------------- {{ _end_ }} 42 | 43 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_subscriber_mgmt_ss_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | PROTOCOL_TYPE = r"ppp|ipoe" 3 | 4 | 5 | 6 | 7 | #-------------------------------------------------- {{ ignore }} 8 | echo "Subscriber-mgmt (Service Side) Configuration" {{_start_}} 9 | #-------------------------------------------------- {{ ignore }} 10 | 11 | subscriber-mgmt {{_ignore_}} 12 | 13 | 14 | authentication-policy "{{name | _start_ | ORPHRASE}}" 15 | 16 | radius-authentication-server {{_start_}} 17 | router "{{router | ORPHRASE }}" 18 | server {{server-id | DIGIT }} address {{address | IP }} secret "{{ secret | ORPHRASE }}" {{hashing-scheme | WORD }} port {{ port | DIGIT }} 19 | 20 | exit {{_ignore_}} 21 | 22 | exit {{_ignore_}} 23 | 24 | 25 | 26 | radius-accounting-policy {{name| _start_ | ORPHRASE}} 27 | 28 | radius-accounting-server {{_start_}} 29 | router "{{router | ORPHRASE }}" 30 | server {{server-id | DIGIT }} address {{address | IP }} secret "{{ secret | re(r'".*"') }}" {{hashing-scheme | WORD }} port {{ port | DIGIT }} 31 | exit {{_ignore_}} 32 | 33 | exit {{_ignore_}} 34 | 35 | 36 | 37 | 38 | local-user-db "{{ name | _start_ | ORPHRASE}}" create 39 | 40 | {{ type | _start_ | re(r"PROTOCOL_TYPE")}} 41 | match-list {{ match-list | ORPHRASE}} 42 | 43 | host "{{host-name | _start_ | ORPHRASE}}" create 44 | auth-policy "{{auth-policy | ORPHRASE }}" 45 | pre-auth-policy "{{pre-auth-policy | ORPHRASE }}" 46 | server {{server | IP }} 47 | no shutdown {{admin-state | set(true)}} 48 | 49 | host-identification {{_start_}} 50 | username {{ username | WORD}} {{ domain-only | let(true)}} 51 | username {{ username | WORD}} 52 | option60 string "{{option60-string | ORPHRASE}}" 53 | 54 | 55 | exit {{_ignore_}} 56 | address pool {{address-pool | ORPHRASE }} 57 | auth-policy "{{auth-policy | ORPHRASE }}" 58 | password {{password | ORPHRASE }} 59 | 60 | identification-strings {{string-id | _start_ | DIGIT }} create 61 | subscriber-id {{subscriber-id | ORPHRASE }} 62 | sla-profile-string {{sla-profile-string | ORPHRASE }} 63 | sub-profile-string {{sub-profile-string | ORPHRASE }} 64 | 65 | exit {{_ignore_}} 66 | pre-auth-policy {{pre-auth-policy | ORPHRASE }} 67 | server {{server | IP }} 68 | 69 | l2tp {{_start_}} 70 | group {{group | ORPHRASE }} 71 | 72 | exit {{_ignore_}} 73 | no shutdown {{admin-state | set(true)}} 74 | 75 | exit {{_ignore_}} 76 | 77 | exit {{_ignore_}} 78 | 79 | exit {{_ignore_}} 80 | exit {{_ignore_}} 81 | 82 | 83 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_system_begin.ttp: -------------------------------------------------------------------------------- 1 | 2 | # TiMOS-C-{{version | _start_}} cpm/hops64 Nokia {{platform}} SR Copyright (c) {{year}} Nokia. 3 | # All rights reserved. All use subject to applicable license agreements. {{ ignore }} 4 | # Built on Wed Nov 13 11:34:50 PST 2019 by builder in /builds/c/160B/R10/panos/main {{ ignore }} 5 | 6 | 7 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_system_cards.ttp: -------------------------------------------------------------------------------- 1 | 2 | def subscription_level(data): 3 | data = data.replace('"','').split() 4 | if len(data) >= 3: 5 | return {"card-type": data[0], "subscription-level": data[2]} 6 | return data[0] 7 | 8 | #-------------------------------------------------- {{ ignore }} 9 | echo "Card Configuration" {{ _start_ }} 10 | #-------------------------------------------------- {{ ignore }} 11 | 12 | card {{slot-number | DIGIT }} 13 | card-type {{ card-type | ORPHRASE | macro('subscription_level') }} 14 | fail-on-error {{fail-on-error | set(true)}} 15 | 16 | virtual-scheduler-adjustment {{ _start_ }} 17 | sched-run-min-int {{sched-run-min-int}} 18 | task-scheduling-int {{task-scheduling-int}} 19 | exit {{ _end_ }} 20 | 21 | 22 | mda {{mda-slot}} 23 | shutdown {{admin-state | set(false)}} 24 | mda-type {{mda-type | replace('"', '') }} 25 | 26 | ingress-xpl {{_start_}} 27 | window {{window}} 28 | exit {{_end_}} 29 | 30 | 31 | egress-xpl {{_start_}} 32 | window {{window}} 33 | exit {{_end_}} 34 | 35 | fail-on-error {{fail-on-error | set(true)}} 36 | no shutdown {{admin-state | set(true)}} 37 | 38 | 39 | fp {{fp-slot | DIGIT | _start_}} 40 | hi-bw-mcast-src group {{hi-bw-mcast-src-group-id | DIGIT }} 41 | 42 | ingress {{ _start_ }} 43 | 44 | mcast-path-management {{ _start_ }} 45 | bandwidth-policy {{bandwidth-policy-name | ORPHRASE | replace('"', '') }} 46 | no shutdown {{ admin-state | set(true) }} 47 | exit {{_end_}} 48 | 49 | exit {{_end_}} 50 | 51 | exit {{_end_}} 52 | 53 | exit {{ignore}} 54 | 55 | #-------------------------------------------------- {{ _end_ }} 56 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_system_ethcfm.ttp: -------------------------------------------------------------------------------- 1 | 2 | eth-cfm {{_start_}} 3 | 4 | domain {{domain-id}} format {{format}} level {{level}} 5 | 6 | association {{association-id}} format {{format}} name {{name | strip('"')}} 7 | bridge-identifier {{bridge-id}} 8 | exit {{ignore}} 9 | remote-mepid {{remote-mepid}} 10 | 11 | 12 | #-------------------------------------------------- {{_end_}} 13 | 14 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_system_maf.ttp: -------------------------------------------------------------------------------- 1 | 2 | management-access-filter {{_start_}} 3 | 4 | ip-filter {{ipv4-filter | set(true)}} 5 | shutdown {{ admin-state | set(false)}} 6 | default-action {{default-action}} 7 | no shutdown {{ admin-state | set(true)}} 8 | 9 | 10 | ipv6-filter {{ipv6-filter | set(true)}} 11 | shutdown {{ admin-state | set(false)}} 12 | default-action {{default-action}} 13 | no shutdown {{ admin-state | set(true)}} 14 | 15 | 16 | 17 | management-access-filter {{_start_}} 18 | ip-filter {{_exact_}} 19 | 20 | 21 | entry {{entry-id | DIGIT }} 22 | description {{description | re(r"\W.*") | strip('"')}} 23 | src-ip {{src-ip}} 24 | protocol {{protocol}} 25 | dst-port {{dst-port | re(r"\d.*")}} 26 | router {{router-instance | strip('"')}} 27 | action {{action | strip('"')}} 28 | exit {{ignore}} 29 | ipv6-filter {{_end_}} 30 | 31 | 32 | 33 | 34 | ipv6-filter {{_start_}} 35 | 36 | 37 | entry {{entry-id}} 38 | description {{description | re(r"\W.*") | strip('"')}} 39 | src-ip {{src-ip }} 40 | protocol {{protocol}} 41 | dst-port {{dst-port | re(r"\d.*")}} 42 | router {{router-instance | strip('"')}} 43 | action {{action-instance | strip('"')}} 44 | exit {{ignore}} 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_system_profiles.ttp: -------------------------------------------------------------------------------- 1 | 2 | profile {{user-profile-name | re(r".+") | strip('"')}} 3 | default-action {{default-action}} 4 | 5 | entry {{entry-id}} {{_start_}} 6 | match {{match | re(r"\W.*") | strip('"')}} 7 | action {{action}} 8 | exit {{ignore}} 9 | 10 | exit {{_end_}} 11 | 12 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_system_security_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | #--------------------------------------------------{{ignore}} 3 | echo "System Security Cpm Hw Filters, PKI, TLS and LDAP Configuration" {{_start_}} 4 | #--------------------------------------------------{{ignore}} 5 | system {{_start_}} 6 | security {{_start_}} 7 | cpm-filter {{_start_}} 8 | default-action drop {{default-action | set(drop)}} 9 | 10 | ip-filter {{_start_}} 11 | no shutdown{{admin_state | _exact_ | set(true)}} 12 | shutdown{{admin_state | _exact_ | set(false)}} 13 | 14 | entry {{entry-id | _start_ }} create 15 | action {{action | ORPHRASE}} 16 | description "{{description | ORPHRASE}}" 17 | log {{log-id}} 18 | 19 | match protocol {{protocol | _start_}} 20 | src-ip {{src-ip-address | PREFIX}} 21 | src-ip ip-prefix-list "{{src-ip-prefix-list}}" 22 | dst-ip {{dst-ip-address | PREFIX}} 23 | dst-ip ip-prefix-list "{{dst-ip-prefix-list}}" 24 | src-port {{ src-port | ORPHRASE | split(' ')}} 25 | dst-port {{ dst-port | ORPHRASE | split(' ')}} 26 | icmp-type {{icmp-type}} 27 | exit {{_end_}} 28 | 29 | 30 | match {{_start_}} 31 | src-ip {{src-ip-address | PREFIX}} 32 | src-ip ip-prefix-list "{{src-ip-prefix-list}}" 33 | dst-ip {{dst-ip-address | PREFIX}} 34 | dst-ip ip-prefix-list "{{dst-ip-prefix-list}}" 35 | exit {{_end_}} 36 | 37 | exit {{_end_}} 38 | 39 | exit {{_end_}} 40 | 41 | 42 | ipv6-filter {{_start_}} 43 | no shutdown{{admin_state | _exact_ | set(true)}} 44 | shutdown{{admin_state | _exact_ | set(false)}} 45 | 46 | entry {{entry-id | _start_ }} create 47 | action {{action | ORPHRASE}} 48 | description "{{description | ORPHRASE}}" 49 | log {{log-id}} 50 | 51 | match next-header {{protocol | _start_}} 52 | src-ip {{src-ipv6-address | PREFIXV6 }} 53 | src-ip ipv6-prefix-list "{{src-ipv6-prefix-list}}" 54 | dst-ip {{dst-ipv6-address | PREFIXV6}} 55 | dst-ip ipv6-prefix-list "{{dst-ipv6-prefix-list}}" 56 | src-port {{ src-port | ORPHRASE | split(' ')}} 57 | dst-port {{ dst-port | ORPHRASE | split(' ')}} 58 | exit {{_end_}} 59 | 60 | exit {{_end_}} 61 | 62 | exit {{_end_}} 63 | 64 | exit {{_end_}} 65 | exit {{_end_}} 66 | exit {{_end_}} 67 | #-------------------------------------------------- {{ignore}} 68 | echo "System Login Control Configuration" {{_end_}} 69 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_system_service_customer.ttp: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------- {{ignore}} 2 | echo "Service Configuration" {{ignore}} 3 | #-------------------------------------------------- {{ignore}} 4 | service {{_start_}} 5 | 6 | customer {{customer-id}} name {{customer-name | strip('"')}} create 7 | description {{description | strip('"')}} 8 | exit {{_end_}} 9 | 10 | #-------------------------------------------------- {{_end_}} 11 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_system_time_ntp.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ignore}} 3 | echo "System Time NTP Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ignore}} 5 | system {{_ignore_}} 6 | time {{_ignore_}} 7 | 8 | ntp {{_start_}} 9 | server {{ address | _line_ | IP | to_list}} 10 | exit {{_ignore_}} 11 | 12 | exit {{_ignore_}} 13 | exit {{_end_}} 14 | 15 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_twamp_light_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | #--------------------------------------------------{{ignore}} 3 | echo "TWAMP Light Configuration" {{_start_}} 4 | #--------------------------------------------------{{ignore}} 5 | twamp-light {{_ignore_}} 6 | 7 | reflector udp-port {{udp_port | DIGIT | _start_}} create 8 | description "{{description | ORPHRASE}}" 9 | 10 | prefix {{prefix | PREFIX | _start_}} create 11 | description "{{description | ORPHRASE}}" 12 | exit {{_end_}} 13 | 14 | no shutdown {{admin_state | set(true)}} 15 | exit {{_end_}} 16 | 17 | exit {{_end_}} 18 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/admin_display_file/sros_vrrp_config.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ignore}} 3 | echo "Vrrp Configuration" {{_start_}} 4 | #-------------------------------------------------- {{ignore}} 5 | vrrp {{_start_}} 6 | 7 | policy {{id | DIGIT}} 8 | delta-in-use-limit {{delta-in-use-limit | DIGIT}} 9 | 10 | priority-event {{_start_}} 11 | 12 | lag-port-down {{id | DIGIT }} 13 | hold-clear {{hold-clear | DIGIT}} 14 | 15 | number-down {{id | DIGIT}} 16 | priority {{priority | DIGIT}} delta 17 | exit {{_end_}} 18 | 19 | exit {{_end_}} 20 | 21 | exit {{_end_}} 22 | 23 | exit {{_end_}} 24 | 25 | exit {{_end_}} 26 | 27 | #-------------------------------------------------- {{_end_}} -------------------------------------------------------------------------------- /ttp_sros_parser/templates/custom/sros_custom_hostname_asn.ttp: -------------------------------------------------------------------------------- 1 | system {{_start_}} 2 | 3 | name {{hostname | strip('"')}} 4 | 5 | #-------------------------------------------------- {{_end_}} 6 | 7 | echo "Router (Network Side) Configuration" {{ignore}} 8 | #-------------------------------------------------- {{ignore}} 9 | 10 | interface "system" {{_start_}} 11 | autonomous-system {{autonomous-system | re(r"\d.*")}} 12 | 13 | #-------------------------------------------------- {{_end_}} 14 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/helpers/sros_system_asn.ttp: -------------------------------------------------------------------------------- 1 | 2 | #-------------------------------------------------- {{ignore}} 3 | echo "Router (Network Side) Configuration" {{ignore}} 4 | #-------------------------------------------------- {{ignore}} 5 | 6 | interface "system" {{_start_}} 7 | autonomous-system {{autonomous-system | re(r"\d.*")}} 8 | 9 | #-------------------------------------------------- {{_end_}} 10 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/helpers/sros_system_hostname.ttp: -------------------------------------------------------------------------------- 1 | system {{_start_}} 2 | 3 | name {{hostname | strip('"')}} 4 | 5 | #-------------------------------------------------- {{_end_}} -------------------------------------------------------------------------------- /ttp_sros_parser/templates/helpers/sros_system_interface.ttp: -------------------------------------------------------------------------------- 1 | 2 | router {{ignore}} 3 | 4 | interface {{interface_name | re('"system"') | strip('"')}} 5 | shutdown {{admin_state | set(false)}} 6 | description {{description | strip('"')}} 7 | enable-ingress-stats {{ingress_stats | set(true)}} 8 | 9 | address {{address}}/{{prefix_length}} 10 | 11 | port {{port}} 12 | 13 | ipv6 {{_start_}} 14 | 15 | address {{ipv6_address}}/{{prefix_length}} 16 | 17 | 18 | 19 | exit {{ignore}} 20 | 21 | exit {{ignore}} 22 | 23 | qos {{network-policy}} 24 | 25 | no shutdown {{admin_state | set(true)}} 26 | exit {{_end_}} 27 | 28 | #-------------------------------------------------- {{_end_}} 29 | 30 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/show_commands/show_router_router_table_general.ttp: -------------------------------------------------------------------------------- 1 | =============================================================================== {{ ignore }} 2 | 3 | 4 | {{ route_table | ORPHRASE }} ({{ router }}: {{ instance }}) 5 | 6 | =============================================================================== {{ ignore }} 7 | Dest Prefix[Flags] Type Proto Age Pref {{ ignore }} 8 | Next Hop[Interface Name] Metric {{ ignore }} 9 | ------------------------------------------------------------------------------- {{ ignore }} 10 | 11 | {{ dest_prefix }} {{ type }} {{ protocol }} {{ age }} {{ pref | DIGIT}} 12 | {{ next_hop }} {{ metric | DIGIT }} 13 | 14 | ------------------------------------------------------------------------------- {{ ignore }} 15 | 16 | No. of Routes: {{ count | DIGIT }} 17 | 18 | 19 | Flags: n = Number of times nexthop is repeated {{ ignore }} 20 | B = BGP backup route available {{ ignore }} 21 | L = LFA nexthop available {{ ignore }} 22 | S = Sticky ECMP requested {{ ignore }} 23 | =============================================================================== {{ ignore }} 24 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/show_commands/sros_file_dir.ttp: -------------------------------------------------------------------------------- 1 | 2 | def set_dir(data): 3 | if "DIR" in data: 4 | return data, {'DIR': True} 5 | def find_slot(data): 6 | if "slot A" in data: 7 | return data, {"slot": "A"} 8 | elif "slot B" in data: 9 | return data, {"slot": "B"} 10 | 11 | 12 | 13 | 14 | Volume {{volume | PHRASE | macro("find_slot")}} 15 | 16 | 17 | Directory {{cf-card | PHRASE | strip('of ')}}:\ 18 | 19 | 20 | {{date}} {{time}} {{DIR | re(r".DIR.") | macro("set_dir") }} {{directory}} 21 | 22 | 23 | {{date}} {{time}} {{size | DIGIT}} {{filename}} 24 | 25 | 26 | {{total-files | DIGIT}} File(s) {{bytes-used}} bytes. 27 | {{total-dirs | DIGIT}} Dir(s) {{bytes-free | DIGIT}} bytes free. 28 | 29 | 30 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/show_commands/sros_show_bof_cli.ttp: -------------------------------------------------------------------------------- 1 | 2 | =============================================================================== {{ignore}} 3 | BOF (Memory) {{_start_}} 4 | =============================================================================== {{ignore}} 5 | 6 | primary-image {{cf-card}}:\{{primary-image}}\ 7 | secondary-image {{cf-card}}:\{{secondary-image}}\ 8 | 9 | 10 | primary-config {{cf-card}}:\{{primary-config}} 11 | secondary-config {{cf-card}}:\{{secondary-config}} 12 | 13 | 14 | address {{address}}/{{prefix-length}} active 15 | address {{address}}/{{prefix-length}} active 16 | 17 | primary-dns {{primary-dns}} 18 | secondary-dns {{secondary-dns}} 19 | dns-domain {{dns-domain}} 20 | 21 | static-route {{network}} next-hop {{next-hop}} 22 | 23 | autonegotiate {{autonegotiate | set(true)}} 24 | no autonegotiate {{autonegotiate | set(false)}} 25 | duplex {{duplex}} 26 | speed {{speed}} 27 | wait {{wait}} 28 | persist {{persist}} 29 | no li-local-save {{ignore}} 30 | no li-separate {{ignore}} 31 | no fips-140-2 {{ignore}} 32 | console-speed {{console-speed}} 33 | 34 | =============================================================================== {{_end_}} 35 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/show_commands/sros_show_router_interface.ttp: -------------------------------------------------------------------------------- 1 | 2 | =============================================================================== {{ignore}} 3 | Interface Table (Router: Base) {{ignore}} 4 | =============================================================================== {{ignore}} 5 | ------------------------------------------------------------------------------- {{_start_}} 6 | 7 | {{interface-name}} {{admin-state}} {{ipv4}}/{{ipv6}} {{mode}} {{port-sap-id}} 8 | 9 | {{prefix}}/{{prefix-length}} {{pfx-state}} 10 | 11 | ------------------------------------------------------------------------------- {{_end_}} 12 | 13 | 14 | Interfaces : {{total | DIGIT}} 15 | 16 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/show_commands/sros_show_router_route_table.ttp: -------------------------------------------------------------------------------- 1 | 2 | =============================================================================== {{ignore}} 3 | Route Table (Router: Base) {{_start_}}{{_exact_}} 4 | 5 | =============================================================================== {{ignore}} 6 | Dest Prefix[Flags] Type Proto Age Pref {{ignore}} 7 | Next Hop[Interface Name] Metric {{ignore}} 8 | ------------------------------------------------------------------------------- {{ignore}} 9 | 10 | {{ipaddress | PREFIX}} {{type}} {{protocol}} {{age}} {{pref}} 11 | 12 | {{next-hop | re(r'.+') | strip()}} {{metric | DIGIT}} 13 | 14 | 15 | ------------------------------------------------------------------------------- {{ignore}} 16 | 17 | No. of Routes: {{total-routes | DIGIT}} 18 | 19 | Flags: n = Number of times nexthop is repeated {{ignore}} 20 | B = BGP backup route available {{ignore}} 21 | L = LFA nexthop available {{ignore}} 22 | S = Sticky ECMP requested {{ignore}} 23 | =============================================================================== {{_end_}}{{exact}} 24 | 25 | IPv6 Route Table (Router: Base) {{_end_}} 26 | 27 | 28 | 29 | =============================================================================== {{ignore}} 30 | IPv6 Route Table (Router: Base) {{_start_}}{{_exact_}} 31 | 32 | =============================================================================== {{ignore}} 33 | Dest Prefix[Flags] Type Proto Age Pref {{ignore}} 34 | Next Hop[Interface Name] Metric {{ignore}} 35 | ------------------------------------------------------------------------------- {{ignore}} 36 | 37 | {{ipaddress | PREFIXV6}} {{type}} {{protocol}} {{age}} {{pref}} 38 | 39 | {{next-hop | re(r'.+')|strip()|resub('"','')|strip('"')}} {{metric | DIGIT}} 40 | 41 | 42 | ------------------------------------------------------------------------------- {{ignore}} 43 | 44 | No. of Routes: {{total-routes | DIGIT}} 45 | 46 | Flags: n = Number of times nexthop is repeated {{ignore}} 47 | B = BGP backup route available {{ignore}} 48 | L = LFA nexthop available {{ignore}} 49 | S = Sticky ECMP requested {{ignore}} 50 | =============================================================================== {{_end_}}{{exact}} 51 | 52 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/show_commands/sros_show_router_static_route_ipv4.ttp: -------------------------------------------------------------------------------- 1 | 2 | =============================================================================== {{ignore}} 3 | Static Route Table (Router: Base) Family: IPv4 {{_start_}}{{_exact_}} 4 | =============================================================================== {{ignore}} 5 | Prefix Tag Met Pref Type Act {{ignore}} 6 | Next Hop Interface {{ignore}} 7 | ------------------------------------------------------------------------------- {{ignore}} 8 | 9 | {{ipaddress | PREFIX}} {{tag | DIGIT}} {{metric | DIGIT}} {{preference | DIGIT}} {{type}} {{active}} 10 | 11 | {{next_hop}} 12 | 13 | 14 | 15 | No. of Static Routes: {{total_routes | DIGIT}} 16 | =============================================================================== {{_end_}} 17 | 18 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/show_commands/sros_show_router_static_route_ipv6.ttp: -------------------------------------------------------------------------------- 1 | 2 | =============================================================================== {{ignore}} 3 | Static Route Table (Router: Base) Family: IPv6 {{_start_}}{{_exact_}} 4 | 5 | =============================================================================== {{ignore}} 6 | Prefix Tag Met Pref Type Act {{ignore}} 7 | Next Hop Interface {{ignore}} 8 | ------------------------------------------------------------------------------- {{ignore}} 9 | 10 | {{ipaddress | PREFIXV6}} {{tag | DIGIT}} {{metric | DIGIT}} {{preference | DIGIT}} {{type}} {{active}} 11 | 12 | {{next-hop}} {{interface}} 13 | 14 | 15 | 16 | No. of Static Routes: {{total-routes | DIGIT}} 17 | =============================================================================== {{_end_}} 18 | 19 | 20 | -------------------------------------------------------------------------------- /ttp_sros_parser/templates/show_commands/sros_show_service_service_using.ttp: -------------------------------------------------------------------------------- 1 | 2 | =============================================================================== {{ignore}} 3 | Services {{ignore}} 4 | =============================================================================== {{ignore}} 5 | ------------------------------------------------------------------------------- {{ignore}} 6 | 7 | {{service-id | DIGIT}} {{service-type}} {{admin-state}} {{operational-state}} {{customer-id | DIGIT}} {{service-name}} 8 | ------------------------------------------------------------------------------- {{_end_}} 9 | 10 | 11 | Matching Services : {{total-services | DIGIT}} 12 | ------------------------------------------------------------------------------- {{ignore}} 13 | =============================================================================== {{ignore}} 14 | 15 | --------------------------------------------------------------------------------