75
75
'snmp_outlet': _("PDU power outlet index (1-based). Required."),
77
77
OPTIONAL_PROPERTIES = {
78
'snmp_version': _("SNMP protocol version: %(v1)s, %(v2c)s, %(v3)s "
79
"(optional, default %(v1)s)")
80
% {"v1": SNMP_V1, "v2c": SNMP_V2C, "v3": SNMP_V3},
81
'snmp_port': _("SNMP port, default %(port)d") % {"port": SNMP_PORT},
82
'snmp_community': _("SNMP community. Required for versions %(v1)s, "
84
% {"v1": SNMP_V1, "v2c": SNMP_V2C},
85
'snmp_security': _("SNMP security name. Required for version %(v3)s")
79
_("SNMP protocol version: %(v1)s, %(v2c)s, %(v3)s "
80
"(optional, default %(v1)s)")
81
% {"v1": SNMP_V1, "v2c": SNMP_V2C, "v3": SNMP_V3},
83
_("SNMP port, default %(port)d") % {"port": SNMP_PORT},
85
_("SNMP community. Required for versions %(v1)s, %(v2c)s")
86
% {"v1": SNMP_V1, "v2c": SNMP_V2C},
88
_("SNMP security name. Required for version %(v3)s")
88
91
COMMON_PROPERTIES = REQUIRED_PROPERTIES.copy()
89
92
COMMON_PROPERTIES.update(OPTIONAL_PROPERTIES)
221
224
@abc.abstractmethod
222
225
def _snmp_power_state(self):
223
"""Perform the SNMP request required to retrieve the current power
226
"""Perform the SNMP request required to get the current power state.
226
228
:raises: SNMPFailure if an SNMP request fails.
227
229
:returns: power state. One of :class:`ironic.common.states`.
376
378
self.client.set(self.oid, value)
381
class SNMPDriverAten(SNMPDriverSimple):
382
"""SNMP driver class for Aten PDU devices.
384
SNMP objects for Aten PDU:
385
1.3.6.1.4.1.21317.1.3.2.2.2.2 Outlet Power
386
Values: 1=Off, 2=On, 3=Pending, 4=Reset
388
oid_device = (21317, 1, 3, 2, 2, 2, 2)
393
"""Return the OID of the power state object.
395
:returns: Power state object OID as a tuple of integers.
397
outlet = int(self.snmp_info['outlet'])
398
return self.oid_enterprise + self.oid_device + (outlet, 0,)
379
401
class SNMPDriverAPC(SNMPDriverSimple):
380
402
"""SNMP driver class for APC PDU devices.
501
523
# A dictionary of supported drivers keyed by snmp_driver attribute
502
524
DRIVER_CLASSES = {
503
525
'apc': SNMPDriverAPC,
526
'aten': SNMPDriverAten,
504
527
'cyberpower': SNMPDriverCyberPower,
505
528
'eatonpower': SNMPDriverEatonPower,
506
529
'teltronix': SNMPDriverTeltronix
510
533
def _parse_driver_info(node):
511
"""Return a dictionary of validated driver information, usable for
534
"""Parse a node's driver_info values.
536
Return a dictionary of validated driver information, usable for
512
537
SNMPDriver object creation.
514
539
:param node: An Ironic node object.
520
545
missing_info = [key for key in REQUIRED_PROPERTIES if not info.get(key)]
522
547
raise exception.MissingParameterValue(_(
523
"SNMP driver requires the following to be set: %s.")
548
"SNMP driver requires the following parameters to be set in "
549
"node's driver_info: %s.") % missing_info)