A comprehensive Python SNMP library supporting v1/v2c/v3 with authentication and privacy protocols
84
A Python utility that updates configuration values on SNMP-enabled network devices.
The utility must modify device settings by sending SNMP SET commands to change OID values. It should:
Input validation requirements:
Setting a single OID value "1.3.6.1.2.1.1.4.0" to string "admin@example.com" with valid SNMPv2c credentials succeeds @test
Setting multiple OID values "1.3.6.1.2.1.1.4.0" to "admin@example.com" and "1.3.6.1.2.1.1.6.0" to "Data Center 1" with valid credentials succeeds @test
Attempting to connect to invalid hostname "999.999.999.999" returns an error @test
Calling with empty hostname raises ValueError @test
@generates
def update_device_config(host: str, port: int, credentials: dict, changes: list[tuple[str, str]]) -> dict:
"""
Update configuration values on an SNMP device using SET operations.
Args:
host: Device hostname or IP address
port: SNMP port (typically 161)
credentials: Dictionary with either:
- 'community': string for SNMPv2c, OR
- 'username' and 'auth_key': strings for SNMPv3
changes: List of (OID, value) tuples where OID and value are strings
Returns:
Dictionary with:
- 'success': bool indicating if all changes succeeded
- 'updated_oids': list of OIDs successfully updated
- 'error': error message string if failed, None if successful
Raises:
ValueError: If host is empty, port is invalid, or credentials are missing
"""
passProvides SNMP protocol operations including SET commands for modifying device configurations.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/pypi-pysnmpevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10