def _create_configs_ipv4() -> List[SNMPHostConfig]: return [ SNMPHostConfig( is_ipv6_primary=False, hostname="ipv4/snmpv1", ipaddress="127.0.0.1", credentials="public", port=1337, 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=SNMPBackendEnum.CLASSIC, ), SNMPHostConfig( is_ipv6_primary=False, hostname="ipv4/snmpv2", ipaddress="127.0.0.1", credentials="public", port=1337, is_bulkwalk_host=True, 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=SNMPBackendEnum.CLASSIC, ), SNMPHostConfig( is_ipv6_primary=False, hostname="ipv4/snmpv3", ipaddress="127.0.0.1", credentials=( "authPriv", "md5", "md5desuser", "md5password", "DES", "desencryption", ), port=1338, 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=SNMPBackendEnum.CLASSIC, ), ]
def _create_configs_ipv6() -> List[SNMPHostConfig]: return [ SNMPHostConfig( is_ipv6_primary=True, hostname="ipv6/snmpv1", ipaddress="::1", credentials="public", port=1337, 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, ), SNMPHostConfig( is_ipv6_primary=True, hostname="ipv6/snmpv2", ipaddress="::1", credentials="public", port=1337, is_bulkwalk_host=True, 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, ), SNMPHostConfig( is_ipv6_primary=True, hostname="ipv6/snmpv3", ipaddress="::1", credentials=( "authPriv", "sha", "shaaesuser", "shapassword", "AES", "aesencryption", ), port=1340, 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, ), ]
def fetcher_inline_legacy_fixture(self, file_cache): return SNMPFetcher( file_cache, sections={}, on_error="raise", missing_sys_description=False, do_status_data_inventory=False, snmp_config=SNMPHostConfig( is_ipv6_primary=False, hostname="bob", ipaddress="1.2.3.4", credentials="public", port=42, is_bulkwalk_host=False, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=0, timing={}, oid_range_limits=[], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackend.inline_legacy if not cmk_version.is_raw_edition() else SNMPBackend.classic, ), )
def from_json(cls, serialized: Dict[str, Any]) -> 'SNMPFetcher': # The SNMPv3 configuration is represented by a tuple of different lengths (see # SNMPCredentials). Since we just deserialized from JSON, we have to convert the # list used by JSON back to a tuple. # SNMPv1/v2 communities are represented by a string: Leave it untouched. if isinstance(serialized["snmp_config"]["credentials"], list): serialized["snmp_config"]["credentials"] = tuple( serialized["snmp_config"]["credentials"]) return cls( file_cache=SNMPFileCache.from_json(serialized.pop("file_cache")), snmp_section_trees={ SectionName(name): [SNMPTree.from_json(tree) for tree in trees ] for name, trees in serialized["snmp_section_trees"].items() }, snmp_section_detects=[ ( SectionName(name), # The cast is necessary as mypy does not infer types in a list comprehension. # See https://github.com/python/mypy/issues/5068 SNMPDetectSpec([[cast(SNMPDetectAtom, tuple(inner)) for inner in outer] for outer in specs]), ) for name, specs in serialized["snmp_section_detects"] ], configured_snmp_sections={ SectionName(name) for name in serialized["configured_snmp_sections"] }, on_error=serialized["on_error"], missing_sys_description=serialized["missing_sys_description"], use_snmpwalk_cache=serialized["use_snmpwalk_cache"], snmp_config=SNMPHostConfig(**serialized["snmp_config"]), )
def fetcher_pysnmp(self, file_cache: SNMPFileCache) -> SNMPFetcher: return SNMPFetcher( file_cache, sections={}, on_error=OnError.RAISE, missing_sys_description=False, do_status_data_inventory=False, section_store_path="/tmp/db", snmp_config=SNMPHostConfig( is_ipv6_primary=False, hostname=HostName("bob"), ipaddress="1.2.3.4", credentials="public", port=42, is_bulkwalk_host=False, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=0, timing={}, oid_range_limits={}, snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackendEnum.PYSNMP if not cmk_version.is_raw_edition() else SNMPBackendEnum.CLASSIC, ), )
def backend_fixture(request, snmp_data_dir): backend = request.param if backend is None: return pytest.skip("CEE feature only") config = SNMPHostConfig( is_ipv6_primary=False, ipaddress="127.0.0.1", hostname="localhost", credentials="public", port=1337, # TODO: Use SNMPv2 over v1 for the moment is_bulkwalk_host=False, is_snmpv2or3_without_bulkwalk_host=True, bulk_walk_size_of=10, timing={}, oid_range_limits=[], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=backend is StoredWalkSNMPBackend, is_inline_snmp_host=backend is InlineSNMPBackend, record_stats=False, ) snmpwalks_dir = cmk.utils.paths.snmpwalks_dir # Point the backend to the test walks shipped with the test file in git cmk.utils.paths.snmpwalks_dir = str(snmp_data_dir / "cmk-walk") assert snmp_data_dir.exists() assert (snmp_data_dir / "cmk-walk").exists() yield backend(config) # Restore global variable. cmk.utils.paths.snmpwalks_dir = snmpwalks_dir
def _from_json(cls, serialized: Dict[str, Any]) -> 'SNMPFetcher': # The SNMPv3 configuration is represented by a tuple of different lengths (see # SNMPCredentials). Since we just deserialized from JSON, we have to convert the # list used by JSON back to a tuple. # SNMPv1/v2 communities are represented by a string: Leave it untouched. if isinstance(serialized["snmp_config"]["credentials"], list): serialized["snmp_config"]["credentials"] = tuple( serialized["snmp_config"]["credentials"]) return cls( file_cache=SNMPFileCache.from_json(serialized.pop("file_cache")), snmp_plugin_store=SNMPPluginStore.deserialize( serialized["snmp_plugin_store"]), disabled_sections={ SectionName(name) for name in serialized["disabled_sections"] }, configured_snmp_sections={ SectionName(name) for name in serialized["configured_snmp_sections"] }, inventory_snmp_sections={ SectionName(name) for name in serialized["inventory_snmp_sections"] }, on_error=serialized["on_error"], missing_sys_description=serialized["missing_sys_description"], use_snmpwalk_cache=serialized["use_snmpwalk_cache"], do_status_data_inventory=serialized["do_status_data_inventory"], snmp_config=SNMPHostConfig(**serialized["snmp_config"]), )
def fetcher(self, file_cache): return SNMPFetcher( file_cache, sections={}, on_error="raise", missing_sys_description=False, do_status_data_inventory=False, section_store_path="/tmp/db", snmp_config=SNMPHostConfig( is_ipv6_primary=False, hostname="bob", ipaddress="1.2.3.4", credentials="public", port=42, is_bulkwalk_host=False, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=0, timing={}, oid_range_limits=[], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackendEnum.CLASSIC, ), )
def fetcher_fixture(self, file_cache): SNMPFetcher.snmp_plugin_store = SNMPPluginStore({ SectionName("pim"): SNMPPluginStoreItem( trees=[ BackendSNMPTree(base=".1.1.1", oids=[ BackendOIDSpec("1.2", "string", False), BackendOIDSpec("3.4", "string", False) ]) ], detect_spec=SNMPDetectSpec([[("1.2.3.4", "pim device", True)]]), ), SectionName("pam"): SNMPPluginStoreItem( trees=[ BackendSNMPTree( base=".1.2.3", oids=[ BackendOIDSpec("4.5", "string", False), BackendOIDSpec("6.7", "string", False), BackendOIDSpec("8.9", "string", False) ], ), ], detect_spec=SNMPDetectSpec([[("1.2.3.4", "pam device", True)]]), ), SectionName("pum"): SNMPPluginStoreItem( trees=[ BackendSNMPTree(base=".2.2.2", oids=[BackendOIDSpec("2.2", "string", False)]), BackendSNMPTree(base=".3.3.3", oids=[BackendOIDSpec("2.2", "string", False)]), ], detect_spec=SNMPDetectSpec([[]]), ), }) return SNMPFetcher( file_cache, disabled_sections=set(), configured_snmp_sections=set(), inventory_snmp_sections=set(), on_error="raise", missing_sys_description=False, use_snmpwalk_cache=False, do_status_data_inventory=False, snmp_config=SNMPHostConfig( is_ipv6_primary=False, hostname="bob", ipaddress="1.2.3.4", credentials="public", port=42, is_bulkwalk_host=False, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=0, timing={}, oid_range_limits=[], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackend.classic, ), )
def from_json(cls, serialized: Dict[str, Any]) -> 'SNMPDataFetcher': return cls( { name: [SNMPTree.from_json(tree) for tree in trees] for name, trees in serialized["oid_infos"].items() }, serialized["use_snmpwalk_cache"], SNMPHostConfig(**serialized["snmp_config"]), )
def from_json(cls, serialized: Dict[str, Any]) -> 'SNMPFetcher': return cls( SNMPFileCache.from_json(serialized.pop("file_cache")), { SectionName(name): [SNMPTree.from_json(tree) for tree in trees ] for name, trees in serialized["oid_infos"].items() }, serialized["use_snmpwalk_cache"], SNMPHostConfig(**serialized["snmp_config"]), )
def _create_configs_special_auth() -> List[SNMPHostConfig]: return [ SNMPHostConfig( is_ipv6_primary=False, hostname="noauthnopriv", ipaddress="127.0.0.1", credentials=( "noAuthNoPriv", "noAuthNoPrivUser", ), port=1339, 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, ), SNMPHostConfig( is_ipv6_primary=False, hostname="authonly", ipaddress="127.0.0.1", credentials=( "authNoPriv", "md5", "authOnlyUser", "authOnlyUser", ), port=1337, 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, ), ]
def test_factory_snmp_backend_unknown_backend( snmp_config: SNMPHostConfig) -> None: with pytest.raises(NotImplementedError, match="Unknown SNMP backend"): snmp_config = snmp_config._replace( snmp_backend="bla") # type: ignore[arg-type] if inline: assert isinstance( factory.backend(snmp_config, logging.getLogger()), inline.InlineSNMPBackend) else: assert isinstance( factory.backend(snmp_config, logging.getLogger()), ClassicSNMPBackend, )
def fetcher_fixture(self, fc_conf): return SNMPFetcher.from_json( json_identity({ "file_cache": fc_conf.configure(), "snmp_section_trees": { "pim": [SNMPTree(base=".1.1.1", oids=["1.2", "3.4"]).to_json()], "pam": [ SNMPTree(base=".1.2.3", oids=["4.5", "6.7", "8.9"]).to_json() ], "pum": [ SNMPTree(base=".2.2.2", oids=["2.2"]).to_json(), SNMPTree(base=".3.3.3", oids=["2.2"]).to_json(), ], }, "snmp_section_detects": [ ("pim", [[("1.2.3.4", "pim device", True)]]), ("pam", [[("1.2.3.4", "pam device", True)]]), ], "configured_snmp_sections": [], "on_error": "raise", "missing_sys_description": False, "use_snmpwalk_cache": False, "snmp_config": SNMPHostConfig( is_ipv6_primary=False, hostname="bob", ipaddress="1.2.3.4", credentials=(), port=42, is_bulkwalk_host=False, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=0, timing={}, oid_range_limits=[], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, is_inline_snmp_host=False, record_stats=False, )._asdict(), }))
def fixture_snmp_config(): return SNMPHostConfig( is_ipv6_primary=False, hostname="bob", ipaddress="1.2.3.4", credentials="public", port=42, is_bulkwalk_host=False, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=0, timing={}, oid_range_limits=[], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackendEnum.CLASSIC, )
def from_json(cls, serialized: Dict[str, Any]) -> 'SNMPFetcher': return cls( file_cache=SNMPFileCache.from_json(serialized.pop("file_cache")), snmp_section_trees={ SectionName(name): [SNMPTree.from_json(tree) for tree in trees ] for name, trees in serialized["snmp_section_trees"].items() }, snmp_section_detects=[ (SectionName(name), specs) for name, specs in serialized["snmp_section_detects"] ], configured_snmp_sections={ SectionName(name) for name in serialized["configured_snmp_sections"] }, on_error=serialized["on_error"], missing_sys_description=serialized["missing_sys_description"], use_snmpwalk_cache=serialized["use_snmpwalk_cache"], snmp_config=SNMPHostConfig(**serialized["snmp_config"]), )
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, snmp_backend=SNMPBackendEnum.CLASSIC, ) assert ClassicSNMPBackend(snmp_config, logger)._snmp_proto_spec() == 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, is_inline_snmp_host=False, record_stats=False, ) assert ClassicSNMPBackend(snmp_config, logger)._snmp_port_spec() == expected
def fetcher_fixture(self, file_cache): return SNMPFetcher( file_cache, snmp_section_trees={ SectionName("pim"): [SNMPTree(base=".1.1.1", oids=["1.2", "3.4"])], SectionName("pam"): [SNMPTree(base=".1.2.3", oids=["4.5", "6.7", "8.9"])], SectionName("pum"): [ SNMPTree(base=".2.2.2", oids=["2.2"]), SNMPTree(base=".3.3.3", oids=["2.2"]), ], }, snmp_section_detects={ SectionName("pim"): SNMPDetectSpec([[("1.2.3.4", "pim device", True)]]), SectionName("pam"): SNMPDetectSpec([[("1.2.3.4", "pam device", True)]]), }, disabled_sections=set(), configured_snmp_sections=set(), structured_data_snmp_sections=set(), on_error="raise", missing_sys_description=False, use_snmpwalk_cache=False, snmp_config=SNMPHostConfig( is_ipv6_primary=False, hostname="bob", ipaddress="1.2.3.4", credentials="public", port=42, is_bulkwalk_host=False, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=0, timing={}, oid_range_limits=[], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackend.classic, ), )
def _from_json(cls, serialized: Dict[str, Any]) -> 'SNMPFetcher': # The SNMPv3 configuration is represented by a tuple of different lengths (see # SNMPCredentials). Since we just deserialized from JSON, we have to convert the # list used by JSON back to a tuple. # SNMPv1/v2 communities are represented by a string: Leave it untouched. if isinstance(serialized["snmp_config"]["credentials"], list): serialized["snmp_config"]["credentials"] = tuple( serialized["snmp_config"]["credentials"]) return cls( file_cache=SNMPFileCache.from_json(serialized.pop("file_cache")), sections={ SectionName(s): SectionMeta.deserialize(m) for s, m in serialized["sections"].items() }, on_error=serialized["on_error"], missing_sys_description=serialized["missing_sys_description"], do_status_data_inventory=serialized["do_status_data_inventory"], snmp_config=SNMPHostConfig.deserialize(serialized["snmp_config"]), )
def _create_configs_oidranges() -> List: first_str: Literal["first", "last"] = "first" mid_str: Literal["mid"] = "mid" last_str: Literal["first", "last"] = "last" return [ SNMPHostConfig( is_ipv6_primary=False, hostname=HostName("oidranges/first"), ipaddress="127.0.0.1", credentials="public", port=1337, is_bulkwalk_host=True, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=10, timing={}, oid_range_limits={SectionName("if64"): [(first_str, 3)]}, snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackendEnum.CLASSIC, ), SNMPHostConfig( is_ipv6_primary=False, hostname=HostName("oidranges/mid"), ipaddress="127.0.0.1", credentials="public", port=1337, is_bulkwalk_host=True, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=10, timing={}, oid_range_limits={SectionName("if64"): [(mid_str, (4, 2))]}, snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackendEnum.CLASSIC, ), SNMPHostConfig( is_ipv6_primary=False, hostname=HostName("oidranges/last"), ipaddress="127.0.0.1", credentials="public", port=1337, is_bulkwalk_host=True, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=10, timing={}, oid_range_limits={SectionName("if64"): [(last_str, 3)]}, snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackendEnum.CLASSIC, ), SNMPHostConfig( is_ipv6_primary=False, hostname=HostName("oidranges"), ipaddress="127.0.0.1", credentials="public", port=1337, is_bulkwalk_host=True, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=10, timing={}, oid_range_limits={ SectionName("if64"): [(first_str, 1), (mid_str, (3, 1)), (last_str, 2)] }, snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackendEnum.CLASSIC, ), ]
def test_factory_snmp_backend_inline(snmp_config: SNMPHostConfig) -> None: snmp_config = snmp_config._replace(snmp_backend=SNMPBackendEnum.INLINE) if inline: assert isinstance(factory.backend(snmp_config, logging.getLogger()), inline.InlineSNMPBackend)
"context_name", ]) @pytest.mark.parametrize("settings,expected", [ (SNMPSettings( snmp_config=SNMPHostConfig( is_ipv6_primary=False, hostname="localhost", ipaddress="127.0.0.1", credentials="public", port=161, is_bulkwalk_host=True, is_snmpv2or3_without_bulkwalk_host=True, bulk_walk_size_of=10, timing={ "timeout": 2, "retries": 3 }, oid_range_limits=[], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackendEnum.CLASSIC, ), context_name=None, ), [ 'snmpbulkwalk', '-Cr10', '-v2c', '-c', 'public', '-m', '', '-M', '', '-t', '2.00', '-r', '3', '-Cc' ]), (SNMPSettings(
SNMPBackend, SNMPBackendEnum, SNMPHostConfig, SpecialColumn, ) import cmk.base.config as config SNMPConfig = SNMPHostConfig( is_ipv6_primary=False, hostname=HostName("testhost"), ipaddress="1.2.3.4", credentials="", port=42, is_bulkwalk_host=False, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=0, timing={}, oid_range_limits=[], snmpv3_contexts=[], character_encoding="ascii", is_usewalk_host=False, snmp_backend=SNMPBackendEnum.CLASSIC, ) class SNMPTestBackend(SNMPBackend): def get(self, oid, context_name=None): pass def walk(self, oid,
None, # type: ignore # not used backend=None, # type: ignore # monkeypatched ) assert actual_result is expected_result # C/P from `test_snmplib_snmp_table`. SNMPConfig = SNMPHostConfig( is_ipv6_primary=False, hostname="testhost", ipaddress="1.2.3.4", credentials="", port=42, is_bulkwalk_host=False, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=0, timing={}, oid_range_limits=[], snmpv3_contexts=[], character_encoding="ascii", is_usewalk_host=False, is_inline_snmp_host=False, record_stats=False, ) # Adapted from `test_snmplib_snmp_table`. class SNMPTestBackend(ABCSNMPBackend): def get(self, oid, context_name=None): raise NotImplementedError("get")
def _create_configs_oidranges(): return [ SNMPHostConfig( is_ipv6_primary=False, hostname="oidranges/first", ipaddress="127.0.0.1", credentials="public", port=1337, is_bulkwalk_host=True, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=10, timing={}, oid_range_limits=[('if64', [('first', 3)])], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackend.classic, ), SNMPHostConfig( is_ipv6_primary=False, hostname="oidranges/mid", ipaddress="127.0.0.1", credentials="public", port=1337, is_bulkwalk_host=True, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=10, timing={}, oid_range_limits=[('if64', [('mid', (4, 2))])], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackend.classic, ), SNMPHostConfig( is_ipv6_primary=False, hostname="oidranges/last", ipaddress="127.0.0.1", credentials="public", port=1337, is_bulkwalk_host=True, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=10, timing={}, oid_range_limits=[('if64', [('last', 3)])], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackend.classic, ), SNMPHostConfig( is_ipv6_primary=False, hostname="oidranges", ipaddress="127.0.0.1", credentials="public", port=1337, is_bulkwalk_host=True, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=10, timing={}, oid_range_limits=[('if64', [('first', 1), ('mid', (3, 1)), ('last', 2)])], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackend.classic, ), ]
def test_factory_snmp_backend_pysnmp(snmp_config: SNMPHostConfig) -> None: snmp_config = snmp_config._replace(snmp_backend=SNMPBackendEnum.PYSNMP) if pysnmp_backend: assert isinstance(factory.backend(snmp_config, logging.getLogger()), pysnmp_backend.PySNMPBackend)
def _create_configs_oidranges(): return [ SNMPHostConfig( is_ipv6_primary=False, hostname=HostName("oidranges/first"), ipaddress="127.0.0.1", credentials="public", port=1337, is_bulkwalk_host=True, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=10, timing={}, oid_range_limits=[("if64", [("first", 3)])], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackendEnum.CLASSIC, ), SNMPHostConfig( is_ipv6_primary=False, hostname=HostName("oidranges/mid"), ipaddress="127.0.0.1", credentials="public", port=1337, is_bulkwalk_host=True, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=10, timing={}, oid_range_limits=[("if64", [("mid", (4, 2))])], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackendEnum.CLASSIC, ), SNMPHostConfig( is_ipv6_primary=False, hostname=HostName("oidranges/last"), ipaddress="127.0.0.1", credentials="public", port=1337, is_bulkwalk_host=True, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=10, timing={}, oid_range_limits=[("if64", [("last", 3)])], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackendEnum.CLASSIC, ), SNMPHostConfig( is_ipv6_primary=False, hostname=HostName("oidranges"), ipaddress="127.0.0.1", credentials="public", port=1337, is_bulkwalk_host=True, is_snmpv2or3_without_bulkwalk_host=False, bulk_walk_size_of=10, timing={}, oid_range_limits=[("if64", [("first", 1), ("mid", (3, 1)), ("last", 2)])], snmpv3_contexts=[], character_encoding=None, is_usewalk_host=False, snmp_backend=SNMPBackendEnum.CLASSIC, ), ]