Add BayTech MRP27 snmp driver type

Change-Id: I07feec6d1ddeffeb4d2abbe2081f3ca824f169e1
This commit is contained in:
Ilya Etingof 2018-06-26 13:28:18 +02:00
parent c45d3c1399
commit ba0a7828f9
4 changed files with 51 additions and 1 deletions

View File

@ -53,6 +53,7 @@ Aten all? Yes aten
CyberPower all? Untested cyberpower CyberPower all? Untested cyberpower
EatonPower all? Untested eatonpower EatonPower all? Untested eatonpower
Teltronix all? Yes teltronix Teltronix all? Yes teltronix
BayTech MRP27 Yes baytech_mrp27
============== ========== ========== ===================== ============== ========== ========== =====================

View File

@ -695,6 +695,21 @@ class SNMPDriverEatonPower(SNMPDriverBase):
self.client.set(oid, value) self.client.set(oid, value)
class SNMPDriverBaytechMRP27(SNMPDriverSimple):
"""SNMP driver class for Baytech MRP27 PDU devices.
SNMP objects for Baytech MRP27 PDU:
4779, 1, 3, 5, 3, 1, 3, {unit_id} Outlet Power
Values: 0=Off, 1=On, 2=Reboot
"""
# TODO(srobert): Add support for dynamically allocated unit_id when needed
unit_id = 1
oid_device = (4779, 1, 3, 5, 3, 1, 3) + (unit_id,)
value_power_off = 0
value_power_on = 1
class SNMPDriverAuto(SNMPDriverBase): class SNMPDriverAuto(SNMPDriverBase):
SYS_OBJ_OID = (1, 3, 6, 1, 2, 1, 1, 2) SYS_OBJ_OID = (1, 3, 6, 1, 2, 1, 1, 2)
@ -765,7 +780,8 @@ DRIVER_CLASSES = {
'cyberpower': SNMPDriverCyberPower, 'cyberpower': SNMPDriverCyberPower,
'eatonpower': SNMPDriverEatonPower, 'eatonpower': SNMPDriverEatonPower,
'teltronix': SNMPDriverTeltronix, 'teltronix': SNMPDriverTeltronix,
'auto': SNMPDriverAuto 'baytech_mrp27': SNMPDriverBaytechMRP27,
'auto': SNMPDriverAuto,
} }

View File

@ -1496,6 +1496,34 @@ class SNMPDeviceDriverTestCase(db_base.DbTestCase):
mock_client.get.assert_has_calls(calls) mock_client.get.assert_has_calls(calls)
self.assertEqual(states.POWER_ON, pstate) self.assertEqual(states.POWER_ON, pstate)
def test_baytech_mrp27_power_snmp_objects(self, mock_get_client):
# Ensure the correct SNMP object OIDs and values are used by the
# Baytech MRP 27 Power driver
self._update_driver_info(snmp_driver="baytech_mrp27", snmp_outlet="3")
driver = snmp._get_driver(self.node)
oid = (1, 3, 6, 1, 4, 1, 4779, 1, 3, 5, 3, 1, 3, 1, 3)
self.assertEqual(oid, driver._snmp_oid())
self.assertEqual(1, driver.value_power_on)
self.assertEqual(0, driver.value_power_off)
def test_baytech_mrp27_power_state_on(self, mock_get_client):
self._test_simple_device_power_state_on('baytech_mrp27',
mock_get_client)
def test_baytech_mrp27_power_state_off(self, mock_get_client):
self._test_simple_device_power_state_off('baytech_mrp27',
mock_get_client)
def test_baytech_mrp27_power_on(self, mock_get_client):
self._test_simple_device_power_on('baytech_mrp27', mock_get_client)
def test_baytech_mrp27_power_off(self, mock_get_client):
self._test_simple_device_power_off('baytech_mrp27', mock_get_client)
def test_baytech_mrp27_power_reset(self, mock_get_client):
self._test_simple_device_power_reset('baytech_mrp27', mock_get_client)
@mock.patch.object(snmp, '_get_driver', autospec=True) @mock.patch.object(snmp, '_get_driver', autospec=True)
class SNMPDriverTestCase(db_base.DbTestCase): class SNMPDriverTestCase(db_base.DbTestCase):

View File

@ -0,0 +1,5 @@
---
features:
- |
Adds new Power Distribution Unit (PDU) ``snmp`` driver type - BayTech
MRP27.