File tree Expand file tree Collapse file tree 5 files changed +52
-0
lines changed Expand file tree Collapse file tree 5 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 91
91
| regex_split | netutils.regex.regex_split |
92
92
| regex_sub | netutils.regex.regex_sub |
93
93
| longest_prefix_match | netutils.route.longest_prefix_match |
94
+ | get_running_config_command | netutils.running_config.get_running_config_command |
94
95
| uptime_seconds_to_string | netutils.time.uptime_seconds_to_string |
95
96
| uptime_string_to_seconds | netutils.time.uptime_string_to_seconds |
96
97
| vlanconfig_to_list | netutils.vlan.vlanconfig_to_list |
Original file line number Diff line number Diff line change 300
300
"vyos" : "vyos" ,
301
301
}
302
302
303
+ # Running config command
304
+ RUNNING_CONFIG_MAPPER : t .Dict [str , str ] = {
305
+ "cisco_ios" : "show run" ,
306
+ "cisco_nxos" : "show run" ,
307
+ "cisco_xr" : "show run" ,
308
+ "juniper_junos" : "show configuration | display set" ,
309
+ "arista_eos" : "show run" ,
310
+ "checkpoint_gaia" : 'clish -c "show configuration"' ,
311
+ }
312
+
303
313
# PYTNC | Normalized
304
314
PYNTC_LIB_MAPPER : t .Dict [str , str ] = {
305
315
"arista_eos_eapi" : "arista_eos" ,
Original file line number Diff line number Diff line change
1
+ """Configuration command lookup."""
2
+
3
+ from netutils .lib_mapper import RUNNING_CONFIG_MAPPER
4
+
5
+
6
+ def get_running_config_command (platform : str ) -> str :
7
+ """
8
+ Get the running config command for a specific network platform.
9
+
10
+ Args:
11
+ platform: Platform name, like 'cisco_ios' or 'juniper_junos'.
12
+
13
+ Returns:
14
+ The corresponding command as a string, or 'show run' by default.
15
+ """
16
+ return RUNNING_CONFIG_MAPPER .get (platform .lower (), "show run" )
Original file line number Diff line number Diff line change 99
99
"version_metadata" : "os_version.version_metadata" ,
100
100
"get_nist_urls" : "nist.get_nist_urls" ,
101
101
"get_nist_vendor_platform_urls" : "nist.get_nist_vendor_platform_urls" ,
102
+ "get_running_config_command" : "running_config.get_running_config_command" ,
102
103
}
103
104
104
105
Original file line number Diff line number Diff line change
1
+ """Tests for the running configuration command mapping."""
2
+
3
+ import pytest
4
+ from netutils import lib_mapper
5
+ from netutils .running_config import get_running_config_command
6
+
7
+
8
+ def test_running_config_mapper_keys_are_known ():
9
+ """Ensure all keys in RUNNING_CONFIG_MAPPER are in MAIN_LIB_MAPPER values."""
10
+ unknown_keys = [key for key in lib_mapper .RUNNING_CONFIG_MAPPER if key not in lib_mapper .MAIN_LIB_MAPPER .values ()]
11
+ assert not unknown_keys , f"Unexpected keys in RUNNING_CONFIG_MAPPER: { unknown_keys } "
12
+
13
+
14
+ @pytest .mark .parametrize ("platform,expected_command" , list (lib_mapper .RUNNING_CONFIG_MAPPER .items ()))
15
+ def test_get_running_config_command_known_platforms (platform , expected_command ):
16
+ """Test get_running_config_command returns correct command for known platforms."""
17
+ assert get_running_config_command (platform ) == expected_command
18
+ assert get_running_config_command (platform .upper ()) == expected_command # test case insensitivity
19
+
20
+
21
+ def test_get_running_config_command_unknown_platform ():
22
+ """Test get_running_config_command returns default 'show run' for unknown platforms."""
23
+ assert get_running_config_command ("unknown_platform" ) == "show run"
24
+ assert get_running_config_command ("checkpoint_gaiAA" ) == "show run"
You can’t perform that action at this time.
0 commit comments