Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network_template.py: add support for multiple shared variables #568

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tnizharadze
Copy link
Contributor

SUMMARY

This pull request add support for multiple shared variables in "parse" method of class "NetworkTemplate"

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

network_template.py
class NetworkTemplate(RmEngineBase):
def parse(self):

ADDITIONAL INFORMATION

Suppose that we have this configuration in network device:

l2vpn evpn instance 123 point-to-point
 rd 222:222
 route-target export 33:44
 route-target import 33:44
 no auto-route-target
 vpws context TEST
  service target 44 source 77
  member Vlan10
  remote link failure notification
 !
 vpws context TEST2
  member Vlan11
  remote link failure notification
  shutdown
 !
l2vpn evpn instance 124 point-to-point
 rd 333:333
 route-target export 43:45
 route-target import 43:45
 route-target export 45:55
 route-target import 45:55
 vpws context TEST3
  member Vlan12
  remote link failure notification
  shutdown
 !
 vpws context TEST4
  service target 55 source 55
  member Vlan14
  remote link failure notification
 !

As we can see there is two shared objects - instance number and context name within specific instance.
The easiest way to parse this type of configuration is to get multiple shared variables (which isn't currently supported).
With this patch parsers will look like this:

    PARSERS = [
        {
            "name": "instance",
            "getval": re.compile(
                r"""
                l2vpn\sevpn\sinstance\s(?P<instance>\S+)\spoint-to-point
                \s*
                $""", re.VERBOSE,
            ),
            "setval": "l2vpn evpn instance {{ instance }} point-to-point",
            "result": {
                "{{ instance }}": {
                    "instance": "{{ instance }}",
                },
            },
            "shared": True,
        },
        {
            "name": "vpws_context",
            "getval": re.compile(
                r"""
                \svpws\scontext\s(?P<context>\S+)
                \s*
                $""", re.VERBOSE,
            ),
            "setval": "vpws context {{ context }}",
            "result": {
                "{{ instance }}": {
                    "vpws_context": {
                        "{{ context }}": {
                            "context": "{{ context }}",
                        },
                    },
                },
            },
            "shared": True,
        },
  ]

@codecov
Copy link

codecov bot commented Jul 18, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@b5bb3ee). Click here to learn what that means.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #568   +/-   ##
=======================================
  Coverage        ?   64.47%           
=======================================
  Files           ?       31           
  Lines           ?     3868           
  Branches        ?      685           
=======================================
  Hits            ?     2494           
  Misses          ?     1231           
  Partials        ?      143           

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/b391f9bad8a541a1a0550a6d4df36fc0

ansible-test-network-integration-junos-vsrx-netconf-python36-stable29 FAILURE in 13m 52s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python36-stable211 SUCCESS in 1h 24m 00s
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39-stable212 SUCCESS in 1h 10m 29s
ansible-test-network-integration-junos-vsrx-netconf-python39 RETRY_LIMIT in 6m 03s
ansible-test-network-integration-junos-vsrx-network_cli-python36-stable29 FAILURE in 12m 16s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python36-stable211 SUCCESS in 16m 50s
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable212 SUCCESS in 15m 46s
ansible-test-network-integration-junos-vsrx-network_cli-python39 RETRY_LIMIT in 5m 57s
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable29 FAILURE in 13m 28s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable211 SUCCESS in 16m 40s
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable212 FAILURE in 24m 38s
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39 RETRY_LIMIT in 7m 56s
ansible-test-network-integration-nxos-cli-python39-scenario01 RETRY_LIMIT in 6m 04s (non-voting)
ansible-test-network-integration-nxos-cli-python39-scenario02 RETRY_LIMIT in 5m 12s (non-voting)
ansible-test-network-integration-nxos-cli-python39-scenario03 RETRY_LIMIT in 6m 20s (non-voting)
ansible-test-network-integration-nxos-cli-python39-scenario04 RETRY_LIMIT in 5m 06s (non-voting)
ansible-test-network-integration-eos-network_cli-python39 RETRY_LIMIT in 8m 57s (non-voting)
ansible-test-network-integration-eos-httpapi-python39 RETRY_LIMIT in 7m 06s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39 RETRY_LIMIT in 8m 12s (non-voting)
ansible-ee-integration-ios-latest FAILURE in 13m 46s (non-voting)
ansible-ee-integration-ios-stable-2.9 FAILURE in 19m 11s (non-voting)
ansible-ee-integration-ios-stable-2.11 FAILURE in 13m 16s (non-voting)
ansible-ee-integration-ios-stable-2.12 FAILURE in 19m 28s (non-voting)
ansible-ee-integration-ios-libssh-latest FAILURE in 20m 34s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.9 FAILURE in 19m 19s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.11 FAILURE in 19m 16s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.12 FAILURE in 13m 09s (non-voting)
ansible-test-network-integration-vyos-paramiko-python39-devel NODE_FAILURE Node request 200-0006210116 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable214 NODE_FAILURE Node request 200-0006210117 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable213 NODE_FAILURE Node request 200-0006210118 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable212 NODE_FAILURE Node request 200-0006210119 failed in 0s
ansible-test-network-integration-vyos-paramiko-python36-stable29 NODE_FAILURE Node request 200-0006210120 failed in 0s (non-voting)
ansible-test-network-integration-vyos-libssh-python39-devel NODE_FAILURE Node request 200-0006210121 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable214 NODE_FAILURE Node request 200-0006210122 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable213 NODE_FAILURE Node request 200-0006210123 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable212 NODE_FAILURE Node request 200-0006210124 failed in 0s
ansible-test-network-integration-vyos-libssh-python36-stable29 NODE_FAILURE Node request 200-0006210125 failed in 0s
✔️ build-ansible-collection SUCCESS in 14m 58s
ansible-test-network-integration-ansible-netcommon-junos-vsrx-netconf-python39 RETRY_LIMIT in 1m 06s
✔️ ansible-tox-linters SUCCESS in 10m 31s
✔️ ansible-galaxy-importer SUCCESS in 4m 22s

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/41d3e4b05b254f1da0f625de066c992d

ansible-test-network-integration-junos-vsrx-netconf-python36-stable29 FAILURE in 13m 36s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python36-stable211 SUCCESS in 1h 13m 35s
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39-stable212 SUCCESS in 1h 04m 10s
ansible-test-network-integration-junos-vsrx-netconf-python39 RETRY_LIMIT in 8m 43s
ansible-test-network-integration-junos-vsrx-network_cli-python36-stable29 FAILURE in 12m 23s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python36-stable211 SUCCESS in 17m 07s
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable212 SUCCESS in 15m 43s
ansible-test-network-integration-junos-vsrx-network_cli-python39 RETRY_LIMIT in 7m 25s
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable29 FAILURE in 15m 28s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable211 SUCCESS in 16m 25s
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable212 FAILURE in 13m 07s
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39 RETRY_LIMIT in 7m 45s
ansible-test-network-integration-nxos-cli-python39-scenario01 RETRY_LIMIT in 9m 05s (non-voting)
ansible-test-network-integration-nxos-cli-python39-scenario02 RETRY_LIMIT in 5m 05s (non-voting)
ansible-test-network-integration-nxos-cli-python39-scenario03 RETRY_LIMIT in 9m 03s (non-voting)
ansible-test-network-integration-nxos-cli-python39-scenario04 RETRY_LIMIT in 4m 52s (non-voting)
ansible-test-network-integration-eos-network_cli-python39 RETRY_LIMIT in 1m 09s (non-voting)
ansible-test-network-integration-eos-httpapi-python39 RETRY_LIMIT in 5m 41s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39 RETRY_LIMIT in 1m 19s (non-voting)
ansible-ee-integration-ios-latest FAILURE in 13m 42s (non-voting)
ansible-ee-integration-ios-stable-2.9 FAILURE in 12m 22s (non-voting)
ansible-ee-integration-ios-stable-2.11 FAILURE in 13m 48s (non-voting)
ansible-ee-integration-ios-stable-2.12 FAILURE in 13m 57s (non-voting)
ansible-ee-integration-ios-libssh-latest FAILURE in 17m 46s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.9 FAILURE in 17m 24s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.11 FAILURE in 17m 37s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.12 FAILURE in 12m 21s (non-voting)
ansible-test-network-integration-vyos-paramiko-python39-devel NODE_FAILURE Node request 200-0006211213 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable214 NODE_FAILURE Node request 200-0006211214 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable213 NODE_FAILURE Node request 200-0006211215 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable212 NODE_FAILURE Node request 200-0006211216 failed in 0s
ansible-test-network-integration-vyos-paramiko-python36-stable29 NODE_FAILURE Node request 200-0006211217 failed in 0s (non-voting)
ansible-test-network-integration-vyos-libssh-python39-devel NODE_FAILURE Node request 200-0006211218 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable214 NODE_FAILURE Node request 200-0006211219 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable213 NODE_FAILURE Node request 200-0006211220 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable212 NODE_FAILURE Node request 200-0006211221 failed in 0s
ansible-test-network-integration-vyos-libssh-python36-stable29 NODE_FAILURE Node request 200-0006211222 failed in 0s
✔️ build-ansible-collection SUCCESS in 14m 35s
ansible-test-network-integration-ansible-netcommon-junos-vsrx-netconf-python39 RETRY_LIMIT in 7m 23s
✔️ ansible-tox-linters SUCCESS in 10m 29s
✔️ ansible-galaxy-importer SUCCESS in 5m 04s

@NilashishC NilashishC self-requested a review March 6, 2024 10:31
@Ruchip16 Ruchip16 added the feature This issue/PR relates to a feature request. label Mar 7, 2024
@rohitthakur2590 rohitthakur2590 removed the request for review from NilashishC July 10, 2024 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants