mirror of
https://github.com/hansjone/netx.git
synced 2026-10-10 12:40:44 +08:00
Merge duplicate if-intf checks into Config Interface Intent.
Hide standalone IF VRF from the catalog and point ARP enrich at config_interface so one CLI maps to one check item. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
c1b1c0f75d
commit
1642a0adec
8 changed files with 37 additions and 21 deletions
|
|
@ -59,18 +59,20 @@ class AuxResolveTests(unittest.TestCase):
|
|||
reload_profiles()
|
||||
|
||||
def test_resolve_from_profile_id(self) -> None:
|
||||
ra = resolve_aux_command(AuxCommand(key="if_intf", profile_id="zte.if_intf"))
|
||||
ra = resolve_aux_command(AuxCommand(key="if_intf", profile_id="zte.config_interface"))
|
||||
self.assertEqual(ra.command, "show running-config if-intf")
|
||||
self.assertEqual(ra.parser_id, "if_intf")
|
||||
self.assertIn("zte_zxros_show_running_config_if_intf", ra.rule_keys)
|
||||
self.assertEqual(ra.parser_id, "config_interface")
|
||||
|
||||
def test_arp_profile_slim(self) -> None:
|
||||
p = get_profile("zte.arp")
|
||||
assert p is not None
|
||||
self.assertEqual(p.aux_commands[0].key, "if_intf")
|
||||
self.assertEqual(p.aux_commands[0].profile_id, "zte.if_intf")
|
||||
self.assertEqual(p.aux_commands[0].profile_id, "zte.config_interface")
|
||||
self.assertEqual(len(p.enrich_joins), 1)
|
||||
self.assertEqual(p.enrich_joins[0].take, ("vrf",))
|
||||
ii = get_profile("zte.if_intf")
|
||||
assert ii is not None
|
||||
self.assertFalse(ii.enabled)
|
||||
|
||||
|
||||
class CollectSessionCacheTests(unittest.TestCase):
|
||||
|
|
@ -98,13 +100,13 @@ class ArpEnrichPipelineTests(unittest.TestCase):
|
|||
|
||||
def test_run_primary_with_enrich(self) -> None:
|
||||
if_recs, if_fsm, _ = run_parser(
|
||||
"if_intf",
|
||||
"config_interface",
|
||||
raw_text=IF_INTF_SAMPLE,
|
||||
vendor="zte",
|
||||
device_type="zte_zxros",
|
||||
command="show running-config if-intf",
|
||||
)
|
||||
ra = resolve_aux_command(AuxCommand(key="if_intf", profile_id="zte.if_intf"))
|
||||
ra = resolve_aux_command(AuxCommand(key="if_intf", profile_id="zte.config_interface"))
|
||||
bundle = build_parse_bundle(
|
||||
primary_raw=ARP_MATCHING,
|
||||
primary_parser_id="arp",
|
||||
|
|
|
|||
|
|
@ -97,7 +97,10 @@ class ArpMultiCommandTests(unittest.TestCase):
|
|||
assert p is not None
|
||||
self.assertEqual(len(p.aux_commands), 1)
|
||||
self.assertEqual(p.aux_commands[0].key, "if_intf")
|
||||
self.assertEqual(p.aux_commands[0].profile_id, "zte.if_intf")
|
||||
self.assertEqual(p.aux_commands[0].profile_id, "zte.config_interface")
|
||||
ii = get_profile("zte.if_intf")
|
||||
assert ii is not None
|
||||
self.assertFalse(ii.enabled)
|
||||
self.assertEqual(get_parser_meta("if_intf")["rule_keys"], ("zte_zxros_show_running_config_if_intf",))
|
||||
|
||||
def test_arp_enriches_vrf_via_aux_records(self) -> None:
|
||||
|
|
@ -110,13 +113,13 @@ class ArpMultiCommandTests(unittest.TestCase):
|
|||
from netx_api.biz_state.profiles import AuxCommand
|
||||
|
||||
if_recs, if_fsm, _ = run_parser(
|
||||
"if_intf",
|
||||
"config_interface",
|
||||
raw_text=IF_INTF_SAMPLE,
|
||||
vendor="zte",
|
||||
device_type="zte_zxros",
|
||||
command="show running-config if-intf",
|
||||
)
|
||||
ra = resolve_aux_command(AuxCommand(key="if_intf", profile_id="zte.if_intf"))
|
||||
ra = resolve_aux_command(AuxCommand(key="if_intf", profile_id="zte.config_interface"))
|
||||
bundle = build_parse_bundle(
|
||||
primary_raw=ARP_MATCHING,
|
||||
primary_parser_id="arp",
|
||||
|
|
|
|||
|
|
@ -233,6 +233,9 @@ class ZteConfigIntentTests(unittest.TestCase):
|
|||
self.assertIsNotNone(hit)
|
||||
assert hit is not None
|
||||
self.assertEqual(hit.profile.profile_id, "zte.config_interface")
|
||||
ii = get_profile("zte.if_intf")
|
||||
assert ii is not None
|
||||
self.assertFalse(ii.enabled)
|
||||
|
||||
def test_config_vrf(self) -> None:
|
||||
rows = normalize_config_vrf(raw_text=_CFG_VRF, command="show running-config vrf")
|
||||
|
|
|
|||
|
|
@ -54,7 +54,12 @@ class ZteStatusParserTests(unittest.TestCase):
|
|||
for mid in ("isis_adjacency", "interface_brief", "arp", "nd6_cache", "bgp_peer", "if_intf"):
|
||||
self.assertIn(mid, metric_field_map())
|
||||
self.assertIsNotNone(get_profile("zte.isis_adjacency"))
|
||||
self.assertIsNotNone(get_profile("zte.if_intf"))
|
||||
ii = get_profile("zte.if_intf")
|
||||
self.assertIsNotNone(ii)
|
||||
assert ii is not None
|
||||
self.assertFalse(ii.enabled)
|
||||
self.assertNotIn("zte.if_intf", zte)
|
||||
self.assertIn("zte.config_interface", zte)
|
||||
|
||||
def test_isis_adjacency(self) -> None:
|
||||
text = _section(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue