Skip to content

Commit c434f84

Browse files
authoredMar 2, 2025
Support new type "Raritan" PDU in snmpPduController (sonic-net#16987)
Support new type "Raritan" PDU in snmpPduController
1 parent 478de97 commit c434f84

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
 

‎tests/common/plugins/pdu_controller/snmp_pdu_controllers.py

+24
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ def pduCntrlOid(self):
5252
APC_RPDU_PORT_NAME_BASE_OID = "1.3.6.1.4.1.318.1.1.12.3.3.1.1.2"
5353
APC_RPDU_PORT_STATUS_BASE_OID = "1.3.6.1.4.1.318.1.1.12.3.5.1.1.4"
5454
APC_RPDU_PORT_CONTROL_BASE_OID = "1.3.6.1.4.1.318.1.1.12.3.3.1.1.4"
55+
# MIB OID for 'Raritan PDU'
56+
RARITAN_PORT_NAME_BASE_OID = "1.3.6.1.4.1.13742.6.3.5.3.1.3"
57+
RARITAN_PORT_STATUS_BASE_OID = "1.3.6.1.4.1.13742.6.4.1.2.1.3"
58+
RARITAN_PORT_CONTROL_BASE_OID = "1.3.6.1.4.1.13742.6.4.1.2.1.2"
59+
RARITAN_PORT_POWER_BASE_OID = "1.3.6.1.4.1.13742.6.5.4.3.1.4"
5560
self.STATUS_ON = "1"
5661
self.STATUS_OFF = "0"
5762
self.CONTROL_ON = "1"
@@ -95,6 +100,16 @@ def pduCntrlOid(self):
95100
self.PORT_CONTROL_BASE_OID = APC_RPDU_PORT_CONTROL_BASE_OID
96101
self.has_lanes = False
97102
self.max_lanes = 1
103+
elif self.pduType == "Raritan":
104+
self.PORT_NAME_BASE_OID = RARITAN_PORT_NAME_BASE_OID
105+
self.PORT_STATUS_BASE_OID = RARITAN_PORT_STATUS_BASE_OID
106+
self.PORT_CONTROL_BASE_OID = RARITAN_PORT_CONTROL_BASE_OID
107+
self.PORT_POWER_BASE_OID = RARITAN_PORT_POWER_BASE_OID
108+
self.STATUS_ON = "7"
109+
self.STATUS_OFF = "8"
110+
self.CONTROL_OFF = "0"
111+
self.has_lanes = False
112+
self.max_lanes = 1
98113
else:
99114
pass
100115

@@ -221,7 +236,14 @@ def _get_one_outlet_power(self, cmdGen, snmp_auth, port_id, status):
221236
if not self.PORT_POWER_BASE_OID:
222237
return
223238

239+
# For PDU "Raritan", the SNMP MIB OID of power define as below:
240+
# measurementsOutletSensorValue - .1.3.6.1.4.1.13742.6.5.4.3.1.4.a.b.c
241+
# a = pduID (almost always "1" unless you are linking the PDUs)
242+
# b = outletId (the number of the outlet on the PDU)
243+
# c = sensorID (1=amps, 4=volts, 5=watts)
224244
query_id = '.' + self.PORT_POWER_BASE_OID + port_id
245+
if self.pduType == "Raritan":
246+
query_id = query_id + ".5" # 5 = watts for Raritan PDU
225247
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
226248
snmp_auth,
227249
cmdgen.UdpTransportTarget((self.controller, 161)),
@@ -235,6 +257,8 @@ def _get_one_outlet_power(self, cmdGen, snmp_auth, port_id, status):
235257
current_oid = str(oid)
236258
current_val = str(val)
237259
port_oid = current_oid.replace(self.PORT_POWER_BASE_OID, '')
260+
if self.pduType == "Raritan":
261+
port_oid = port_oid.rsplit('.', 1)[0] # Remove the ".5" suffix
238262
if port_oid == port_id:
239263
if current_val != "":
240264
status['output_watts'] = current_val

0 commit comments

Comments
 (0)