Skip to content

Commit

Permalink
Rename generic-router to generic-device (#14723)
Browse files Browse the repository at this point in the history
* rename generic-router to generic-device

* update snmprec

* update test_profiles

* update test_e2e_core_vs_python

* update snmp_listener test

* change example
  • Loading branch information
NouhaManai96 authored Jun 13, 2023
1 parent 9f8a32d commit d45f39e
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 27 deletions.
4 changes: 2 additions & 2 deletions snmp/assets/configuration/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions snmp/datadog_checks/snmp/data/conf.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions snmp/datadog_checks/snmp/data/profiles/generic-device.yaml
Original file line number Diff line number Diff line change
@@ -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.*
13 changes: 3 additions & 10 deletions snmp/datadog_checks/snmp/data/profiles/generic-router.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion snmp/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion snmp/tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions snmp/tests/test_e2e_core_vs_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
6 changes: 3 additions & 3 deletions snmp/tests/test_e2e_snmp_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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),
]

Expand All @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions snmp/tests/test_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions snmp/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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',
}

Expand Down

0 comments on commit d45f39e

Please sign in to comment.