首页 > 解决方案 > pysnmp - Using variables to set the v3 auth & priv tpyes

问题描述

I have variables set with the required auth authProto and priv privProto types that I want to substitute for the usmHMACSHAAuthProtocol and usmAesCfb128Protocol entries below:

config.addV3User(
    snmpEngine, user,
    config.usmHMACSHAAuthProtocol, authKey,
    config.usmAesCfb128Protocol, privKey
)

What is the cleanest way to make use of these variables?

标签: pythonpysnmp

解决方案


Based on your comment, it seems that your problem is a simple typo. If you do authProto = "config.usmHMACSHAAuthProtocol", it is setting authProto to the text config.usmHMACSHAAuthProtocol. You want to set it to the value. To do this, just remove the quotes:

authProto = config.usmHMACSHAAuthProtocol.

Then, you can just use it directly when you addV3User.


推荐阅读