cisco-config-parser 2.2.1__tar.gz → 2.2.3__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 (62) hide show
  1. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/PKG-INFO +10 -48
  2. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/README.md +9 -47
  3. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/helper/help.py +70 -28
  4. cisco_config_parser-2.2.3/cisco_config_parser/helper/helper.py +38 -0
  5. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/parent_child/parent_child_parser.py +4 -0
  6. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/parser/__init__.py +9 -0
  7. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/parser/parser.py +34 -10
  8. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/parser_regex/regex.py +25 -2
  9. cisco_config_parser-2.2.3/cisco_config_parser/routing_protocol/__init__.py +5 -0
  10. cisco_config_parser-2.2.3/cisco_config_parser/routing_protocol/ios/__init__.py +6 -0
  11. cisco_config_parser-2.2.3/cisco_config_parser/routing_protocol/ios/rtp_bgp.py +294 -0
  12. cisco_config_parser-2.2.3/cisco_config_parser/routing_protocol/ios/rtp_eigtp.py +149 -0
  13. cisco_config_parser-2.2.3/cisco_config_parser/routing_protocol/ios/rtp_ios_rtp_obj.py +127 -0
  14. cisco_config_parser-2.2.3/cisco_config_parser/routing_protocol/ios/rtp_ospf.py +194 -0
  15. cisco_config_parser-2.2.3/cisco_config_parser/routing_protocol/ios/rtp_static.py +107 -0
  16. {cisco_config_parser-2.2.1/cisco_config_parser/routing_protocol → cisco_config_parser-2.2.3/cisco_config_parser/routing_protocol/utils}/rtp_separator.py +13 -0
  17. cisco_config_parser-2.2.3/cisco_config_parser/routing_protocol/utils/utils.py +22 -0
  18. cisco_config_parser-2.2.1/cisco_config_parser/testing.py → cisco_config_parser-2.2.3/cisco_config_parser/routing_protocol/xr/__init__.py +0 -0
  19. cisco_config_parser-2.2.3/cisco_config_parser/testing.py +80 -0
  20. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser.egg-info/PKG-INFO +10 -48
  21. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser.egg-info/SOURCES.txt +11 -5
  22. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/setup.py +1 -1
  23. cisco_config_parser-2.2.1/cisco_config_parser/helper/helper.py +0 -26
  24. cisco_config_parser-2.2.1/cisco_config_parser/routing_protocol/__init__.py +0 -4
  25. cisco_config_parser-2.2.1/cisco_config_parser/routing_protocol/rtp_ios_obj.py +0 -68
  26. cisco_config_parser-2.2.1/cisco_config_parser/routing_protocol/rtp_ios_parser.py +0 -448
  27. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/__init__.py +0 -0
  28. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/cisco_config_parser.py +0 -0
  29. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/global_search/__init__.py +0 -0
  30. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/global_search/global_obj.py +0 -0
  31. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/global_search/global_parser.py +0 -0
  32. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/global_search/global_separator.py +0 -0
  33. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/helper/__init__.py +0 -0
  34. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/layer2_interface/__init__.py +0 -0
  35. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/layer2_interface/l2_interface_obj.py +0 -0
  36. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/layer2_interface/l2_interface_parser.py +0 -0
  37. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/layer2_interface/l2_interface_separator.py +0 -0
  38. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/layer2_interface/l2_section_parser.py +0 -0
  39. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/layer3_interface/__init__.py +0 -0
  40. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/layer3_interface/l3_interface_obj.py +0 -0
  41. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/layer3_interface/l3_interface_parser.py +0 -0
  42. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/layer3_interface/l3_interface_separator.py +0 -0
  43. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/layer3_interface/l3_section_parser.py +0 -0
  44. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/old_version/__init__.py +0 -0
  45. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/old_version/exceptions.py +0 -0
  46. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/old_version/obj.py +0 -0
  47. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/old_version/old_parse.py +0 -0
  48. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/old_version/ssh.py +0 -0
  49. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/old_version/utils.py +0 -0
  50. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/parent_child/__init__.py +0 -0
  51. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/parent_child/parent_child_obj.py +0 -0
  52. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/parent_child/parent_child_separator.py +0 -0
  53. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/parser_regex/__init__.py +0 -0
  54. /cisco_config_parser-2.2.1/cisco_config_parser/routing_protocol/rtp_dynamic_obj.py → /cisco_config_parser-2.2.3/cisco_config_parser/routing_protocol/nxos/__init__.py +0 -0
  55. /cisco_config_parser-2.2.1/cisco_config_parser/routing_protocol/rtp_dynamic_parser.py → /cisco_config_parser-2.2.3/cisco_config_parser/routing_protocol/utils/__init__.py +0 -0
  56. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/separator/__init__.py +0 -0
  57. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/separator/separator.py +0 -0
  58. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser/setup.py +0 -0
  59. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser.egg-info/dependency_links.txt +0 -0
  60. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/cisco_config_parser.egg-info/top_level.txt +0 -0
  61. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/pyproject.toml +0 -0
  62. {cisco_config_parser-2.2.1 → cisco_config_parser-2.2.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cisco_config_parser
3
- Version: 2.2.1
3
+ Version: 2.2.3
4
4
  Summary: This library is used for Network Automation involving Cisco Routers and Switch. It will parse Cisco IOS, IOS-XE, IOS-XR, and NXOS configuration file into objects and/or json format
5
5
  Home-page: https://github.com/arezazadeh/cisco_config_parser
6
6
  Author: Ahmad Rezazadeh
@@ -26,7 +26,11 @@ pip install cisco-config-parser
26
26
  ## Classes in this library
27
27
 
28
28
  ```python
29
- IOSRouteParser
29
+ IOSStaticRouteConfig
30
+ IOSOSPFConfig
31
+ IOSEIGRPConfig
32
+ IOSBGPConfig
33
+ IOSBGPConfig
30
34
  L3InterfaceParser
31
35
  L2InterfaceParser
32
36
  ParentChildParser
@@ -38,7 +42,7 @@ there more Classes are being built, and will be released in the upcoming version
38
42
  ```python
39
43
  from cisco_config_parser.helper import helper
40
44
 
41
- helper = helper.IOSRouteParser()
45
+ helper = helper.IOSStaticRouteConfig()
42
46
 
43
47
  print(helper)
44
48
  ```
@@ -55,50 +59,8 @@ with open("show_run.txt", "r") as file_output:
55
59
 
56
60
  obj = ConfigParser(content)
57
61
 
58
-
59
- #
60
- ##
61
- ###
62
- #### Static Routes Example:
63
- ###
64
- ##
65
- #
66
- obj.get_static_routes()
67
- obj.get_static_routes(return_json=True)
68
-
69
-
70
- #
71
- ##
72
- ###
73
- #### OSPF Example:
74
- ###
75
- ##
76
- #
77
- ospf = obj.get_ospf_config(return_json=True)
78
- ospf = obj.get_ospf_config()
79
- for i in ospf:
80
- print(i.children)
81
- print(i.network)
82
- print(i.no_passive_interface)
83
-
84
- #
85
- ##
86
- ###
87
- #### EIGRP Example:
88
- ###
89
- ##
90
- #
91
- eigrp = obj.get_eigrp_config(return_json=True)
92
- eigrp = obj.get_eigrp_config()
93
- for i in eigrp:
94
- print(i.children)
95
- print(i.network)
96
- print(i.vrf_children) << returns a list of EIGRPVrfChildren objects
97
- vrf_children = i.vrf_children
98
- for vrf in vrf_children:
99
- print(vrf.network)
100
- print(vrf.children)
101
-
62
+ obj.get_static_routes() << Returns a list of objects
63
+ obj.get_static_routes(return_json=True) << Returns a list of dictionaries
102
64
 
103
65
  ```
104
66
 
@@ -109,7 +71,7 @@ for i in eigrp:
109
71
  - able to set custom regex and create dynamic method
110
72
 
111
73
 
112
- * Example:
74
+ * L3Interface Example:
113
75
 
114
76
  ```python
115
77
  from cisco_config_parser import ConfigParser
@@ -16,7 +16,11 @@ pip install cisco-config-parser
16
16
  ## Classes in this library
17
17
 
18
18
  ```python
19
- IOSRouteParser
19
+ IOSStaticRouteConfig
20
+ IOSOSPFConfig
21
+ IOSEIGRPConfig
22
+ IOSBGPConfig
23
+ IOSBGPConfig
20
24
  L3InterfaceParser
21
25
  L2InterfaceParser
22
26
  ParentChildParser
@@ -28,7 +32,7 @@ there more Classes are being built, and will be released in the upcoming version
28
32
  ```python
29
33
  from cisco_config_parser.helper import helper
30
34
 
31
- helper = helper.IOSRouteParser()
35
+ helper = helper.IOSStaticRouteConfig()
32
36
 
33
37
  print(helper)
34
38
  ```
@@ -45,50 +49,8 @@ with open("show_run.txt", "r") as file_output:
45
49
 
46
50
  obj = ConfigParser(content)
47
51
 
48
-
49
- #
50
- ##
51
- ###
52
- #### Static Routes Example:
53
- ###
54
- ##
55
- #
56
- obj.get_static_routes()
57
- obj.get_static_routes(return_json=True)
58
-
59
-
60
- #
61
- ##
62
- ###
63
- #### OSPF Example:
64
- ###
65
- ##
66
- #
67
- ospf = obj.get_ospf_config(return_json=True)
68
- ospf = obj.get_ospf_config()
69
- for i in ospf:
70
- print(i.children)
71
- print(i.network)
72
- print(i.no_passive_interface)
73
-
74
- #
75
- ##
76
- ###
77
- #### EIGRP Example:
78
- ###
79
- ##
80
- #
81
- eigrp = obj.get_eigrp_config(return_json=True)
82
- eigrp = obj.get_eigrp_config()
83
- for i in eigrp:
84
- print(i.children)
85
- print(i.network)
86
- print(i.vrf_children) << returns a list of EIGRPVrfChildren objects
87
- vrf_children = i.vrf_children
88
- for vrf in vrf_children:
89
- print(vrf.network)
90
- print(vrf.children)
91
-
52
+ obj.get_static_routes() << Returns a list of objects
53
+ obj.get_static_routes(return_json=True) << Returns a list of dictionaries
92
54
 
93
55
  ```
94
56
 
@@ -99,7 +61,7 @@ for i in eigrp:
99
61
  - able to set custom regex and create dynamic method
100
62
 
101
63
 
102
- * Example:
64
+ * L3Interface Example:
103
65
 
104
66
  ```python
105
67
  from cisco_config_parser import ConfigParser
@@ -1,8 +1,8 @@
1
1
 
2
2
 
3
- RTP_IOS_HELP = """
3
+ RTP_IOS_STATIC_HELP = """
4
4
 
5
- Example Usage:
5
+ Example Usage For Static Routes:
6
6
  ====================================================================================================
7
7
 
8
8
  with open("show_run.txt", "r") as file_output:
@@ -11,40 +11,51 @@ with open("show_run.txt", "r") as file_output:
11
11
 
12
12
  obj = ConfigParser(content)
13
13
 
14
+ # Return it as a json object
15
+ obj.get_static_routes(return_json=True)
14
16
 
15
- #
16
- ##
17
- ###
18
- #### Static Routes Example:
19
- ###
20
- ##
21
- #
17
+ # or as a list of StaticRoute objects
22
18
  obj.get_static_routes()
23
- obj.get_static_routes(return_json=True)
19
+ """
20
+
24
21
 
22
+ RTP_IOS_OSPF_HELP = """
25
23
 
26
- #
27
- ##
28
- ###
29
- #### OSPF Example:
30
- ###
31
- ##
32
- #
24
+ Example Usage For OSPF Routes:
25
+ ====================================================================================================
26
+
27
+ with open("show_run.txt", "r") as file_output:
28
+ content = file_output.read()
29
+
30
+
31
+ obj = ConfigParser(content)
32
+
33
+ # Return it as a json object
33
34
  ospf = obj.get_ospf_config(return_json=True)
35
+
36
+ # or as a list of OSPFConfig objects
34
37
  ospf = obj.get_ospf_config()
35
38
  for i in ospf:
36
39
  print(i.children)
37
40
  print(i.network)
38
41
  print(i.no_passive_interface)
39
42
 
40
- #
41
- ##
42
- ###
43
- #### EIGRP Example:
44
- ###
45
- ##
46
- #
43
+ """
44
+ RTP_IOS_EIGRP_HELP = """
45
+
46
+ Example Usage For EIGRP Routes:
47
+ ====================================================================================================
48
+
49
+ with open("show_run.txt", "r") as file_output:
50
+ content = file_output.read()
51
+
52
+
53
+ obj = ConfigParser(content)
54
+
55
+ # Return it as a json object
47
56
  eigrp = obj.get_eigrp_config(return_json=True)
57
+
58
+ # or as a list of EIGRPConfig objects
48
59
  eigrp = obj.get_eigrp_config()
49
60
  for i in eigrp:
50
61
  print(i.children)
@@ -55,8 +66,38 @@ for i in eigrp:
55
66
  print(vrf.network)
56
67
  print(vrf.children)
57
68
  """
69
+
70
+
71
+ RTP_IOS_BGP_HELP = """
72
+
73
+ Example Usage For BGP Routes:
74
+ ====================================================================================================
75
+
76
+ with open("show_run.txt", "r") as file_output:
77
+ content = file_output.read()
78
+
79
+
80
+ obj = ConfigParser(content)
81
+
82
+ # Return it as a json object
83
+ bgp = obj.get_bgp_config(return_json=True)
84
+
85
+
86
+ # or as a list of BGPConfig objects
87
+ bgp = obj.get_bgp_config()
88
+ for i in bgp:
89
+ print(i.children)
90
+ print(i.network)
91
+ print(i.vrf_children) << returns a list of BGPVrfChildren objects
92
+ vrf_children = i.vrf_children
93
+ for vrf in vrf_children:
94
+ print(vrf.network)
95
+ print(vrf.children)
96
+ """
97
+
58
98
  PARENT_CHILD_HELP = """
59
- Example Usage:
99
+
100
+ Example Usage For Parent Child:
60
101
  ====================================================================================================
61
102
 
62
103
  with open("show_run.txt", "r") as file_output:
@@ -72,7 +113,8 @@ for i in parent_child:
72
113
 
73
114
  """
74
115
  LAYER3_INTERFACE_HELP = """
75
- Example Usage:
116
+
117
+ Example Usage For Layer3 Interfaces:
76
118
  ====================================================================================================
77
119
  with open("show_run.txt", "r") as file_output:
78
120
  content = file_output.read()
@@ -101,9 +143,9 @@ for intf in l3_intfs:
101
143
  print(intf.load_interval) <<< dynamically creates an attribute based on the custom regex
102
144
 
103
145
  """
104
-
105
146
  LAYER2_INTERFACE_HELP = """
106
- Example Usage:
147
+
148
+ Example Usage For Layer2 Interfaces:
107
149
  ====================================================================================================
108
150
  with open("show_run.txt", "r") as file_output:
109
151
  content = file_output.read()
@@ -0,0 +1,38 @@
1
+ from .help import *
2
+
3
+
4
+ class IOSStaticRouteConfig:
5
+ def __repr__(self):
6
+ return RTP_IOS_STATIC_HELP
7
+
8
+ class IOSOSPFConfig:
9
+ def __repr__(self):
10
+ return RTP_IOS_OSPF_HELP
11
+
12
+
13
+ class IOSEIGRPConfig:
14
+ def __repr__(self):
15
+ return RTP_IOS_EIGRP_HELP
16
+
17
+ class IOSBGPConfig:
18
+ def __repr__(self):
19
+ return RTP_IOS_BGP_HELP
20
+
21
+
22
+ class ParentChild:
23
+ def __repr__(self):
24
+ return PARENT_CHILD_HELP
25
+
26
+
27
+ class L3Interface:
28
+ def __repr__(self):
29
+ return LAYER3_INTERFACE_HELP
30
+
31
+
32
+ class L2Interface:
33
+ def __repr__(self):
34
+ return LAYER2_INTERFACE_HELP
35
+
36
+
37
+
38
+
@@ -21,6 +21,7 @@ class ParentChildParser:
21
21
  return: list of ParentChild objects
22
22
  """
23
23
  custom_regex = kwargs.get("custom_regex", None)
24
+ return_json = kwargs.get("return_json", False)
24
25
  if not custom_regex:
25
26
  raise ValueError("custom_regex is required")
26
27
 
@@ -41,5 +42,8 @@ class ParentChildParser:
41
42
  parent_child_obj.children = [line.strip() for line in child_regex if line] if child_regex else ""
42
43
  parent_child_obj_list.append(parent_child_obj)
43
44
 
45
+ if return_json:
46
+ return [obj.__dict__ for obj in parent_child_obj_list]
47
+
44
48
  return parent_child_obj_list
45
49
 
@@ -32,6 +32,15 @@ class ConfigParser(Parser):
32
32
  return self._get_eigrp_config(return_json=return_json)
33
33
 
34
34
 
35
+ def get_bgp_config(self, return_json=False):
36
+ """
37
+ Get the eigrp configuration from the config file
38
+ :return: list of eigrp objects or json
39
+ """
40
+ return self._get_bgp_config(return_json=return_json)
41
+
42
+
43
+
35
44
  def get_vlan_info(self):
36
45
  """
37
46
  Get the vlan information from the config file
@@ -2,7 +2,12 @@ from cisco_config_parser.layer3_interface import L3InterfaceParser
2
2
  from cisco_config_parser.layer2_interface import L2InterfaceParser
3
3
  from cisco_config_parser.parent_child import ParentChildParser
4
4
  from cisco_config_parser.global_search import GlobalParser
5
- from cisco_config_parser.routing_protocol.rtp_ios_parser import IOSRouteParser
5
+ from cisco_config_parser.routing_protocol.ios.rtp_ospf import IOSOSPFConfig
6
+ from cisco_config_parser.routing_protocol.ios.rtp_eigtp import IOSEIGRPConfig
7
+ from cisco_config_parser.routing_protocol.ios.rtp_static import IOSStaticRouteConfig
8
+ from cisco_config_parser.routing_protocol.ios.rtp_bgp import IOSBGPConfig
9
+
10
+
6
11
  from cisco_config_parser.parser_regex.regex import *
7
12
 
8
13
 
@@ -14,11 +19,10 @@ class Parser:
14
19
  self._l2_parser_obj = L2InterfaceParser(self._content)
15
20
  self._parent_child_parser_obj = ParentChildParser(self._content)
16
21
  self._global_parser_obj = GlobalParser(self._content)
17
- self._routing_protocol_parser_obj = IOSRouteParser(self._content)
18
22
 
19
23
 
20
24
 
21
- def determine_platform(self):
25
+ def determine_platform(self, TARGET_CLASS):
22
26
  """
23
27
  Determine the platform of the device
24
28
  IOS, NXOS, IOSXR
@@ -29,7 +33,7 @@ class Parser:
29
33
  """
30
34
 
31
35
  if IOS_PLATFORM_REGEX_1.search(self._content):
32
- return IOSRouteParser
36
+ return TARGET_CLASS
33
37
 
34
38
  elif NXOS_PLATFORM_REGEX_1.search(self._content) or NXOS_PLATFORM_REGEX_2.search(self._content):
35
39
  return "NXOS"
@@ -57,12 +61,12 @@ class Parser:
57
61
  if user provides the platform, then use the platform to fetch the static routes
58
62
  """
59
63
  if "ios" in self._platform.lower():
60
- return self._routing_protocol_parser_obj._fetch_static_route_config(return_json=return_json)
64
+ return IOSStaticRouteConfig(self._content)._fetch_static_route_config(return_json=return_json)
61
65
 
62
66
  """
63
67
  if platform is not provided, then use internal logic to determine the platform
64
68
  """
65
- relevant_object = self.determine_platform()
69
+ relevant_object = self.determine_platform(IOSStaticRouteConfig)
66
70
  return relevant_object(self._content)._fetch_static_route_config(return_json=return_json)
67
71
 
68
72
 
@@ -76,12 +80,12 @@ class Parser:
76
80
  if user provides the platform, then use the platform to fetch the static routes
77
81
  """
78
82
  if "ios" in self._platform.lower():
79
- return self._routing_protocol_parser_obj._fetch_ospf_config(return_json=return_json)
83
+ return IOSOSPFConfig(self._content)._fetch_ospf_config(return_json=return_json)
80
84
 
81
85
  """
82
86
  if platform is not provided, then use internal logic to determine the platform
83
87
  """
84
- relevant_object = self.determine_platform()
88
+ relevant_object = self.determine_platform(IOSOSPFConfig)
85
89
  return relevant_object(self._content)._fetch_ospf_config(return_json=return_json)
86
90
 
87
91
 
@@ -96,15 +100,35 @@ class Parser:
96
100
  if user provides the platform, then use the platform to fetch the static routes
97
101
  """
98
102
  if "ios" in self._platform.lower():
99
- return self._routing_protocol_parser_obj._fetch_eigrp_config(return_json=return_json)
103
+ return IOSEIGRPConfig(self._content)._fetch_eigrp_config(return_json=return_json)
100
104
 
101
105
  """
102
106
  if platform is not provided, then use internal logic to determine the platform
103
107
  """
104
- relevant_object = self.determine_platform()
108
+ relevant_object = self.determine_platform(IOSEIGRPConfig)
105
109
  return relevant_object(self._content)._fetch_eigrp_config(return_json=return_json)
106
110
 
107
111
 
112
+ def _get_bgp_config(self, return_json=False):
113
+ """
114
+ Get the static routes from the config file
115
+ :return: list of static route objects
116
+ """
117
+ if self._platform:
118
+ """
119
+ if user provides the platform, then use the platform to fetch the static routes
120
+ """
121
+ if "ios" in self._platform.lower():
122
+ return IOSBGPConfig(self._content)._fetch_bgp_config(return_json=return_json)
123
+
124
+ """
125
+ if platform is not provided, then use internal logic to determine the platform
126
+ """
127
+ relevant_object = self.determine_platform(IOSBGPConfig)
128
+ return relevant_object(self._content)._fetch_bgp_config(return_json=return_json)
129
+
130
+
131
+
108
132
 
109
133
  def _get_vlan_info(self):
110
134
  """
@@ -61,8 +61,6 @@ VLAN_REGEX = re.compile(r"^vlan\s([0-9]+)", flags=re.MULTILINE)
61
61
 
62
62
  # Routing Protocol
63
63
  RTP_REGEX = re.compile(r"^router\s(.*)", flags=re.MULTILINE)
64
-
65
- RTP_BGP_REGEX = re.compile(r"^router bgp", flags=re.MULTILINE)
66
64
  RTP_ISIS_REGEX = re.compile(r"^router isis", flags=re.MULTILINE)
67
65
  RTP_RIP_REGEX = re.compile(r"^router rip", flags=re.MULTILINE)
68
66
 
@@ -99,6 +97,31 @@ RTP_EIGRP_REGEX = re.compile(r"^router eigrp", flags=re.MULTILINE)
99
97
  RTP_IOS_EIGRP_VRF_REGEX = re.compile(r"\s+address-family\sipv4\svrf\s(\S+)", flags=re.MULTILINE)
100
98
  RTP_IOS_EIGRP_NETWORK_REGEX = re.compile(r"\s+network\s(\d+\.\d+\.\d+\.\d+)\s(\d+\.\d+\.\d+\.\d+)", flags=re.MULTILINE)
101
99
 
100
+ # IOS ROUTING PROTOCOL - BGP
101
+ RTP_BGP_REGEX = re.compile(r"^router bgp", flags=re.MULTILINE)
102
+ RTP_BGP_ROUTER_ID_REGEX = re.compile(r"\s+bgp\srouter-id\s(\d+\.\d+\.\d+\.\d+)", flags=re.MULTILINE)
103
+ RTP_IOS_BGP_VRF_REGEX = re.compile(r"\s+address-family\sipv4\svrf\s(\S+)", flags=re.MULTILINE)
104
+ RTP_IOS_BGP_NETWORK_REGEX = re.compile(r"\s+network\s(\d+\.\d+\.\d+\.\d+)\smask\s(\d+\.\d+\.\d+\.\d+)", flags=re.MULTILINE)
105
+ RTP_IOS_BGP_NEIGHBOR_IP_REGEX = re.compile(r"\s+neighbor\s(\d+\.\d+\.\d+\.\d+)\s(.*)", flags=re.MULTILINE)
106
+ RTP_IOS_BGP_NEIGHBOR_REMOTE_AS_REGEX = re.compile(r"\s+neighbor\s(\d+\.\d+\.\d+\.\d+)\sremote-as\s(\d+)", flags=re.MULTILINE)
107
+ RTP_IOS_BGP_NEIGHBOR_DESCR_REGEX = re.compile(r"\s+neighbor\s(\d+\.\d+\.\d+\.\d+)\sdescription\s(.*)", flags=re.MULTILINE)
108
+ RTP_IOS_BGP_NEIGHBOR_UPDATE_SRC_REGEX = re.compile(r"\s+neighbor\s(\d+\.\d+\.\d+\.\d+)\supdate-source\s(.*)", flags=re.MULTILINE)
109
+ RTP_IOS_BGP_NEIGHBOR_RM_INBOUND_REGEX = re.compile(r"\s+neighbor\s(\d+\.\d+\.\d+\.\d+)\sroute-map\s(.*)\sin", flags=re.MULTILINE)
110
+ RTP_IOS_BGP_NEIGHBOR_RM_OUTBOUND_REGEX = re.compile(r"\s+neighbor\s(\d+\.\d+\.\d+\.\d+)\sroute-map\s(.*)\sout", flags=re.MULTILINE)
111
+
112
+ RTP_IOS_BGP_PEER_GROUP_REGEX = re.compile(r"\s+neighbor\s(\S+)\speer-group$", flags=re.MULTILINE)
113
+ RTP_IOS_BGP_PG_REMOTE_AS_REGEX = re.compile(r"\s+neighbor\s(.*)\sremote-as\s(\S+)", flags=re.MULTILINE)
114
+ RTP_IOS_BGP_PG_UPDATE_SRC_REGEX = re.compile(r"\s+neighbor\s(.*)\supdate-source\s(\S+)", flags=re.MULTILINE)
115
+ RTP_IOS_BGP_PG_RM_IN_REGEX = re.compile(r"\s+neighbor\s(.*)\sroute-map\s(\S+)\sin", flags=re.MULTILINE)
116
+ RTP_IOS_BGP_PG_RM_OUT_REGEX = re.compile(r"\s+neighbor\s(.*)\sroute-map\s(\S+)\sout", flags=re.MULTILINE)
117
+ RTP_IOS_BGP_PG_NEIGHBOR_REGEX = re.compile(r"\s+neighbor\s(\d+\.\d+\.\d+\.\d+)\speer-group(.*)", flags=re.MULTILINE)
118
+ RTP_IOS_BGP_PG_NEIGHBOR_DESCR_REGEX = re.compile(r"\s+neighbor\s(\d+\.\d+\.\d+\.\d+)\sdescription(.*)", flags=re.MULTILINE)
119
+ RTP_IOS_BGP_GLOBAL_IPV4_REGEX = re.compile(r"\s+address-family\sipv4$", flags=re.MULTILINE)
120
+
121
+ RTP_IOS_BGP_REDISTRIBUTE_REGEX = re.compile(r"\s+(redistribute\s.*)", flags=re.MULTILINE)
122
+ RTP_IOS_BGP_REDISTRIBUTE_W_RM_REGEX = re.compile(r"redistribute\s(\S+\s\S+|\S+)\s+route-map(.*)", flags=re.MULTILINE)
123
+ RTP_IOS_BGP_REDISTRIBUTE_WO_RM_REGEX = re.compile(r"redistribute\s(\S+\s\S+|\S+)$", flags=re.MULTILINE)
124
+
102
125
 
103
126
 
104
127
  def find_vrf_section(vrf, item):
@@ -0,0 +1,5 @@
1
+ from cisco_config_parser.routing_protocol.utils.rtp_separator import IOSRoutingProtocolSeparator
2
+ from .utils import *
3
+ from .ios import *
4
+ from .nxos import *
5
+ from .xr import *
@@ -0,0 +1,6 @@
1
+
2
+ from .rtp_bgp import *
3
+ from .rtp_eigtp import *
4
+ from .rtp_ospf import *
5
+ from .rtp_static import *
6
+ from .rtp_ios_rtp_obj import *