From d45f39e3b2d4a22ad02f69419cdc20a65164285f Mon Sep 17 00:00:00 2001 From: NouhaManai Date: Tue, 13 Jun 2023 10:30:42 +0200 Subject: [PATCH] Rename generic-router to generic-device (#14723) * rename generic-router to generic-device * update snmprec * update test_profiles * update test_e2e_core_vs_python * update snmp_listener test * change example --- snmp/assets/configuration/spec.yaml | 4 ++-- snmp/datadog_checks/snmp/data/conf.yaml.example | 4 ++-- .../snmp/data/profiles/generic-device.yaml | 11 +++++++++++ .../snmp/data/profiles/generic-router.yaml | 13 +++---------- ...eneric-router.snmprec => generic-device.snmprec} | 0 snmp/tests/conftest.py | 2 +- snmp/tests/test_check.py | 2 +- snmp/tests/test_e2e_core_vs_python.py | 4 ++-- snmp/tests/test_e2e_snmp_listener.py | 6 +++--- snmp/tests/test_profiles.py | 6 +++--- snmp/tests/test_unit.py | 6 +++--- 11 files changed, 31 insertions(+), 27 deletions(-) create mode 100644 snmp/datadog_checks/snmp/data/profiles/generic-device.yaml rename snmp/tests/compose/data/{generic-router.snmprec => generic-device.snmprec} (100%) diff --git a/snmp/assets/configuration/spec.yaml b/snmp/assets/configuration/spec.yaml index 5e2d9c2d52fdc..32ea71521b83b 100644 --- a/snmp/assets/configuration/spec.yaml +++ b/snmp/assets/configuration/spec.yaml @@ -85,8 +85,8 @@ files: example: f5-big-ip: definition_file: f5-big-ip.yaml - router: - definition_file: generic-router.yaml + cisco-asr: + definition_file: cisco-asr.yaml - name: refresh_oids_cache_interval description: | Note: Beta feature, only available using python SNMP integration. diff --git a/snmp/datadog_checks/snmp/data/conf.yaml.example b/snmp/datadog_checks/snmp/data/conf.yaml.example index db8a2904970bd..2be7b889d977c 100644 --- a/snmp/datadog_checks/snmp/data/conf.yaml.example +++ b/snmp/datadog_checks/snmp/data/conf.yaml.example @@ -66,8 +66,8 @@ init_config: # profiles: # f5-big-ip: # definition_file: f5-big-ip.yaml - # router: - # definition_file: generic-router.yaml + # cisco-asr: + # definition_file: cisco-asr.yaml ## @param refresh_oids_cache_interval - integer - optional - default: 0 ## Note: Beta feature, only available using python SNMP integration. diff --git a/snmp/datadog_checks/snmp/data/profiles/generic-device.yaml b/snmp/datadog_checks/snmp/data/profiles/generic-device.yaml new file mode 100644 index 0000000000000..f528188e227ce --- /dev/null +++ b/snmp/datadog_checks/snmp/data/profiles/generic-device.yaml @@ -0,0 +1,11 @@ +# Generic profile for network devices + +extends: + - _base.yaml + - _generic-if.yaml + - _generic-ip.yaml + - _generic-tcp.yaml + - _generic-udp.yaml + - _generic-ospf.yaml + +sysobjectid: 1.3.6.1.4.* diff --git a/snmp/datadog_checks/snmp/data/profiles/generic-router.yaml b/snmp/datadog_checks/snmp/data/profiles/generic-router.yaml index 98f88ef978995..f3d54c9998bcb 100644 --- a/snmp/datadog_checks/snmp/data/profiles/generic-router.yaml +++ b/snmp/datadog_checks/snmp/data/profiles/generic-router.yaml @@ -1,12 +1,5 @@ -# Generic profile for network devices -# +# generic-device.yaml is now the generic profile for network devices +# this profile is kept only for backward compatibility extends: - - _base.yaml - - _generic-if.yaml - - _generic-ip.yaml - - _generic-tcp.yaml - - _generic-udp.yaml - - _generic-ospf.yaml - -sysobjectid: 1.3.6.1.4.* + - generic-device.yaml diff --git a/snmp/tests/compose/data/generic-router.snmprec b/snmp/tests/compose/data/generic-device.snmprec similarity index 100% rename from snmp/tests/compose/data/generic-router.snmprec rename to snmp/tests/compose/data/generic-device.snmprec diff --git a/snmp/tests/conftest.py b/snmp/tests/conftest.py index fd2d22df71af8..27ca2aeb9e07b 100644 --- a/snmp/tests/conftest.py +++ b/snmp/tests/conftest.py @@ -103,7 +103,7 @@ def create_datadog_conf_file(tmp_dir): { 'network': '{}.0/29'.format(prefix), 'port': PORT, - 'community': 'generic-router', + 'community': 'generic-device', 'version': 2, 'timeout': 1, 'retries': 2, diff --git a/snmp/tests/test_check.py b/snmp/tests/test_check.py index de3c466d50d6f..0b947bd3a556b 100644 --- a/snmp/tests/test_check.py +++ b/snmp/tests/test_check.py @@ -765,7 +765,7 @@ def test_profile_sysoid_list(aggregator, caplog): devices_matched = [ {'community_string': 'hpe-proliant', 'sysobjectid': '1.3.6.1.4.1.232.1.2'}, - {'community_string': 'generic-router', 'sysobjectid': '1.3.6.1.4.1.1.2.1.3.4'}, + {'community_string': 'generic-device', 'sysobjectid': '1.3.6.1.4.1.1.2.1.3.4'}, ] common_tags = common.CHECK_TAGS + ['snmp_profile:profile1'] for device in devices_matched: diff --git a/snmp/tests/test_e2e_core_vs_python.py b/snmp/tests/test_e2e_core_vs_python.py index 8ccbac7cc0cef..13f8ed335bd8a 100644 --- a/snmp/tests/test_e2e_core_vs_python.py +++ b/snmp/tests/test_e2e_core_vs_python.py @@ -412,8 +412,8 @@ def test_e2e_profile_fortinet_fortigate(dd_agent_check): ) -def test_e2e_profile_generic_router(dd_agent_check): - config = common.generate_container_profile_config('generic-router') +def test_e2e_profile_generic_device(dd_agent_check): + config = common.generate_container_profile_config('generic-device') assert_python_vs_core(dd_agent_check, config) diff --git a/snmp/tests/test_e2e_snmp_listener.py b/snmp/tests/test_e2e_snmp_listener.py index 0d61981a5e156..512c02e726de9 100644 --- a/snmp/tests/test_e2e_snmp_listener.py +++ b/snmp/tests/test_e2e_snmp_listener.py @@ -53,7 +53,7 @@ def test_e2e_snmp_listener(dd_agent_check, container_ip, autodiscovery_ready): # === network profile === common_tags = [ - 'snmp_profile:generic-router', + 'snmp_profile:generic-device', 'snmp_device:{}'.format(snmp_device), 'autodiscovery_subnet:{}.0/29'.format(subnet_prefix), 'tag1:val1', @@ -128,7 +128,7 @@ def test_e2e_snmp_listener(dd_agent_check, container_ip, autodiscovery_ready): 'snmp_device:{}'.format(snmp_device), 'autodiscovery_subnet:{}.0/27'.format(subnet_prefix), 'snmp_host:41ba948911b9', - 'snmp_profile:generic-router', + 'snmp_profile:generic-device', 'device_namespace:test-auth-proto-{}'.format(auth_proto), ] @@ -142,7 +142,7 @@ def test_e2e_snmp_listener(dd_agent_check, container_ip, autodiscovery_ready): 'snmp_device:{}'.format(_build_device_ip(container_ip, '2')), 'autodiscovery_subnet:{}.0/27'.format(subnet_prefix), 'snmp_host:41ba948911b9', - 'snmp_profile:generic-router', + 'snmp_profile:generic-device', ] aggregator.assert_metric('snmp.devices_monitored', count=0, tags=tags) diff --git a/snmp/tests/test_profiles.py b/snmp/tests/test_profiles.py index 276a576295010..5c97d052d8780 100644 --- a/snmp/tests/test_profiles.py +++ b/snmp/tests/test_profiles.py @@ -416,8 +416,8 @@ def test_f5(aggregator): @pytest.mark.usefixtures("dd_environment") -def test_router(aggregator): - profile = "generic-router" +def test_device(aggregator): + profile = "generic-device" run_profile_check(profile) common_tags = common.CHECK_TAGS + ['snmp_profile:' + profile] @@ -474,7 +474,7 @@ def test_f5_router(aggregator): instance['community_string'] = 'f5-big-ip' instance['enforce_mib_constraints'] = False - init_config = {'profiles': {'router': {'definition_file': 'generic-router.yaml'}}} + init_config = {'profiles': {'router': {'definition_file': 'generic-device.yaml'}}} check = SnmpCheck('snmp', init_config, [instance]) check.check(instance) diff --git a/snmp/tests/test_unit.py b/snmp/tests/test_unit.py index ba0a9553facab..f529f1ff72fe0 100644 --- a/snmp/tests/test_unit.py +++ b/snmp/tests/test_unit.py @@ -491,12 +491,12 @@ def test_profile_override(): with temp_dir() as tmp: with mock_profiles_confd_root(tmp): - profile_file = os.path.join(tmp, 'generic-router.yaml') + profile_file = os.path.join(tmp, 'generic-device.yaml') with open(profile_file, 'wb') as f: f.write(yaml.safe_dump(profile)) profiles = _load_default_profiles() - assert profiles['generic-router'] == {'definition': profile} + assert profiles['generic-device'] == {'definition': profile} def test_discovery_tags(): @@ -525,7 +525,7 @@ def mock_fetch(cfg): assert set(config.tags) == { 'snmp_device:192.168.0.2', 'test:check', - 'snmp_profile:generic-router', + 'snmp_profile:generic-device', 'autodiscovery_subnet:192.168.0.0/29', }