CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pysnmp

A comprehensive Python SNMP library supporting v1/v2c/v3 with authentication and privacy protocols

84

0.94x
Overview
Eval results
Files

task.mdevals/scenario-3/

Network Device Configuration Manager

A Python utility that updates configuration values on SNMP-enabled network devices.

Requirements

The utility must modify device settings by sending SNMP SET commands to change OID values. It should:

  • Connect to a target device using hostname/IP, port, and authentication credentials
  • Update one or more OID values in a single operation
  • Support both SNMPv2c (community string) and SNMPv3 (username/auth key) authentication
  • Return success status and list of updated OIDs
  • Return error information if the operation fails

Input validation requirements:

  • Validate hostname is not empty
  • Validate port is between 1 and 65535
  • Validate authentication credentials are provided
  • Raise ValueError for invalid inputs before attempting network operations

Test Cases

  • 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

Implementation

@generates

API

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
    """
    pass

Dependencies { .dependencies }

pysnmp { .dependency }

Provides SNMP protocol operations including SET commands for modifying device configurations.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-pysnmp

tile.json