How to use the napalm.base.helpers.regex_find_txt function in napalm

To help you get started, we’ve selected a few napalm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github napalm-automation / napalm / napalm / ios / ios.py View on Github external
r"route-map ([^\s]+) out", neighbor_config
            )
            import_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) in", neighbor_config
            )
            local_address = napalm.base.helpers.regex_find_txt(
                r" update-source (\w+)", neighbor_config
            )
            local_as = napalm.base.helpers.regex_find_txt(
                r"local-as (\d+)", neighbor_config, default=0
            )
            password = napalm.base.helpers.regex_find_txt(
                r"password (?:[0-9] )?([^\']+\')", neighbor_config
            )
            nhs = bool(
                napalm.base.helpers.regex_find_txt(r" next-hop-self", neighbor_config)
            )
            route_reflector_client = bool(
                napalm.base.helpers.regex_find_txt(
                    r"route-reflector-client", neighbor_config
                )
            )

            # Add the group name to bgp_group_neighbors if its not there already
            if group_name not in bgp_group_neighbors.keys():
                bgp_group_neighbors[group_name] = {}

            # Build the neighbor dict of attributes
            bgp_group_neighbors[group_name][bgp_neighbor] = {
                "description": description,
                "remote_as": peer_as,
                "prefix_limit": build_prefix_limit(
github napalm-automation / napalm / napalm / ios / ios.py View on Github external
r"route-map ([^\s]+) in", neighbor_config
            )
            local_address = napalm.base.helpers.regex_find_txt(
                r" update-source (\w+)", neighbor_config
            )
            local_as = napalm.base.helpers.regex_find_txt(
                r"local-as (\d+)", neighbor_config, default=0
            )
            password = napalm.base.helpers.regex_find_txt(
                r"password (?:[0-9] )?([^\']+\')", neighbor_config
            )
            nhs = bool(
                napalm.base.helpers.regex_find_txt(r" next-hop-self", neighbor_config)
            )
            route_reflector_client = bool(
                napalm.base.helpers.regex_find_txt(
                    r"route-reflector-client", neighbor_config
                )
            )

            # Add the group name to bgp_group_neighbors if its not there already
            if group_name not in bgp_group_neighbors.keys():
                bgp_group_neighbors[group_name] = {}

            # Build the neighbor dict of attributes
            bgp_group_neighbors[group_name][bgp_neighbor] = {
                "description": description,
                "remote_as": peer_as,
                "prefix_limit": build_prefix_limit(
                    afi, prefix_limit, prefix_percent, prefix_timeout
                ),
                "export_policy": export_policy,
github napalm-automation / napalm / napalm / ios / ios.py View on Github external
prefix_limit = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix (\d+) \d+ \w+ \d+", neighbor_config, default=0
            )
            prefix_percent = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ (\d+) \w+ \d+", neighbor_config, default=0
            )
            prefix_timeout = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ \d+ \w+ (\d+)", neighbor_config, default=0
            )
            export_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) out", neighbor_config
            )
            import_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) in", neighbor_config
            )
            local_address = napalm.base.helpers.regex_find_txt(
                r" update-source (\w+)", neighbor_config
            )
            local_as = napalm.base.helpers.regex_find_txt(
                r"local-as (\d+)", neighbor_config, default=0
            )
            password = napalm.base.helpers.regex_find_txt(
                r"password (?:[0-9] )?([^\']+\')", neighbor_config
            )
            nhs = bool(
                napalm.base.helpers.regex_find_txt(r" next-hop-self", neighbor_config)
            )
            route_reflector_client = bool(
                napalm.base.helpers.regex_find_txt(
                    r"route-reflector-client", neighbor_config
                )
            )
github napalm-automation / napalm / napalm / ios / ios.py View on Github external
for afi in afi_list:
                afi_config = napalm.base.helpers.cisco_conf_parse_objects(
                    afi, bgp_config_text
                )
                multipath = bool(
                    napalm.base.helpers.regex_find_txt(r" multipath", str(afi_config))
                )
                if multipath:
                    break
            description = napalm.base.helpers.regex_find_txt(
                r" description ([^\']+)\'", neighbor_config
            )
            local_as = napalm.base.helpers.regex_find_txt(
                r"local-as (\d+)", neighbor_config, default=0
            )
            import_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) in", neighbor_config
            )
            export_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) out", neighbor_config
            )
            local_address = napalm.base.helpers.regex_find_txt(
                r" update-source (\w+)", neighbor_config
            )
            multihop_ttl = napalm.base.helpers.regex_find_txt(
                r"ebgp-multihop {\d+}", neighbor_config, default=0
            )
            peer_as = napalm.base.helpers.regex_find_txt(
                r" remote-as (\d+)", neighbor_config, default=0
            )
            remove_private_as = bool(
                napalm.base.helpers.regex_find_txt(
github napalm-automation / napalm / napalm / ios / ios.py View on Github external
description = napalm.base.helpers.regex_find_txt(
                r" description ([^\']+)\'", neighbor_config
            )
            local_as = napalm.base.helpers.regex_find_txt(
                r"local-as (\d+)", neighbor_config, default=0
            )
            import_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) in", neighbor_config
            )
            export_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) out", neighbor_config
            )
            local_address = napalm.base.helpers.regex_find_txt(
                r" update-source (\w+)", neighbor_config
            )
            multihop_ttl = napalm.base.helpers.regex_find_txt(
                r"ebgp-multihop {\d+}", neighbor_config, default=0
            )
            peer_as = napalm.base.helpers.regex_find_txt(
                r" remote-as (\d+)", neighbor_config, default=0
            )
            remove_private_as = bool(
                napalm.base.helpers.regex_find_txt(
                    r"remove-private-as", neighbor_config
                )
            )
            prefix_limit = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix (\d+) \d+ \w+ \d+", neighbor_config, default=0
            )
            prefix_percent = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ (\d+) \w+ \d+", neighbor_config, default=0
            )
github napalm-automation / napalm / napalm / ios / ios.py View on Github external
local_as = napalm.base.helpers.regex_find_txt(
                r"local-as (\d+)", neighbor_config, default=0
            )
            import_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) in", neighbor_config
            )
            export_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) out", neighbor_config
            )
            local_address = napalm.base.helpers.regex_find_txt(
                r" update-source (\w+)", neighbor_config
            )
            multihop_ttl = napalm.base.helpers.regex_find_txt(
                r"ebgp-multihop {\d+}", neighbor_config, default=0
            )
            peer_as = napalm.base.helpers.regex_find_txt(
                r" remote-as (\d+)", neighbor_config, default=0
            )
            remove_private_as = bool(
                napalm.base.helpers.regex_find_txt(
                    r"remove-private-as", neighbor_config
                )
            )
            prefix_limit = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix (\d+) \d+ \w+ \d+", neighbor_config, default=0
            )
            prefix_percent = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ (\d+) \w+ \d+", neighbor_config, default=0
            )
            prefix_timeout = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ \d+ \w+ (\d+)", neighbor_config, default=0
            )
github napalm-automation / napalm / napalm / ios / ios.py View on Github external
prefix_timeout = napalm.base.helpers.regex_find_txt(
                r"maximum-prefix \d+ \d+ \w+ (\d+)", neighbor_config, default=0
            )
            export_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) out", neighbor_config
            )
            import_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) in", neighbor_config
            )
            local_address = napalm.base.helpers.regex_find_txt(
                r" update-source (\w+)", neighbor_config
            )
            local_as = napalm.base.helpers.regex_find_txt(
                r"local-as (\d+)", neighbor_config, default=0
            )
            password = napalm.base.helpers.regex_find_txt(
                r"password (?:[0-9] )?([^\']+\')", neighbor_config
            )
            nhs = bool(
                napalm.base.helpers.regex_find_txt(r" next-hop-self", neighbor_config)
            )
            route_reflector_client = bool(
                napalm.base.helpers.regex_find_txt(
                    r"route-reflector-client", neighbor_config
                )
            )

            # Add the group name to bgp_group_neighbors if its not there already
            if group_name not in bgp_group_neighbors.keys():
                bgp_group_neighbors[group_name] = {}

            # Build the neighbor dict of attributes
github napalm-automation / napalm / napalm / ios / ios.py View on Github external
)
                multipath = bool(
                    napalm.base.helpers.regex_find_txt(r" multipath", str(afi_config))
                )
                if multipath:
                    break
            description = napalm.base.helpers.regex_find_txt(
                r" description ([^\']+)\'", neighbor_config
            )
            local_as = napalm.base.helpers.regex_find_txt(
                r"local-as (\d+)", neighbor_config, default=0
            )
            import_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) in", neighbor_config
            )
            export_policy = napalm.base.helpers.regex_find_txt(
                r"route-map ([^\s]+) out", neighbor_config
            )
            local_address = napalm.base.helpers.regex_find_txt(
                r" update-source (\w+)", neighbor_config
            )
            multihop_ttl = napalm.base.helpers.regex_find_txt(
                r"ebgp-multihop {\d+}", neighbor_config, default=0
            )
            peer_as = napalm.base.helpers.regex_find_txt(
                r" remote-as (\d+)", neighbor_config, default=0
            )
            remove_private_as = bool(
                napalm.base.helpers.regex_find_txt(
                    r"remove-private-as", neighbor_config
                )
            )