Skip to content

Commit ddd7c5d

Browse files
authored
Fix SNMPv3 configuration on Edge Filers (#319)
- Added missing _classname='SnmpV3Config' for proper XML serialization - Fixed SNMPv3 enable() and modify() methods to include class name - Updated unit tests to expect the new _classname attribute - Added docstring for get_configuration() method - Fixed modify() method to default port to 161 - Updated changelog with bug fix entry This resolves the issue where SNMPv3 configuration appeared successful but wasn't actually working on Edge Filers due to improper XML serialization without the required class attribute.
1 parent 6e0423e commit ddd7c5d

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

cterasdk/edge/snmp.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def enable(self, port=161, community_str=None, username=None, auth_password=None
3737
param.readCommunity = community_str
3838
if username is not None and auth_password is not None and privacy_password is not None:
3939
param.snmpV3 = Object()
40+
param.snmpV3._classname = 'SnmpV3Config' # pylint: disable=protected-access
4041
param.snmpV3.mode = enum.Mode.Enabled
4142
param.snmpV3.username = username
4243
param.snmpV3.authenticationPassword = auth_password
@@ -53,9 +54,15 @@ def disable(self):
5354
logger.info("Disabled SNMP.")
5455

5556
def get_configuration(self):
57+
"""
58+
Get current SNMP configuration
59+
60+
:return: Current SNMP configuration
61+
:rtype: cterasdk.common.object.Object
62+
"""
5663
return self._edge.api.get('/config/snmp')
5764

58-
def modify(self, port=None, community_str=None, username=None, auth_password=None, privacy_password=None):
65+
def modify(self, port=161, community_str=None, username=None, auth_password=None, privacy_password=None):
5966
"""
6067
Modify current SNMP configuration. Only configurations that are not `None` will be changed. SNMP must be enabled
6168
@@ -68,12 +75,12 @@ def modify(self, port=None, community_str=None, username=None, auth_password=Non
6875
current_config = self.get_configuration()
6976
if current_config.mode == enum.Mode.Disabled:
7077
raise CTERAException("SNMP configuration cannot be modified when disabled")
71-
if port:
72-
current_config.port = port
78+
current_config.port = port
7379
if community_str:
7480
current_config.readCommunity = community_str
7581
if username is not None and auth_password is not None and privacy_password is not None:
7682
current_config.snmpV3 = Object()
83+
current_config.snmpV3._classname = 'SnmpV3Config' # pylint: disable=protected-access
7784
current_config.snmpV3.mode = enum.Mode.Enabled
7885
current_config.snmpV3.username = username
7986
current_config.snmpV3.authenticationPassword = auth_password

docs/source/UserGuides/Miscellaneous/Changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Improvements
2626
Bug Fixes
2727
^^^^^^^^^
2828

29+
* Fixed SNMPv3 configuration on Edge Filers - added missing XML class name for proper serialization
2930
* Corrected Direct I/O object class references in the documentation
3031

3132
.. code:: python

tests/ut/edge/test_snmp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def _get_snmp_object(self, port=None, community_str=None, username=None, auth_pa
7676
param.readCommunity = community_str
7777
if username is not None and auth_password is not None and privacy_password is not None:
7878
param.snmpV3 = Object()
79+
param.snmpV3._classname = 'SnmpV3Config' # pylint: disable=protected-access
7980
param.snmpV3.mode = Mode.Enabled
8081
param.snmpV3.username = username
8182
param.snmpV3.authenticationPassword = auth_password

0 commit comments

Comments
 (0)