def walk_for_export(snmp_config, oid): # type: (SNMPHostConfig, OID) -> SNMPRowInfoForStoredWalk if snmp_config.is_inline_snmp_host: backend = inline.InlineSNMPBackend(config.record_inline_snmp_stats) # type: ABCSNMPBackend else: backend = ClassicSNMPBackend() rows = backend.walk(snmp_config, oid) return _convert_rows_for_stored_walk(rows)
def factory(snmp_config, enforce_stored_walks): # type: (SNMPHostConfig, bool) -> ABCSNMPBackend if enforce_stored_walks or snmp_config.is_usewalk_host: return StoredWalkSNMPBackend() if snmp_config.is_inline_snmp_host: return inline.InlineSNMPBackend(config.record_inline_snmp_stats) return ClassicSNMPBackend()
def test_snmp_proto_spec(monkeypatch, is_ipv6, expected): snmp_config = SNMPHostConfig( is_ipv6_primary=is_ipv6, hostname="localhost", ipaddress="127.0.0.1", credentials="public", port=161, is_bulkwalk_host=False, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=10, timing={}, oid_range_limits=[], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, is_inline_snmp_host=False, ) assert ClassicSNMPBackend()._snmp_proto_spec(snmp_config) == expected
def test_snmp_port_spec(port, expected): snmp_config = SNMPHostConfig( is_ipv6_primary=False, hostname="localhost", ipaddress="127.0.0.1", credentials="public", port=port, is_bulkwalk_host=False, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=10, timing={}, oid_range_limits=[], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackend.classic, ) assert ClassicSNMPBackend(snmp_config, logger)._snmp_port_spec() == expected
def test_snmp_walk_command(monkeypatch, settings, expected): backend = ClassicSNMPBackend(settings.snmp_config, logger) assert backend._snmp_walk_command(settings.context_name) == expected
def test_snmp_walk_command(monkeypatch, settings, expected): assert ClassicSNMPBackend()._snmp_walk_command( settings.snmp_config, settings.context_name) == expected