cisco-config-parser 2.1__tar.gz → 2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/PKG-INFO +85 -2
  2. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/README.md +84 -1
  3. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/global_search/global_parser.py +3 -1
  4. cisco_config_parser-2.1/cisco_config_parser/testing.py → cisco_config_parser-2.2/cisco_config_parser/helper/__init__.py +0 -0
  5. cisco_config_parser-2.2/cisco_config_parser/helper/help.py +73 -0
  6. cisco_config_parser-2.2/cisco_config_parser/helper/helper.py +23 -0
  7. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/layer3_interface/l3_interface_obj.py +2 -1
  8. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/layer3_interface/l3_interface_parser.py +27 -0
  9. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/layer3_interface/l3_section_parser.py +25 -0
  10. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/parser/__init__.py +36 -2
  11. cisco_config_parser-2.2/cisco_config_parser/parser/parser.py +201 -0
  12. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/parser_regex/regex.py +46 -1
  13. cisco_config_parser-2.2/cisco_config_parser/routing_protocol/__init__.py +4 -0
  14. cisco_config_parser-2.2/cisco_config_parser/routing_protocol/rtp_dynamic_obj.py +0 -0
  15. cisco_config_parser-2.2/cisco_config_parser/routing_protocol/rtp_dynamic_parser.py +0 -0
  16. cisco_config_parser-2.2/cisco_config_parser/routing_protocol/rtp_ios_obj.py +68 -0
  17. cisco_config_parser-2.2/cisco_config_parser/routing_protocol/rtp_ios_parser.py +448 -0
  18. cisco_config_parser-2.2/cisco_config_parser/routing_protocol/rtp_separator.py +130 -0
  19. cisco_config_parser-2.2/cisco_config_parser/testing.py +0 -0
  20. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser.egg-info/PKG-INFO +85 -2
  21. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser.egg-info/SOURCES.txt +9 -0
  22. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/setup.py +1 -1
  23. cisco_config_parser-2.1/cisco_config_parser/parser/parser.py +0 -101
  24. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/__init__.py +0 -0
  25. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/cisco_config_parser.py +0 -0
  26. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/global_search/__init__.py +0 -0
  27. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/global_search/global_obj.py +0 -0
  28. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/global_search/global_separator.py +0 -0
  29. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/layer2_interface/__init__.py +0 -0
  30. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/layer2_interface/l2_interface_obj.py +0 -0
  31. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/layer2_interface/l2_interface_parser.py +1 -1
  32. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/layer2_interface/l2_interface_separator.py +0 -0
  33. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/layer2_interface/l2_section_parser.py +0 -0
  34. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/layer3_interface/__init__.py +0 -0
  35. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/layer3_interface/l3_interface_separator.py +0 -0
  36. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/old_version/__init__.py +0 -0
  37. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/old_version/exceptions.py +0 -0
  38. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/old_version/obj.py +0 -0
  39. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/old_version/old_parse.py +0 -0
  40. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/old_version/ssh.py +0 -0
  41. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/old_version/utils.py +0 -0
  42. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/parent_child/__init__.py +0 -0
  43. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/parent_child/parent_child_obj.py +0 -0
  44. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/parent_child/parent_child_parser.py +0 -0
  45. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/parent_child/parent_child_separator.py +0 -0
  46. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/parser_regex/__init__.py +0 -0
  47. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/separator/__init__.py +0 -0
  48. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/separator/separator.py +0 -0
  49. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser/setup.py +0 -0
  50. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser.egg-info/dependency_links.txt +0 -0
  51. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/cisco_config_parser.egg-info/top_level.txt +0 -0
  52. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/pyproject.toml +0 -0
  53. {cisco_config_parser-2.1 → cisco_config_parser-2.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cisco_config_parser
3
- Version: 2.1
3
+ Version: 2.2
4
4
  Summary: This Package Will Parse Cisco IOS, IOS-XE, IOS-XR and NXOS Configuration File.
5
5
  Home-page: https://github.com/arezazadeh/cisco_config_parser
6
6
  Author: Ahmad Rezazadeh
@@ -12,7 +12,89 @@ Description-Content-Type: text/markdown
12
12
  ## This Package Will Parse Cisco IOS, IOS-XE, IOS-XR, and NXOS Configuration File.
13
13
 
14
14
 
15
- # New Version 2.0
15
+ # New Version 2.0
16
+
17
+ ## Classes in this library
18
+
19
+ ```python
20
+ IOSRouteParser
21
+ L3InterfaceParser
22
+ L2InterfaceParser
23
+ ParentChildParser
24
+ ```
25
+ there more Classes are being built, and will be released in the upcoming versions.
26
+
27
+ ## Get Example usage:
28
+
29
+ ```python
30
+ from cisco_config_parser.helper import helper
31
+
32
+ helper = helper.IOSRouteParser()
33
+
34
+ print(helper)
35
+ ```
36
+
37
+ **Output**:
38
+ ```
39
+
40
+ Example Usage:
41
+ ====================================================================================================
42
+
43
+ with open("show_run.txt", "r") as file_output:
44
+ content = file_output.read()
45
+
46
+
47
+ obj = ConfigParser(content)
48
+
49
+
50
+ #
51
+ ##
52
+ ###
53
+ #### Static Routes Example:
54
+ ###
55
+ ##
56
+ #
57
+ obj.get_static_routes()
58
+ obj.get_static_routes(return_json=True)
59
+
60
+
61
+ #
62
+ ##
63
+ ###
64
+ #### OSPF Example:
65
+ ###
66
+ ##
67
+ #
68
+ ospf = obj.get_ospf_config(return_json=True)
69
+ ospf = obj.get_ospf_config()
70
+ for i in ospf:
71
+ print(i.children)
72
+ print(i.network)
73
+ print(i.no_passive_interface)
74
+
75
+ #
76
+ ##
77
+ ###
78
+ #### EIGRP Example:
79
+ ###
80
+ ##
81
+ #
82
+ eigrp = obj.get_eigrp_config(return_json=True)
83
+ eigrp = obj.get_eigrp_config()
84
+ for i in eigrp:
85
+ print(i.children)
86
+ print(i.network)
87
+ print(i.vrf_children) << returns a list of EIGRPVrfChildren objects
88
+ vrf_children = i.vrf_children
89
+ for vrf in vrf_children:
90
+ print(vrf.network)
91
+ print(vrf.children)
92
+
93
+
94
+ ```
95
+
96
+
97
+
16
98
 
17
99
  ### 1. Layer3 Interfaces:
18
100
  - added interface details - returns dict of all layer3 interfaces
@@ -20,6 +102,7 @@ Description-Content-Type: text/markdown
20
102
  - platform agnostic
21
103
  - able to set custom regex and create dynamic method
22
104
 
105
+
23
106
  * Example:
24
107
 
25
108
  ```python
@@ -2,7 +2,89 @@
2
2
  ## This Package Will Parse Cisco IOS, IOS-XE, IOS-XR, and NXOS Configuration File.
3
3
 
4
4
 
5
- # New Version 2.0
5
+ # New Version 2.0
6
+
7
+ ## Classes in this library
8
+
9
+ ```python
10
+ IOSRouteParser
11
+ L3InterfaceParser
12
+ L2InterfaceParser
13
+ ParentChildParser
14
+ ```
15
+ there more Classes are being built, and will be released in the upcoming versions.
16
+
17
+ ## Get Example usage:
18
+
19
+ ```python
20
+ from cisco_config_parser.helper import helper
21
+
22
+ helper = helper.IOSRouteParser()
23
+
24
+ print(helper)
25
+ ```
26
+
27
+ **Output**:
28
+ ```
29
+
30
+ Example Usage:
31
+ ====================================================================================================
32
+
33
+ with open("show_run.txt", "r") as file_output:
34
+ content = file_output.read()
35
+
36
+
37
+ obj = ConfigParser(content)
38
+
39
+
40
+ #
41
+ ##
42
+ ###
43
+ #### Static Routes Example:
44
+ ###
45
+ ##
46
+ #
47
+ obj.get_static_routes()
48
+ obj.get_static_routes(return_json=True)
49
+
50
+
51
+ #
52
+ ##
53
+ ###
54
+ #### OSPF Example:
55
+ ###
56
+ ##
57
+ #
58
+ ospf = obj.get_ospf_config(return_json=True)
59
+ ospf = obj.get_ospf_config()
60
+ for i in ospf:
61
+ print(i.children)
62
+ print(i.network)
63
+ print(i.no_passive_interface)
64
+
65
+ #
66
+ ##
67
+ ###
68
+ #### EIGRP Example:
69
+ ###
70
+ ##
71
+ #
72
+ eigrp = obj.get_eigrp_config(return_json=True)
73
+ eigrp = obj.get_eigrp_config()
74
+ for i in eigrp:
75
+ print(i.children)
76
+ print(i.network)
77
+ print(i.vrf_children) << returns a list of EIGRPVrfChildren objects
78
+ vrf_children = i.vrf_children
79
+ for vrf in vrf_children:
80
+ print(vrf.network)
81
+ print(vrf.children)
82
+
83
+
84
+ ```
85
+
86
+
87
+
6
88
 
7
89
  ### 1. Layer3 Interfaces:
8
90
  - added interface details - returns dict of all layer3 interfaces
@@ -10,6 +92,7 @@
10
92
  - platform agnostic
11
93
  - able to set custom regex and create dynamic method
12
94
 
95
+
13
96
  * Example:
14
97
 
15
98
  ```python
@@ -52,4 +52,6 @@ class GlobalParser:
52
52
  ]
53
53
  vlan_objects.append(vlan_obj)
54
54
 
55
- return vlan_objects
55
+ return vlan_objects
56
+
57
+
@@ -0,0 +1,73 @@
1
+
2
+
3
+ RTP_IOS_HELP = """
4
+
5
+ Example Usage:
6
+ ====================================================================================================
7
+
8
+ with open("show_run.txt", "r") as file_output:
9
+ content = file_output.read()
10
+
11
+
12
+ obj = ConfigParser(content)
13
+
14
+
15
+ #
16
+ ##
17
+ ###
18
+ #### Static Routes Example:
19
+ ###
20
+ ##
21
+ #
22
+ obj.get_static_routes()
23
+ obj.get_static_routes(return_json=True)
24
+
25
+
26
+ #
27
+ ##
28
+ ###
29
+ #### OSPF Example:
30
+ ###
31
+ ##
32
+ #
33
+ ospf = obj.get_ospf_config(return_json=True)
34
+ ospf = obj.get_ospf_config()
35
+ for i in ospf:
36
+ print(i.children)
37
+ print(i.network)
38
+ print(i.no_passive_interface)
39
+
40
+ #
41
+ ##
42
+ ###
43
+ #### EIGRP Example:
44
+ ###
45
+ ##
46
+ #
47
+ eigrp = obj.get_eigrp_config(return_json=True)
48
+ eigrp = obj.get_eigrp_config()
49
+ for i in eigrp:
50
+ print(i.children)
51
+ print(i.network)
52
+ print(i.vrf_children) << returns a list of EIGRPVrfChildren objects
53
+ vrf_children = i.vrf_children
54
+ for vrf in vrf_children:
55
+ print(vrf.network)
56
+ print(vrf.children)
57
+ """
58
+ PARENT_CHILD_HELP = """
59
+ Example Usage:
60
+ ====================================================================================================
61
+
62
+ with open("show_run.txt", "r") as file_output:
63
+ content = file_output.read()
64
+
65
+ obj = ConfigParser(content)
66
+
67
+ parent_child = obj.get_parent_child(custom_regex="(^snmp.*)|(^aaa.*)")
68
+
69
+ for i in parent_child:
70
+ print(i.parent)
71
+ print(i.children)
72
+
73
+ """
@@ -0,0 +1,23 @@
1
+ from .help import *
2
+
3
+
4
+ class IOSRouteParser:
5
+ def __repr__(self):
6
+ return RTP_IOS_HELP
7
+
8
+
9
+
10
+ class ParentChild:
11
+ def __repr__(self):
12
+ return PARENT_CHILD_HELP
13
+
14
+
15
+ class L3Interface:
16
+ def __repr__(self):
17
+ return "L3 Interface Usage"
18
+
19
+
20
+
21
+
22
+
23
+
@@ -32,4 +32,5 @@ class L3Interface:
32
32
  """
33
33
  If the attribute is not found, return None
34
34
  """
35
- return None
35
+ return None
36
+
@@ -1,8 +1,13 @@
1
+ import json
2
+
1
3
  from .l3_interface_separator import L3InterfaceSeparator
2
4
  from .l3_interface_obj import L3Interface
3
5
  from .l3_section_parser import _L3SectionParser
4
6
  from cisco_config_parser.parser_regex.regex import *
5
7
  from dataclasses import dataclass
8
+ import re, ipaddress
9
+
10
+
6
11
 
7
12
 
8
13
 
@@ -65,6 +70,7 @@ class L3InterfaceParser:
65
70
  if ip_address_regex:
66
71
  l3_intf_cls = _L3SectionParser._parse_ip_address_line(**ip_address_kwargs)
67
72
 
73
+
68
74
  if sec_ip_address_regex:
69
75
  # set the primary flag to False to indicate that the ip address is a secondary ip address
70
76
  ip_address_kwargs["primary"] = False
@@ -102,5 +108,26 @@ class L3InterfaceParser:
102
108
  return l3_intf_objects
103
109
 
104
110
 
111
+ def _fetch_subnet_and_usage(self, include_subnet_count=False):
112
+ """
113
+ Fetch the subnet usage from the config file
114
+ return: dictionary of subnet usage
115
+ """
105
116
 
117
+ subnet_usage = {}
118
+ subnet_count = {}
119
+ l3_interfaces = self._fetch_l3_interfaces()
120
+ for i in l3_interfaces:
121
+ if i.subnet:
122
+ cidr = str(ipaddress.IPv4Network(i.subnet, strict=False).prefixlen)
123
+ subnet_usage[i.name] = i.subnet
124
+ if subnet_count.get(f"/{cidr}"):
125
+ subnet_count[f"/{cidr}"] += 1
126
+ else:
127
+ subnet_count[f"/{cidr}"] = 1
128
+
129
+ if include_subnet_count:
130
+ subnet_usage["subnet_count"] = subnet_count
131
+
132
+ return subnet_usage
106
133
 
@@ -5,6 +5,8 @@ import ipaddress
5
5
 
6
6
  class _L3SectionParser:
7
7
 
8
+
9
+
8
10
  @classmethod
9
11
  def _parse_ip_address_line(cls, **kwargs):
10
12
  """
@@ -16,11 +18,34 @@ class _L3SectionParser:
16
18
  mask using the ipaddress module
17
19
  return: l3_interface_obj
18
20
  """
21
+
22
+ def process_ip_address_with_cidr(ip_address_with_cidr, obj):
23
+ """
24
+ Process the ip address with cidr
25
+ :param ip_address_with_cidr: str
26
+ :param obj: L3Interface object
27
+ :return:
28
+ """
29
+ ip_address_config = ip_address_with_cidr.split("/")
30
+ ip_addr = ip_address_config[0].strip()
31
+ cidr = ip_address_config[1].strip()
32
+ subnet_ = ipaddress.IPv4Network(f"{ip_addr}/{cidr}", strict=False)
33
+ obj.ip_address = ip_addr.strip()
34
+ obj.mask = str(subnet_.netmask)
35
+ obj.subnet = str(subnet_).strip()
36
+ return obj
37
+
19
38
  ip_address_line_regex = kwargs.get("ip_address_line_regex")
20
39
  l3_interface_obj = kwargs.get("l3_interface_obj")
21
40
  primary = kwargs.get("primary", True)
22
41
 
23
42
  ip_address_regex = [ip_group for ip_group in ip_address_line_regex.groups() if ip_group]
43
+
44
+ # Check if the ip address has a CIDR - 10.1.1.1/24
45
+ if "/" in ip_address_regex[0]:
46
+ l3_interface_obj = process_ip_address_with_cidr(ip_address_regex[0], l3_interface_obj)
47
+ return l3_interface_obj
48
+
24
49
  ip_address_section = ip_address_regex[0].split()
25
50
  ip_address = ip_address_section[0].strip()
26
51
  mask = ip_address_section[1].strip()
@@ -4,8 +4,33 @@ from .parser import Parser
4
4
 
5
5
 
6
6
  class ConfigParser(Parser):
7
- def __init__(self, _content):
8
- super().__init__(_content)
7
+ def __init__(self, _content, platform=None):
8
+ super().__init__(_content, platform=platform)
9
+
10
+
11
+ def get_static_config(self, return_json=False):
12
+ """
13
+ Get the static routes from the config file
14
+ :return: list of static route objects
15
+ """
16
+ return self._get_static_config(return_json=return_json)
17
+
18
+
19
+ def get_ospf_config(self, return_json=False):
20
+ """
21
+ Get the ospf configuration from the config file
22
+ :return: list of ospf objects or json
23
+ """
24
+ return self._get_ospf_config(return_json=return_json)
25
+
26
+
27
+ def get_eigrp_config(self, return_json=False):
28
+ """
29
+ Get the eigrp configuration from the config file
30
+ :return: list of eigrp objects or json
31
+ """
32
+ return self._get_eigrp_config(return_json=return_json)
33
+
9
34
 
10
35
  def get_vlan_info(self):
11
36
  """
@@ -28,6 +53,15 @@ class ConfigParser(Parser):
28
53
  """
29
54
  return self._get_parent_child(**kwargs)
30
55
 
56
+
57
+ def get_subnet_and_usage(self, include_subnet_count=False):
58
+ """
59
+ Fetch the subnet usage from the config file
60
+ return: dictionary of subnet usage
61
+ """
62
+ return self._get_subnet_and_usage(include_subnet_count=include_subnet_count)
63
+
64
+
31
65
  def get_l3_interfaces(self, **kwargs):
32
66
  """
33
67
  Get L3 interfaces from the config file
@@ -0,0 +1,201 @@
1
+ from cisco_config_parser.layer3_interface import L3InterfaceParser
2
+ from cisco_config_parser.layer2_interface import L2InterfaceParser
3
+ from cisco_config_parser.parent_child import ParentChildParser
4
+ from cisco_config_parser.global_search import GlobalParser
5
+ from cisco_config_parser.routing_protocol.rtp_ios_parser import IOSRouteParser
6
+ from cisco_config_parser.parser_regex.regex import *
7
+
8
+
9
+ class Parser:
10
+ def __init__(self, _content, platform=None):
11
+ self._content = _content
12
+ self._platform = platform
13
+ self._l3_parser_obj = L3InterfaceParser(self._content)
14
+ self._l2_parser_obj = L2InterfaceParser(self._content)
15
+ self._parent_child_parser_obj = ParentChildParser(self._content)
16
+ self._global_parser_obj = GlobalParser(self._content)
17
+ self._routing_protocol_parser_obj = IOSRouteParser(self._content)
18
+
19
+
20
+
21
+ def determine_platform(self):
22
+ """
23
+ Determine the platform of the device
24
+ IOS, NXOS, IOSXR
25
+ :return: string
26
+ - IOS running_config will have "Current configuration : <digts> bytes" at the beginning
27
+ - NXOS running_config will have "!Command: show running-config" at the beginning or we can look for "feature" keyword
28
+ - IOSXR running_config will have "!! IOS XR Configuration 6.2.3" at the beginning or we can look for "prefix-set" or "route-policy" keyword
29
+ """
30
+
31
+ if IOS_PLATFORM_REGEX_1.search(self._content):
32
+ return IOSRouteParser
33
+
34
+ elif NXOS_PLATFORM_REGEX_1.search(self._content) or NXOS_PLATFORM_REGEX_2.search(self._content):
35
+ return "NXOS"
36
+
37
+ elif XR_PLATFORM_REGEX_1.search(self._content) \
38
+ or XR_PLATFORM_REGEX_2.search(self._content) \
39
+ or XR_PLATFORM_REGEX_3.search(self._content):
40
+ return "XR"
41
+
42
+ raise ValueError("""
43
+ ------------------------------------------------------------------------------------------------------
44
+ Not able to determine the platform of the device.
45
+ Please pass the platform='IOS' or platform='NXOS' or platform='XR' as an argument to the Parser class
46
+ ------------------------------------------------------------------------------------------------------
47
+ """)
48
+
49
+
50
+ def _get_static_config(self, return_json=False):
51
+ """
52
+ Get the static routes from the config file
53
+ :return: list of static route objects
54
+ """
55
+ if self._platform:
56
+ """
57
+ if user provides the platform, then use the platform to fetch the static routes
58
+ """
59
+ if "ios" in self._platform.lower():
60
+ return self._routing_protocol_parser_obj._fetch_static_route_config(return_json=return_json)
61
+
62
+ """
63
+ if platform is not provided, then use internal logic to determine the platform
64
+ """
65
+ relevant_object = self.determine_platform()
66
+ return relevant_object(self._content)._fetch_static_route_config(return_json=return_json)
67
+
68
+
69
+ def _get_ospf_config(self, return_json=False):
70
+ """
71
+ Get the static routes from the config file
72
+ :return: list of static route objects
73
+ """
74
+ if self._platform:
75
+ """
76
+ if user provides the platform, then use the platform to fetch the static routes
77
+ """
78
+ if "ios" in self._platform.lower():
79
+ return self._routing_protocol_parser_obj._fetch_ospf_config(return_json=return_json)
80
+
81
+ """
82
+ if platform is not provided, then use internal logic to determine the platform
83
+ """
84
+ relevant_object = self.determine_platform()
85
+ return relevant_object(self._content)._fetch_ospf_config(return_json=return_json)
86
+
87
+
88
+
89
+ def _get_eigrp_config(self, return_json=False):
90
+ """
91
+ Get the static routes from the config file
92
+ :return: list of static route objects
93
+ """
94
+ if self._platform:
95
+ """
96
+ if user provides the platform, then use the platform to fetch the static routes
97
+ """
98
+ if "ios" in self._platform.lower():
99
+ return self._routing_protocol_parser_obj._fetch_eigrp_config(return_json=return_json)
100
+
101
+ """
102
+ if platform is not provided, then use internal logic to determine the platform
103
+ """
104
+ relevant_object = self.determine_platform()
105
+ return relevant_object(self._content)._fetch_eigrp_config(return_json=return_json)
106
+
107
+
108
+
109
+ def _get_vlan_info(self):
110
+ """
111
+ Get the vlan information from the config file
112
+ :return: list of vlan objects
113
+ """
114
+ return self._global_parser_obj._fetch_vlan_info()
115
+
116
+
117
+ def _get_banner(self):
118
+ """
119
+ Get the banner from the config file
120
+ :return: banner object
121
+ """
122
+ return self._global_parser_obj._fetch_banner()
123
+
124
+ def _get_parent_child(self, **kwargs):
125
+ """
126
+ Get parent child from the config file
127
+ :return: list of parent child objects
128
+ """
129
+ return self._parent_child_parser_obj._fetch_parent_child(**kwargs)
130
+
131
+
132
+ def _get_subnet_and_usage(self, include_subnet_count=False):
133
+ """
134
+ Fetch the subnet usage from the config file
135
+ return: dictionary of subnet usage and subnet count
136
+ """
137
+
138
+ return self._l3_parser_obj._fetch_subnet_and_usage(include_subnet_count=include_subnet_count)
139
+
140
+
141
+ def _get_l3_interfaces(self, **kwargs):
142
+ """
143
+ Get L3 interfaces from the config file
144
+ :return: list of L3 interface objects
145
+ """
146
+ return self._l3_parser_obj._fetch_l3_interfaces(**kwargs)
147
+
148
+ def _get_l3_interface_details(self):
149
+ """
150
+ Get the L3 interface details
151
+ :return: dictionary of L3 interface details
152
+ """
153
+ l3_interfaces = self._get_l3_interfaces()
154
+
155
+ if not l3_interfaces:
156
+ return {} # Return an empty dictionary if no interfaces are found
157
+
158
+ return {interface.name: interface.children for interface in l3_interfaces}
159
+
160
+ def _get_l2_access_interfaces(self, **kwargs):
161
+ """
162
+ Get L2 interfaces from the config file
163
+ :return: list of L2 interface objects
164
+ """
165
+ return self._l2_parser_obj._fetch_l2_access_interfaces(**kwargs)
166
+
167
+ def _get_l2_access_interface_details(self):
168
+ """
169
+ Get the L2 interface details
170
+ :return: dictionary of L2 interface details
171
+ """
172
+ l2_access_interfaces = self._get_l2_access_interfaces()
173
+
174
+ if not l2_access_interfaces:
175
+ return {}
176
+
177
+ return {interface.name: interface.children for interface in l2_access_interfaces}
178
+
179
+
180
+ def _get_l2_trunk_interfaces(self, **kwargs):
181
+ """
182
+ Get L2 interfaces from the config file
183
+ :return: list of L2 interface objects
184
+ """
185
+ return self._l2_parser_obj._fetch_l2_trunk_interfaces(**kwargs)
186
+
187
+ def _get_l2_trunk_interface_details(self):
188
+ """
189
+ Get the L2 interface details
190
+ :return: dictionary of L2 interface details
191
+ """
192
+ l2_trunk_interfaces = self._get_l2_trunk_interfaces()
193
+
194
+ if not l2_trunk_interfaces:
195
+ return {}
196
+
197
+ return {interface.name: interface.children for interface in l2_trunk_interfaces}
198
+
199
+
200
+
201
+