Skip to content

Commit

Permalink
Support Vertiv PDU in snmpPduController (#5491)
Browse files Browse the repository at this point in the history
What is the motivation for this PR?
* Integrate Vertiv Geist Upgradeable PDU
* Fix some typo and flake8 warning

How did you do it?
Add some MiB OIDs of Vertiv Geist Upgradeable PDU in class snmpPduController.

How did you verify/test it?
Verified on Vertiv Geist Upgradeable PDU.

Signed-off-by: Zhijian Li <zhijianli@microsoft.com>
  • Loading branch information
lizhijianrd authored Apr 12, 2022
1 parent 91d23e7 commit c41fff2
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions tests/common/plugins/pdu_controller/snmp_pdu_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

logger = logging.getLogger(__name__)


class snmpPduController(PduControllerBase):
"""
PDU Controller class for SNMP conrolled PDUs - 'Sentry Switched CDU' and 'APC Web/SNMP Management Card'
Expand Down Expand Up @@ -54,6 +55,8 @@ def get_pdu_controller_type(self):
self.pduType = "APC"
if 'Emerson' in pdu:
self.pduType = 'Emerson'
if 'Vertiv Geist Upgradeable PDU' in pdu:
self.pduType = 'Vertiv'
return

def pduCntrlOid(self):
Expand All @@ -77,6 +80,11 @@ def pduCntrlOid(self):
SENTRY4_PORT_STATUS_BASE_OID = "1.3.6.1.4.1.1718.4.1.8.3.1.1"
SENTRY4_PORT_CONTROL_BASE_OID = "1.3.6.1.4.1.1718.4.1.8.5.1.2"
SENTRY4_PORT_POWER_BASE_OID = "1.3.6.1.4.1.1718.4.1.8.3.1.9"
# MIB OID for 'Vertiv Geist Upgradeable PDU'
VERTIV_PORT_NAME_BASE_OID = "1.3.6.1.4.1.21239.5.2.3.5.1.3"
VERTIV_PORT_STATUS_BASE_OID = "1.3.6.1.4.1.21239.5.2.3.5.1.4"
VERTIV_PORT_CONTROL_BASE_OID = "1.3.6.1.4.1.21239.5.2.3.5.1.6"
VERTIV_PORT_POWER_BASE_OID = "1.3.6.1.4.1.21239.5.2.3.6.1.12"
self.STATUS_ON = "1"
self.STATUS_OFF = "0"
self.CONTROL_ON = "1"
Expand Down Expand Up @@ -104,15 +112,23 @@ def pduCntrlOid(self):
self.PORT_POWER_BASE_OID = SENTRY4_PORT_POWER_BASE_OID
self.has_lanes = False
self.max_lanes = 1
elif self.pduType == "Vertiv":
self.PORT_NAME_BASE_OID = VERTIV_PORT_NAME_BASE_OID
self.PORT_STATUS_BASE_OID = VERTIV_PORT_STATUS_BASE_OID
self.PORT_CONTROL_BASE_OID = VERTIV_PORT_CONTROL_BASE_OID
self.PORT_POWER_BASE_OID = VERTIV_PORT_POWER_BASE_OID
self.STATUS_OFF = "2"
self.CONTROL_ON = "2"
self.CONTROL_OFF = "4"
self.has_lanes = False
self.max_lanes = 1
else:
pass


def _build_outlet_maps(self, port_oid, label):
self.port_oid_dict[port_oid] = { 'label' : label }
self.port_label_dict[label] = { 'port_oid' : port_oid }


def _probe_lane(self, lane_id, cmdGen, snmp_auth):
pdu_port_base = self.PORT_NAME_BASE_OID
query_oid = '.' + pdu_port_base
Expand All @@ -134,7 +150,6 @@ def _probe_lane(self, lane_id, cmdGen, snmp_auth):
label = val.prettyPrint().lower()
self._build_outlet_maps(port_oid, label)


def _get_pdu_ports(self):
"""
@summary: Helper method for getting PDU ports connected to PSUs of DUT
Expand All @@ -152,7 +167,6 @@ def _get_pdu_ports(self):
for lane_id in range(1, self.max_lanes + 1):
self._probe_lane(lane_id, cmdGen, snmp_auth)


def __init__(self, controller, pdu):
logging.info("Initializing " + self.__class__.__name__)
PduControllerBase.__init__(self)
Expand All @@ -167,7 +181,6 @@ def __init__(self, controller, pdu):
self._get_pdu_ports()
logging.info("Initialized " + self.__class__.__name__)


def turn_on_outlet(self, outlet):
"""
@summary: Use SNMP to turn on power to PDU of DUT specified by outlet
Expand Down Expand Up @@ -222,11 +235,10 @@ def turn_off_outlet(self, outlet):
(port_oid, rfc1902.Integer(self.CONTROL_OFF))
)
if errorIndication or errorStatus != 0:
logging.debug("Failed to turn on outlet %s, exception: %s" % (str(outlet), str(errorStatus)))
logging.debug("Failed to turn off outlet %s, exception: %s" % (str(outlet), str(errorStatus)))
return False
return True


def _get_one_outlet_power(self, cmdGen, snmp_auth, port_id, status):
if not self.PORT_POWER_BASE_OID:
return
Expand All @@ -248,7 +260,6 @@ def _get_one_outlet_power(self, cmdGen, snmp_auth, port_id, status):
status['output_watts'] = current_val
return


def _get_one_outlet_status(self, cmdGen, snmp_auth, port_id):
query_id = '.' + self.PORT_STATUS_BASE_OID + port_id
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
Expand All @@ -270,7 +281,6 @@ def _get_one_outlet_status(self, cmdGen, snmp_auth, port_id):

return None


def get_outlet_status(self, outlet=None, hostname=None):
"""
@summary: Use SNMP to get status of PDU ports supplying power to PSUs of DUT
Expand Down

0 comments on commit c41fff2

Please sign in to comment.