Skip to content

Commit b491ba2

Browse files
jeffkalanopg
andauthored
Fixes and Add Aruba config parser mappings (#632)
Co-authored-by: Ryan Gillespie <24619595+nopg@users.noreply.github.com>
1 parent db42cfc commit b491ba2

File tree

8 files changed

+4035
-8
lines changed

8 files changed

+4035
-8
lines changed

docs/dev/include_parser_list.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
| OS Name | Parser Class |
22
| ---------- | ------ |
33
| arista_eos | netutils.config.parser.EOSConfigParser |
4-
| aruba_aoscx | netutils.config.parser.ArubaConfigParser |
4+
| aruba_aoscx | netutils.config.parser.ArubaConfigCXParser |
5+
| aruba_os | netutils.config.parser.ArubaConfigOSParser |
6+
| aruba_osswitch | netutils.config.parser.ArubaConfigOSParser |
57
| bigip_f5 | netutils.config.parser.F5ConfigParser |
68
| cisco_aireos | netutils.config.parser.AIREOSConfigParser |
79
| cisco_asa | netutils.config.parser.ASAConfigParser |

docs/user/lib_mapper/netutilsparser.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
| ---------- | -- | ------ |
33
| arista_eos || arista_eos |
44
| aruba_aoscx || aruba_aoscx |
5+
| aruba_os || aruba_os |
6+
| aruba_osswitch || aruba_osswitch |
57
| bigip_f5 || bigip_f5 |
68
| cisco_aireos || cisco_aireos |
79
| cisco_asa || cisco_asa |

docs/user/lib_mapper/netutilsparser_reverse.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
| ---------- | -- | ------ |
33
| arista_eos || arista_eos |
44
| aruba_aoscx || aruba_aoscx |
5+
| aruba_os || aruba_os |
6+
| aruba_osswitch || aruba_osswitch |
57
| bigip_f5 || bigip_f5 |
68
| cisco_aireos || cisco_aireos |
79
| cisco_asa || cisco_asa |

netutils/config/compliance.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
parser_map: t.Dict[str, t.Type[parser.BaseConfigParser]] = {
1010
"arista_eos": parser.EOSConfigParser,
11-
"aruba_aoscx": parser.ArubaConfigParser,
11+
"aruba_aoscx": parser.ArubaConfigCXParser,
12+
"aruba_os": parser.ArubaConfigOSParser,
13+
"aruba_osswitch": parser.ArubaConfigOSParser,
1214
"bigip_f5": parser.F5ConfigParser,
1315
"cisco_aireos": parser.AIREOSConfigParser,
1416
"cisco_asa": parser.ASAConfigParser,
@@ -196,7 +198,9 @@ def compliance(
196198

197199

198200
def config_section_not_parsed(
199-
features: t.List[t.Dict[str, t.Union[str, bool, t.List[str]]]], device_cfg: str, network_os: str
201+
features: t.List[t.Dict[str, t.Union[str, bool, t.List[str]]]],
202+
device_cfg: str,
203+
network_os: str,
200204
) -> t.Dict[str, t.Union[str, t.List[str]]]:
201205
r"""Return device config section that is not checked by compliance.
202206
@@ -291,7 +295,10 @@ def diff_network_config(compare_config: str, base_config: str, network_os: str)
291295

292296

293297
def feature_compliance(
294-
feature: t.Dict[str, t.Union[str, bool, t.List[str]]], backup_cfg: str, intended_cfg: str, network_os: str
298+
feature: t.Dict[str, t.Union[str, bool, t.List[str]]],
299+
backup_cfg: str,
300+
intended_cfg: str,
301+
network_os: str,
295302
) -> t.Dict[str, t.Union[str, bool]]:
296303
r"""Report compliance for all features provided as input.
297304
@@ -391,7 +398,11 @@ def find_unordered_cfg_lines(intended_cfg: str, actual_cfg: str) -> t.Tuple[bool
391398
return (False, unordered_lines)
392399

393400

394-
def section_config(feature: t.Dict[str, t.Union[str, bool, t.List[str]]], device_cfg: str, network_os: str) -> str:
401+
def section_config(
402+
feature: t.Dict[str, t.Union[str, bool, t.List[str]]],
403+
device_cfg: str,
404+
network_os: str,
405+
) -> str:
395406
"""Parse feature section config from device cfg.
396407
397408
In case section attribute of the the feature is not provided

netutils/config/parser.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,9 @@ def find_children_w_parents(
417417
]
418418
for cfg_line in self.build_config_relationship():
419419
parents = cfg_line.parents[0] if cfg_line.parents else None
420-
if parents in potential_parents and self._match_type_check(parents, parent_pattern, match_type): # type: ignore[arg-type]
420+
if parents in potential_parents and self._match_type_check(
421+
parents, parent_pattern, match_type # type: ignore[arg-type]
422+
):
421423
config.append(cfg_line.config_line)
422424
return config
423425

@@ -1205,8 +1207,8 @@ def banner_end(self) -> str:
12051207
raise NotImplementedError("Netscaler platform doesn't have a banner.")
12061208

12071209

1208-
class ArubaConfigParser(BaseSpaceConfigParser):
1209-
"""Aruba AOS-CX implementation fo ConfigParser Class."""
1210+
class _ArubaBaseConfigParser(BaseSpaceConfigParser):
1211+
"""Aruba Base implementation fo ConfigParser Class."""
12101212

12111213
banner_end = "!"
12121214
comment_chars = ["!"]
@@ -1287,6 +1289,20 @@ def config_lines_only(self) -> str:
12871289
return self._config
12881290

12891291

1292+
class ArubaConfigCXParser(_ArubaBaseConfigParser):
1293+
"""Aruba AOS-CX implementation fo ConfigParser Class."""
1294+
1295+
1296+
class ArubaConfigOSParser(_ArubaBaseConfigParser):
1297+
"""Aruba OS / OSSWITCH implementation fo ConfigParser Class."""
1298+
1299+
1300+
class ArubaConfigParser(_ArubaBaseConfigParser):
1301+
"""Aruba Config implementation fo ConfigParser Class."""
1302+
1303+
# Remove on next major release.
1304+
1305+
12901306
class IOSXRConfigParser(CiscoConfigParser):
12911307
"""IOS-XR config parser."""
12921308

netutils/lib_mapper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@
389389
NETUTILSPARSER_LIB_MAPPER: t.Dict[str, str] = {
390390
"arista_eos": "arista_eos",
391391
"aruba_aoscx": "aruba_aoscx",
392+
"aruba_os": "aruba_os",
393+
"aruba_osswitch": "aruba_osswitch",
392394
"bigip_f5": "bigip_f5",
393395
"cisco_aireos": "cisco_aireos",
394396
"cisco_asa": "cisco_asa",
@@ -554,6 +556,8 @@
554556
NETUTILSPARSER_LIB_MAPPER_REVERSE: t.Dict[str, str] = {
555557
"arista_eos": "arista_eos",
556558
"aruba_aoscx": "aruba_aoscx",
559+
"aruba_os": "aruba_os",
560+
"aruba_osswitch": "aruba_osswitch",
557561
"bigip_f5": "bigip_f5",
558562
"cisco_aireos": "cisco_aireos",
559563
"cisco_asa": "cisco_asa",

0 commit comments

Comments
 (0)