Merge "snmp inspection for disk size"
This commit is contained in:
@@ -152,3 +152,23 @@ class ImageExtractionFailed(ProliantUtilsException):
|
||||
message = self.message % kwargs
|
||||
|
||||
super(ImageExtractionFailed, self).__init__(message)
|
||||
|
||||
|
||||
class IloSNMPInvalidInputFailure(IloError):
|
||||
message = "Failed to do SNMP retreival %(reason)s"
|
||||
|
||||
def __init__(self, message=None, **kwargs):
|
||||
if not message:
|
||||
message = self.message % kwargs
|
||||
|
||||
super(IloSNMPInvalidInputFailure, self).__init__(message)
|
||||
|
||||
|
||||
class IloSNMPExceptionFailure(IloError):
|
||||
message = "SNMP library failed %(reason)s"
|
||||
|
||||
def __init__(self, message=None, **kwargs):
|
||||
if not message:
|
||||
message = self.message % kwargs
|
||||
|
||||
super(IloSNMPExceptionFailure, self).__init__(message)
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
# under the License.
|
||||
"""IloClient module"""
|
||||
|
||||
from proliantutils import exception
|
||||
from proliantutils.ilo import ipmi
|
||||
from proliantutils.ilo import operations
|
||||
from proliantutils.ilo import ribcl
|
||||
from proliantutils.ilo import ris
|
||||
from proliantutils.ilo.snmp import snmp_cpqdisk_sizes as snmp
|
||||
from proliantutils import log
|
||||
|
||||
SUPPORTED_RIS_METHODS = [
|
||||
@@ -60,7 +62,7 @@ LOG = log.get_logger(__name__)
|
||||
class IloClient(operations.IloOperations):
|
||||
|
||||
def __init__(self, host, login, password, timeout=60, port=443,
|
||||
bios_password=None, cacert=None):
|
||||
bios_password=None, cacert=None, snmp_credentials=None):
|
||||
self.ribcl = ribcl.RIBCLOperations(host, login, password, timeout,
|
||||
port, cacert=cacert)
|
||||
self.ris = ris.RISOperations(host, login, password,
|
||||
@@ -70,9 +72,63 @@ class IloClient(operations.IloOperations):
|
||||
self.host = host
|
||||
self.model = self.ribcl.get_product_name()
|
||||
self.ribcl.init_model_based_tags(self.model)
|
||||
self.snmp_credentials = snmp_credentials
|
||||
self._validate_snmp()
|
||||
LOG.debug(self._("IloClient object created. "
|
||||
"Model: %(model)s"), {'model': self.model})
|
||||
|
||||
def _validate_snmp(self):
|
||||
"""Validates SNMP credentials.
|
||||
|
||||
:raises exception.IloInvalidInputError
|
||||
"""
|
||||
cred = self.snmp_credentials
|
||||
if cred is not None:
|
||||
if cred.get('snmp_inspection') is True:
|
||||
if not all([cred.get('auth_user'),
|
||||
cred.get('auth_prot_pp'),
|
||||
cred.get('auth_priv_pp')]):
|
||||
msg = self._('Either few or all mandatory '
|
||||
'SNMP credentials '
|
||||
'are missing.')
|
||||
LOG.error(msg)
|
||||
raise exception.IloInvalidInputError(msg)
|
||||
try:
|
||||
auth_protocol = cred['auth_protocol']
|
||||
if auth_protocol not in ["SHA", "MD5"]:
|
||||
msg = self._('Invalid SNMP auth protocol '
|
||||
'provided. '
|
||||
'Valid values are SHA or MD5')
|
||||
LOG.error(msg)
|
||||
raise exception.IloInvalidInputError(msg)
|
||||
except KeyError:
|
||||
msg = self._('Auth protocol not provided by user. '
|
||||
'The default value of MD5 will '
|
||||
'be considered.')
|
||||
LOG.debug(msg)
|
||||
pass
|
||||
try:
|
||||
priv_protocol = cred['priv_protocol']
|
||||
if priv_protocol not in ["AES", "DES"]:
|
||||
msg = self._('Invalid SNMP privacy protocol '
|
||||
'provided. '
|
||||
'Valid values are AES or DES')
|
||||
LOG.error(msg)
|
||||
raise exception.IloInvalidInputError(msg)
|
||||
except KeyError:
|
||||
msg = self._('Privacy protocol not provided '
|
||||
'by user. '
|
||||
'The default value of DES will '
|
||||
'be considered.')
|
||||
LOG.debug(msg)
|
||||
pass
|
||||
else:
|
||||
LOG.debug(self._('snmp_inspection set to False. SNMP'
|
||||
'inspection will not be performed.'))
|
||||
else:
|
||||
LOG.debug(self._('SNMP credentials not provided. SNMP '
|
||||
'inspection will not be performed.'))
|
||||
|
||||
def _call_method(self, method_name, *args, **kwargs):
|
||||
"""Call the corresponding method using either RIBCL or RIS."""
|
||||
the_operation_object = self.ribcl
|
||||
@@ -359,7 +415,23 @@ class IloClient(operations.IloOperations):
|
||||
:raises: IloCommandNotSupportedError, if the command is not supported
|
||||
on the server.
|
||||
"""
|
||||
return self._call_method('get_essential_properties')
|
||||
data = self._call_method('get_essential_properties')
|
||||
if (data['properties']['local_gb'] == 0):
|
||||
cred = self.snmp_credentials
|
||||
if cred and cred.get('snmp_inspection'):
|
||||
disksize = snmp.get_local_gb(self.host, cred)
|
||||
if disksize:
|
||||
data['properties']['local_gb'] = disksize
|
||||
else:
|
||||
msg = self._('Snmp inspection failed to '
|
||||
'get the disk size')
|
||||
LOG.debug(msg)
|
||||
raise exception.IloError(msg)
|
||||
else:
|
||||
msg = self._("Inspection failed to get the disk size")
|
||||
LOG.debug(msg)
|
||||
raise exception.IloError(msg)
|
||||
return data
|
||||
|
||||
def get_server_capabilities(self):
|
||||
"""Get hardware properties which can be used for scheduling
|
||||
|
||||
0
proliantutils/ilo/snmp/__init__.py
Normal file
0
proliantutils/ilo/snmp/__init__.py
Normal file
184
proliantutils/ilo/snmp/cpqdisk_mibs/CPQHOST-MIB.py
Normal file
184
proliantutils/ilo/snmp/cpqdisk_mibs/CPQHOST-MIB.py
Normal file
File diff suppressed because one or more lines are too long
526
proliantutils/ilo/snmp/cpqdisk_mibs/CPQIDA-MIB.py
Normal file
526
proliantutils/ilo/snmp/cpqdisk_mibs/CPQIDA-MIB.py
Normal file
File diff suppressed because one or more lines are too long
365
proliantutils/ilo/snmp/cpqdisk_mibs/CPQSCSI-MIB.py
Normal file
365
proliantutils/ilo/snmp/cpqdisk_mibs/CPQSCSI-MIB.py
Normal file
File diff suppressed because one or more lines are too long
15
proliantutils/ilo/snmp/cpqdisk_mibs/IANAifType-MIB.py
Normal file
15
proliantutils/ilo/snmp/cpqdisk_mibs/IANAifType-MIB.py
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# PySNMP MIB module IANAifType-MIB (http://pysnmp.sf.net)
|
||||
#
|
||||
( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString")
|
||||
( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
|
||||
( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint")
|
||||
( NotificationGroup, ModuleCompliance, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
|
||||
( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, mib_2, IpAddress, TimeTicks, Counter64, Unsigned32, iso, Gauge32, ModuleIdentity, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "mib-2", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "iso", "Gauge32", "ModuleIdentity", "ObjectIdentity", "Bits", "Counter32")
|
||||
( DisplayString, TextualConvention, ) = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
|
||||
ianaifType = ModuleIdentity((1, 3, 6, 1, 2, 1, 30)).setRevisions(("2004-11-22 00:00", "2004-06-17 00:00", "2004-05-12 00:00", "2004-05-07 00:00", "2003-08-25 00:00", "2003-08-18 00:00", "2003-08-07 00:00", "2003-03-18 00:00", "2003-01-13 00:00", "2002-10-17 00:00", "2002-07-16 00:00", "2002-07-10 00:00", "2002-06-19 00:00", "2002-01-04 00:00", "2001-12-20 00:00", "2001-11-15 00:00", "2001-11-06 00:00", "2001-11-02 00:00", "2001-10-16 00:00", "2001-09-19 00:00", "2001-05-11 00:00", "2001-01-12 00:00", "2000-12-19 00:00", "2000-12-07 00:00", "2000-12-04 00:00", "2000-10-17 00:00", "2000-10-02 00:00", "2000-09-01 00:00", "2000-08-24 00:00", "2000-08-23 00:00", "2000-08-22 00:00", "2000-04-25 00:00", "2000-03-06 00:00", "1999-10-08 14:30", "1994-01-31 00:00",))
|
||||
class IANAifType(Integer32, TextualConvention):
|
||||
subtypeSpec = Integer32.subtypeSpec+SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,)
|
||||
namedValues = NamedValues(("other", 1), ("regular1822", 2), ("hdh1822", 3), ("ddnX25", 4), ("rfc877x25", 5), ("ethernetCsmacd", 6), ("iso88023Csmacd", 7), ("iso88024TokenBus", 8), ("iso88025TokenRing", 9), ("iso88026Man", 10), ("starLan", 11), ("proteon10Mbit", 12), ("proteon80Mbit", 13), ("hyperchannel", 14), ("fddi", 15), ("lapb", 16), ("sdlc", 17), ("ds1", 18), ("e1", 19), ("basicISDN", 20), ("primaryISDN", 21), ("propPointToPointSerial", 22), ("ppp", 23), ("softwareLoopback", 24), ("eon", 25), ("ethernet3Mbit", 26), ("nsip", 27), ("slip", 28), ("ultra", 29), ("ds3", 30), ("sip", 31), ("frameRelay", 32), ("rs232", 33), ("para", 34), ("arcnet", 35), ("arcnetPlus", 36), ("atm", 37), ("miox25", 38), ("sonet", 39), ("x25ple", 40), ("iso88022llc", 41), ("localTalk", 42), ("smdsDxi", 43), ("frameRelayService", 44), ("v35", 45), ("hssi", 46), ("hippi", 47), ("modem", 48), ("aal5", 49), ("sonetPath", 50), ("sonetVT", 51), ("smdsIcip", 52), ("propVirtual", 53), ("propMultiplexor", 54), ("ieee80212", 55), ("fibreChannel", 56), ("hippiInterface", 57), ("frameRelayInterconnect", 58), ("aflane8023", 59), ("aflane8025", 60), ("cctEmul", 61), ("fastEther", 62), ("isdn", 63), ("v11", 64), ("v36", 65), ("g703at64k", 66), ("g703at2mb", 67), ("qllc", 68), ("fastEtherFX", 69), ("channel", 70), ("ieee80211", 71), ("ibm370parChan", 72), ("escon", 73), ("dlsw", 74), ("isdns", 75), ("isdnu", 76), ("lapd", 77), ("ipSwitch", 78), ("rsrb", 79), ("atmLogical", 80), ("ds0", 81), ("ds0Bundle", 82), ("bsc", 83), ("async", 84), ("cnr", 85), ("iso88025Dtr", 86), ("eplrs", 87), ("arap", 88), ("propCnls", 89), ("hostPad", 90), ("termPad", 91), ("frameRelayMPI", 92), ("x213", 93), ("adsl", 94), ("radsl", 95), ("sdsl", 96), ("vdsl", 97), ("iso88025CRFPInt", 98), ("myrinet", 99), ("voiceEM", 100), ("voiceFXO", 101), ("voiceFXS", 102), ("voiceEncap", 103), ("voiceOverIp", 104), ("atmDxi", 105), ("atmFuni", 106), ("atmIma", 107), ("pppMultilinkBundle", 108), ("ipOverCdlc", 109), ("ipOverClaw", 110), ("stackToStack", 111), ("virtualIpAddress", 112), ("mpc", 113), ("ipOverAtm", 114), ("iso88025Fiber", 115), ("tdlc", 116), ("gigabitEthernet", 117), ("hdlc", 118), ("lapf", 119), ("v37", 120), ("x25mlp", 121), ("x25huntGroup", 122), ("trasnpHdlc", 123), ("interleave", 124), ("fast", 125), ("ip", 126), ("docsCableMaclayer", 127), ("docsCableDownstream", 128), ("docsCableUpstream", 129), ("a12MppSwitch", 130), ("tunnel", 131), ("coffee", 132), ("ces", 133), ("atmSubInterface", 134), ("l2vlan", 135), ("l3ipvlan", 136), ("l3ipxvlan", 137), ("digitalPowerline", 138), ("mediaMailOverIp", 139), ("dtm", 140), ("dcn", 141), ("ipForward", 142), ("msdsl", 143), ("ieee1394", 144), ("if-gsn", 145), ("dvbRccMacLayer", 146), ("dvbRccDownstream", 147), ("dvbRccUpstream", 148), ("atmVirtual", 149), ("mplsTunnel", 150), ("srp", 151), ("voiceOverAtm", 152), ("voiceOverFrameRelay", 153), ("idsl", 154), ("compositeLink", 155), ("ss7SigLink", 156), ("propWirelessP2P", 157), ("frForward", 158), ("rfc1483", 159), ("usb", 160), ("ieee8023adLag", 161), ("bgppolicyaccounting", 162), ("frf16MfrBundle", 163), ("h323Gatekeeper", 164), ("h323Proxy", 165), ("mpls", 166), ("mfSigLink", 167), ("hdsl2", 168), ("shdsl", 169), ("ds1FDL", 170), ("pos", 171), ("dvbAsiIn", 172), ("dvbAsiOut", 173), ("plc", 174), ("nfas", 175), ("tr008", 176), ("gr303RDT", 177), ("gr303IDT", 178), ("isup", 179), ("propDocsWirelessMaclayer", 180), ("propDocsWirelessDownstream", 181), ("propDocsWirelessUpstream", 182), ("hiperlan2", 183), ("propBWAp2Mp", 184), ("sonetOverheadChannel", 185), ("digitalWrapperOverheadChannel", 186), ("aal2", 187), ("radioMAC", 188), ("atmRadio", 189), ("imt", 190), ("mvl", 191), ("reachDSL", 192), ("frDlciEndPt", 193), ("atmVciEndPt", 194), ("opticalChannel", 195), ("opticalTransport", 196), ("propAtm", 197), ("voiceOverCable", 198), ("infiniband", 199), ("teLink", 200), ("q2931", 201), ("virtualTg", 202), ("sipTg", 203), ("sipSig", 204), ("docsCableUpstreamChannel", 205), ("econet", 206), ("pon155", 207), ("pon622", 208), ("bridge", 209), ("linegroup", 210), ("voiceEMFGD", 211), ("voiceFGDEANA", 212), ("voiceDID", 213), ("mpegTransport", 214), ("sixToFour", 215), ("gtp", 216), ("pdnEtherLoop1", 217), ("pdnEtherLoop2", 218), ("opticalChannelGroup", 219), ("homepna", 220), ("gfp", 221), ("ciscoISLvlan", 222), ("actelisMetaLOOP", 223), ("fcipLink", 224), ("rpr", 225), ("qam", 226), ("lmp", 227),)
|
||||
|
||||
mibBuilder.exportSymbols("IANAifType-MIB", IANAifType=IANAifType, PYSNMP_MODULE_ID=ianaifType, ianaifType=ianaifType)
|
||||
119
proliantutils/ilo/snmp/cpqdisk_mibs/IF-MIB.py
Normal file
119
proliantutils/ilo/snmp/cpqdisk_mibs/IF-MIB.py
Normal file
@@ -0,0 +1,119 @@
|
||||
#
|
||||
# PySNMP MIB module IF-MIB (http://pysnmp.sf.net)
|
||||
#
|
||||
( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString")
|
||||
( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
|
||||
( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint")
|
||||
( IANAifType, ) = mibBuilder.importSymbols("IANAifType-MIB", "IANAifType")
|
||||
( NotificationGroup, ModuleCompliance, ObjectGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup")
|
||||
( snmpTraps, ) = mibBuilder.importSymbols("SNMPv2-MIB", "snmpTraps")
|
||||
( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, mib_2, IpAddress, TimeTicks, Counter64, Unsigned32, ModuleIdentity, Gauge32, iso, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "mib-2", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "ModuleIdentity", "Gauge32", "iso", "ObjectIdentity", "Bits", "Counter32")
|
||||
( TextualConvention, AutonomousType, TruthValue, TimeStamp, TestAndIncr, RowStatus, DisplayString, PhysAddress, ) = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "AutonomousType", "TruthValue", "TimeStamp", "TestAndIncr", "RowStatus", "DisplayString", "PhysAddress")
|
||||
ifMIB = ModuleIdentity((1, 3, 6, 1, 2, 1, 31)).setRevisions(("2000-06-14 00:00", "1996-02-28 21:55", "1993-11-08 21:55",))
|
||||
ifMIBObjects = MibIdentifier((1, 3, 6, 1, 2, 1, 31, 1))
|
||||
interfaces = MibIdentifier((1, 3, 6, 1, 2, 1, 2))
|
||||
class OwnerString(OctetString, TextualConvention):
|
||||
displayHint = '255a'
|
||||
subtypeSpec = OctetString.subtypeSpec+ValueSizeConstraint(0,255)
|
||||
|
||||
class InterfaceIndex(Integer32, TextualConvention):
|
||||
displayHint = 'd'
|
||||
subtypeSpec = Integer32.subtypeSpec+ValueRangeConstraint(1,2147483647)
|
||||
|
||||
class InterfaceIndexOrZero(Integer32, TextualConvention):
|
||||
displayHint = 'd'
|
||||
subtypeSpec = Integer32.subtypeSpec+ValueRangeConstraint(0,2147483647)
|
||||
|
||||
ifNumber = MibScalar((1, 3, 6, 1, 2, 1, 2, 1), Integer32()).setMaxAccess("readonly")
|
||||
ifTableLastChange = MibScalar((1, 3, 6, 1, 2, 1, 31, 1, 5), TimeTicks()).setMaxAccess("readonly")
|
||||
ifTable = MibTable((1, 3, 6, 1, 2, 1, 2, 2), )
|
||||
ifEntry = MibTableRow((1, 3, 6, 1, 2, 1, 2, 2, 1), ).setIndexNames((0, "IF-MIB", "ifIndex"))
|
||||
ifIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 1), InterfaceIndex()).setMaxAccess("readonly")
|
||||
ifDescr = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0,255))).setMaxAccess("readonly")
|
||||
ifType = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 3), IANAifType()).setMaxAccess("readonly")
|
||||
ifMtu = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 4), Integer32()).setMaxAccess("readonly")
|
||||
ifSpeed = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 5), Gauge32()).setMaxAccess("readonly")
|
||||
ifPhysAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 6), PhysAddress()).setMaxAccess("readonly")
|
||||
ifAdminStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 7), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2, 3,)).clone(namedValues=NamedValues(("up", 1), ("down", 2), ("testing", 3),))).setMaxAccess("readwrite")
|
||||
ifOperStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 8), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2, 3, 4, 5, 6, 7,)).clone(namedValues=NamedValues(("up", 1), ("down", 2), ("testing", 3), ("unknown", 4), ("dormant", 5), ("notPresent", 6), ("lowerLayerDown", 7),))).setMaxAccess("readonly")
|
||||
ifLastChange = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 9), TimeTicks()).setMaxAccess("readonly")
|
||||
ifInOctets = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 10), Counter32()).setMaxAccess("readonly")
|
||||
ifInUcastPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 11), Counter32()).setMaxAccess("readonly")
|
||||
ifInNUcastPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 12), Counter32()).setMaxAccess("readonly")
|
||||
ifInDiscards = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 13), Counter32()).setMaxAccess("readonly")
|
||||
ifInErrors = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 14), Counter32()).setMaxAccess("readonly")
|
||||
ifInUnknownProtos = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 15), Counter32()).setMaxAccess("readonly")
|
||||
ifOutOctets = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 16), Counter32()).setMaxAccess("readonly")
|
||||
ifOutUcastPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 17), Counter32()).setMaxAccess("readonly")
|
||||
ifOutNUcastPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 18), Counter32()).setMaxAccess("readonly")
|
||||
ifOutDiscards = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 19), Counter32()).setMaxAccess("readonly")
|
||||
ifOutErrors = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 20), Counter32()).setMaxAccess("readonly")
|
||||
ifOutQLen = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 21), Gauge32()).setMaxAccess("readonly")
|
||||
ifSpecific = MibTableColumn((1, 3, 6, 1, 2, 1, 2, 2, 1, 22), ObjectIdentifier()).setMaxAccess("readonly")
|
||||
ifXTable = MibTable((1, 3, 6, 1, 2, 1, 31, 1, 1), )
|
||||
ifXEntry = MibTableRow((1, 3, 6, 1, 2, 1, 31, 1, 1, 1), )
|
||||
ifEntry.registerAugmentions(("IF-MIB", "ifXEntry"))
|
||||
ifXEntry.setIndexNames(*ifEntry.getIndexNames())
|
||||
ifName = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 1), DisplayString()).setMaxAccess("readonly")
|
||||
ifInMulticastPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 2), Counter32()).setMaxAccess("readonly")
|
||||
ifInBroadcastPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 3), Counter32()).setMaxAccess("readonly")
|
||||
ifOutMulticastPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 4), Counter32()).setMaxAccess("readonly")
|
||||
ifOutBroadcastPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 5), Counter32()).setMaxAccess("readonly")
|
||||
ifHCInOctets = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 6), Counter64()).setMaxAccess("readonly")
|
||||
ifHCInUcastPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 7), Counter64()).setMaxAccess("readonly")
|
||||
ifHCInMulticastPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 8), Counter64()).setMaxAccess("readonly")
|
||||
ifHCInBroadcastPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 9), Counter64()).setMaxAccess("readonly")
|
||||
ifHCOutOctets = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 10), Counter64()).setMaxAccess("readonly")
|
||||
ifHCOutUcastPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 11), Counter64()).setMaxAccess("readonly")
|
||||
ifHCOutMulticastPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 12), Counter64()).setMaxAccess("readonly")
|
||||
ifHCOutBroadcastPkts = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 13), Counter64()).setMaxAccess("readonly")
|
||||
ifLinkUpDownTrapEnable = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 14), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2,)).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2),))).setMaxAccess("readwrite")
|
||||
ifHighSpeed = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 15), Gauge32()).setMaxAccess("readonly")
|
||||
ifPromiscuousMode = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 16), TruthValue()).setMaxAccess("readwrite")
|
||||
ifConnectorPresent = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 17), TruthValue()).setMaxAccess("readonly")
|
||||
ifAlias = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 18), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0,64))).setMaxAccess("readwrite")
|
||||
ifCounterDiscontinuityTime = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 19), TimeStamp()).setMaxAccess("readonly")
|
||||
ifStackTable = MibTable((1, 3, 6, 1, 2, 1, 31, 1, 2), )
|
||||
ifStackEntry = MibTableRow((1, 3, 6, 1, 2, 1, 31, 1, 2, 1), ).setIndexNames((0, "IF-MIB", "ifStackHigherLayer"), (0, "IF-MIB", "ifStackLowerLayer"))
|
||||
ifStackHigherLayer = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 2, 1, 1), InterfaceIndexOrZero())
|
||||
ifStackLowerLayer = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 2, 1, 2), InterfaceIndexOrZero())
|
||||
ifStackStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 2, 1, 3), RowStatus()).setMaxAccess("readcreate")
|
||||
ifStackLastChange = MibScalar((1, 3, 6, 1, 2, 1, 31, 1, 6), TimeTicks()).setMaxAccess("readonly")
|
||||
ifRcvAddressTable = MibTable((1, 3, 6, 1, 2, 1, 31, 1, 4), )
|
||||
ifRcvAddressEntry = MibTableRow((1, 3, 6, 1, 2, 1, 31, 1, 4, 1), ).setIndexNames((0, "IF-MIB", "ifIndex"), (0, "IF-MIB", "ifRcvAddressAddress"))
|
||||
ifRcvAddressAddress = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 4, 1, 1), PhysAddress())
|
||||
ifRcvAddressStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 4, 1, 2), RowStatus()).setMaxAccess("readcreate")
|
||||
ifRcvAddressType = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 4, 1, 3), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2, 3,)).clone(namedValues=NamedValues(("other", 1), ("volatile", 2), ("nonVolatile", 3),)).clone('volatile')).setMaxAccess("readcreate")
|
||||
linkDown = NotificationType((1, 3, 6, 1, 6, 3, 1, 1, 5, 3)).setObjects(*(("IF-MIB", "ifIndex"), ("IF-MIB", "ifAdminStatus"), ("IF-MIB", "ifOperStatus"),))
|
||||
linkUp = NotificationType((1, 3, 6, 1, 6, 3, 1, 1, 5, 4)).setObjects(*(("IF-MIB", "ifIndex"), ("IF-MIB", "ifAdminStatus"), ("IF-MIB", "ifOperStatus"),))
|
||||
ifConformance = MibIdentifier((1, 3, 6, 1, 2, 1, 31, 2))
|
||||
ifGroups = MibIdentifier((1, 3, 6, 1, 2, 1, 31, 2, 1))
|
||||
ifCompliances = MibIdentifier((1, 3, 6, 1, 2, 1, 31, 2, 2))
|
||||
ifCompliance3 = ModuleCompliance((1, 3, 6, 1, 2, 1, 31, 2, 2, 3)).setObjects(*(("IF-MIB", "ifGeneralInformationGroup"), ("IF-MIB", "linkUpDownNotificationsGroup"), ("IF-MIB", "ifFixedLengthGroup"), ("IF-MIB", "ifHCFixedLengthGroup"), ("IF-MIB", "ifPacketGroup"), ("IF-MIB", "ifHCPacketGroup"), ("IF-MIB", "ifVHCPacketGroup"), ("IF-MIB", "ifCounterDiscontinuityGroup"), ("IF-MIB", "ifRcvAddressGroup"),))
|
||||
ifGeneralInformationGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 31, 2, 1, 10)).setObjects(*(("IF-MIB", "ifIndex"), ("IF-MIB", "ifDescr"), ("IF-MIB", "ifType"), ("IF-MIB", "ifSpeed"), ("IF-MIB", "ifPhysAddress"), ("IF-MIB", "ifAdminStatus"), ("IF-MIB", "ifOperStatus"), ("IF-MIB", "ifLastChange"), ("IF-MIB", "ifLinkUpDownTrapEnable"), ("IF-MIB", "ifConnectorPresent"), ("IF-MIB", "ifHighSpeed"), ("IF-MIB", "ifName"), ("IF-MIB", "ifNumber"), ("IF-MIB", "ifAlias"), ("IF-MIB", "ifTableLastChange"),))
|
||||
ifFixedLengthGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 31, 2, 1, 2)).setObjects(*(("IF-MIB", "ifInOctets"), ("IF-MIB", "ifOutOctets"), ("IF-MIB", "ifInUnknownProtos"), ("IF-MIB", "ifInErrors"), ("IF-MIB", "ifOutErrors"),))
|
||||
ifHCFixedLengthGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 31, 2, 1, 3)).setObjects(*(("IF-MIB", "ifHCInOctets"), ("IF-MIB", "ifHCOutOctets"), ("IF-MIB", "ifInOctets"), ("IF-MIB", "ifOutOctets"), ("IF-MIB", "ifInUnknownProtos"), ("IF-MIB", "ifInErrors"), ("IF-MIB", "ifOutErrors"),))
|
||||
ifPacketGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 31, 2, 1, 4)).setObjects(*(("IF-MIB", "ifInOctets"), ("IF-MIB", "ifOutOctets"), ("IF-MIB", "ifInUnknownProtos"), ("IF-MIB", "ifInErrors"), ("IF-MIB", "ifOutErrors"), ("IF-MIB", "ifMtu"), ("IF-MIB", "ifInUcastPkts"), ("IF-MIB", "ifInMulticastPkts"), ("IF-MIB", "ifInBroadcastPkts"), ("IF-MIB", "ifInDiscards"), ("IF-MIB", "ifOutUcastPkts"), ("IF-MIB", "ifOutMulticastPkts"), ("IF-MIB", "ifOutBroadcastPkts"), ("IF-MIB", "ifOutDiscards"), ("IF-MIB", "ifPromiscuousMode"),))
|
||||
ifHCPacketGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 31, 2, 1, 5)).setObjects(*(("IF-MIB", "ifHCInOctets"), ("IF-MIB", "ifHCOutOctets"), ("IF-MIB", "ifInOctets"), ("IF-MIB", "ifOutOctets"), ("IF-MIB", "ifInUnknownProtos"), ("IF-MIB", "ifInErrors"), ("IF-MIB", "ifOutErrors"), ("IF-MIB", "ifMtu"), ("IF-MIB", "ifInUcastPkts"), ("IF-MIB", "ifInMulticastPkts"), ("IF-MIB", "ifInBroadcastPkts"), ("IF-MIB", "ifInDiscards"), ("IF-MIB", "ifOutUcastPkts"), ("IF-MIB", "ifOutMulticastPkts"), ("IF-MIB", "ifOutBroadcastPkts"), ("IF-MIB", "ifOutDiscards"), ("IF-MIB", "ifPromiscuousMode"),))
|
||||
ifVHCPacketGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 31, 2, 1, 6)).setObjects(*(("IF-MIB", "ifHCInUcastPkts"), ("IF-MIB", "ifHCInMulticastPkts"), ("IF-MIB", "ifHCInBroadcastPkts"), ("IF-MIB", "ifHCOutUcastPkts"), ("IF-MIB", "ifHCOutMulticastPkts"), ("IF-MIB", "ifHCOutBroadcastPkts"), ("IF-MIB", "ifHCInOctets"), ("IF-MIB", "ifHCOutOctets"), ("IF-MIB", "ifInOctets"), ("IF-MIB", "ifOutOctets"), ("IF-MIB", "ifInUnknownProtos"), ("IF-MIB", "ifInErrors"), ("IF-MIB", "ifOutErrors"), ("IF-MIB", "ifMtu"), ("IF-MIB", "ifInUcastPkts"), ("IF-MIB", "ifInMulticastPkts"), ("IF-MIB", "ifInBroadcastPkts"), ("IF-MIB", "ifInDiscards"), ("IF-MIB", "ifOutUcastPkts"), ("IF-MIB", "ifOutMulticastPkts"), ("IF-MIB", "ifOutBroadcastPkts"), ("IF-MIB", "ifOutDiscards"), ("IF-MIB", "ifPromiscuousMode"),))
|
||||
ifRcvAddressGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 31, 2, 1, 7)).setObjects(*(("IF-MIB", "ifRcvAddressStatus"), ("IF-MIB", "ifRcvAddressType"),))
|
||||
ifStackGroup2 = ObjectGroup((1, 3, 6, 1, 2, 1, 31, 2, 1, 11)).setObjects(*(("IF-MIB", "ifStackStatus"), ("IF-MIB", "ifStackLastChange"),))
|
||||
ifCounterDiscontinuityGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 31, 2, 1, 13)).setObjects(*(("IF-MIB", "ifCounterDiscontinuityTime"),))
|
||||
linkUpDownNotificationsGroup = NotificationGroup((1, 3, 6, 1, 2, 1, 31, 2, 1, 14)).setObjects(*(("IF-MIB", "linkUp"), ("IF-MIB", "linkDown"),))
|
||||
ifTestTable = MibTable((1, 3, 6, 1, 2, 1, 31, 1, 3), )
|
||||
ifTestEntry = MibTableRow((1, 3, 6, 1, 2, 1, 31, 1, 3, 1), )
|
||||
ifEntry.registerAugmentions(("IF-MIB", "ifTestEntry"))
|
||||
ifTestEntry.setIndexNames(*ifEntry.getIndexNames())
|
||||
ifTestId = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 3, 1, 1), TestAndIncr()).setMaxAccess("readwrite")
|
||||
ifTestStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 3, 1, 2), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2,)).clone(namedValues=NamedValues(("notInUse", 1), ("inUse", 2),))).setMaxAccess("readwrite")
|
||||
ifTestType = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 3, 1, 3), AutonomousType()).setMaxAccess("readwrite")
|
||||
ifTestResult = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 3, 1, 4), Integer32().subtype(subtypeSpec=SingleValueConstraint(1, 2, 3, 4, 5, 6, 7,)).clone(namedValues=NamedValues(("none", 1), ("success", 2), ("inProgress", 3), ("notSupported", 4), ("unAbleToRun", 5), ("aborted", 6), ("failed", 7),))).setMaxAccess("readonly")
|
||||
ifTestCode = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 3, 1, 5), ObjectIdentifier()).setMaxAccess("readonly")
|
||||
ifTestOwner = MibTableColumn((1, 3, 6, 1, 2, 1, 31, 1, 3, 1, 6), OwnerString()).setMaxAccess("readwrite")
|
||||
ifGeneralGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 31, 2, 1, 1)).setObjects(*(("IF-MIB", "ifDescr"), ("IF-MIB", "ifType"), ("IF-MIB", "ifSpeed"), ("IF-MIB", "ifPhysAddress"), ("IF-MIB", "ifAdminStatus"), ("IF-MIB", "ifOperStatus"), ("IF-MIB", "ifLastChange"), ("IF-MIB", "ifLinkUpDownTrapEnable"), ("IF-MIB", "ifConnectorPresent"), ("IF-MIB", "ifHighSpeed"), ("IF-MIB", "ifName"),))
|
||||
ifTestGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 31, 2, 1, 8)).setObjects(*(("IF-MIB", "ifTestId"), ("IF-MIB", "ifTestStatus"), ("IF-MIB", "ifTestType"), ("IF-MIB", "ifTestResult"), ("IF-MIB", "ifTestCode"), ("IF-MIB", "ifTestOwner"),))
|
||||
ifStackGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 31, 2, 1, 9)).setObjects(*(("IF-MIB", "ifStackStatus"),))
|
||||
ifOldObjectsGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 31, 2, 1, 12)).setObjects(*(("IF-MIB", "ifInNUcastPkts"), ("IF-MIB", "ifOutNUcastPkts"), ("IF-MIB", "ifOutQLen"), ("IF-MIB", "ifSpecific"),))
|
||||
ifCompliance = ModuleCompliance((1, 3, 6, 1, 2, 1, 31, 2, 2, 1)).setObjects(*(("IF-MIB", "ifGeneralGroup"), ("IF-MIB", "ifStackGroup"), ("IF-MIB", "ifFixedLengthGroup"), ("IF-MIB", "ifHCFixedLengthGroup"), ("IF-MIB", "ifPacketGroup"), ("IF-MIB", "ifHCPacketGroup"), ("IF-MIB", "ifTestGroup"), ("IF-MIB", "ifRcvAddressGroup"),))
|
||||
ifCompliance2 = ModuleCompliance((1, 3, 6, 1, 2, 1, 31, 2, 2, 2)).setObjects(*(("IF-MIB", "ifGeneralInformationGroup"), ("IF-MIB", "ifStackGroup2"), ("IF-MIB", "ifCounterDiscontinuityGroup"), ("IF-MIB", "ifFixedLengthGroup"), ("IF-MIB", "ifHCFixedLengthGroup"), ("IF-MIB", "ifPacketGroup"), ("IF-MIB", "ifHCPacketGroup"), ("IF-MIB", "ifRcvAddressGroup"),))
|
||||
mibBuilder.exportSymbols("IF-MIB", ifRcvAddressTable=ifRcvAddressTable, PYSNMP_MODULE_ID=ifMIB, ifVHCPacketGroup=ifVHCPacketGroup, ifGeneralInformationGroup=ifGeneralInformationGroup, ifHCOutBroadcastPkts=ifHCOutBroadcastPkts, ifOutNUcastPkts=ifOutNUcastPkts, ifInBroadcastPkts=ifInBroadcastPkts, ifStackLastChange=ifStackLastChange, ifHighSpeed=ifHighSpeed, ifRcvAddressAddress=ifRcvAddressAddress, ifOperStatus=ifOperStatus, ifCompliance=ifCompliance, ifRcvAddressEntry=ifRcvAddressEntry, ifStackGroup2=ifStackGroup2, ifStackEntry=ifStackEntry, ifOutQLen=ifOutQLen, ifXEntry=ifXEntry, ifStackTable=ifStackTable, ifType=ifType, ifMIBObjects=ifMIBObjects, ifInMulticastPkts=ifInMulticastPkts, ifNumber=ifNumber, ifHCInUcastPkts=ifHCInUcastPkts, ifFixedLengthGroup=ifFixedLengthGroup, ifHCInBroadcastPkts=ifHCInBroadcastPkts, ifOldObjectsGroup=ifOldObjectsGroup, ifGeneralGroup=ifGeneralGroup, ifStackHigherLayer=ifStackHigherLayer, ifStackStatus=ifStackStatus, ifAdminStatus=ifAdminStatus, ifOutMulticastPkts=ifOutMulticastPkts, ifSpeed=ifSpeed, ifInUnknownProtos=ifInUnknownProtos, interfaces=interfaces, ifPacketGroup=ifPacketGroup, ifXTable=ifXTable, ifHCInMulticastPkts=ifHCInMulticastPkts, ifLinkUpDownTrapEnable=ifLinkUpDownTrapEnable, ifTable=ifTable, ifInUcastPkts=ifInUcastPkts, OwnerString=OwnerString, ifConformance=ifConformance, ifPhysAddress=ifPhysAddress, ifInDiscards=ifInDiscards, ifTestType=ifTestType, ifHCOutUcastPkts=ifHCOutUcastPkts, ifCompliances=ifCompliances, ifTestEntry=ifTestEntry, ifGroups=ifGroups, ifTestCode=ifTestCode, ifOutErrors=ifOutErrors, ifTestId=ifTestId, ifHCPacketGroup=ifHCPacketGroup, ifOutUcastPkts=ifOutUcastPkts, linkUpDownNotificationsGroup=linkUpDownNotificationsGroup, ifStackGroup=ifStackGroup, InterfaceIndexOrZero=InterfaceIndexOrZero, ifInNUcastPkts=ifInNUcastPkts, ifLastChange=ifLastChange, ifTestStatus=ifTestStatus, ifEntry=ifEntry, ifTestOwner=ifTestOwner, ifTestResult=ifTestResult, ifHCOutMulticastPkts=ifHCOutMulticastPkts, ifName=ifName, ifRcvAddressStatus=ifRcvAddressStatus, ifTestGroup=ifTestGroup, ifHCFixedLengthGroup=ifHCFixedLengthGroup, ifIndex=ifIndex, ifOutOctets=ifOutOctets, ifCounterDiscontinuityGroup=ifCounterDiscontinuityGroup, ifAlias=ifAlias, ifMtu=ifMtu, ifStackLowerLayer=ifStackLowerLayer, ifConnectorPresent=ifConnectorPresent, ifRcvAddressGroup=ifRcvAddressGroup, ifHCInOctets=ifHCInOctets, ifDescr=ifDescr, ifRcvAddressType=ifRcvAddressType, ifOutDiscards=ifOutDiscards, ifInOctets=ifInOctets, InterfaceIndex=InterfaceIndex, ifOutBroadcastPkts=ifOutBroadcastPkts, linkDown=linkDown, ifPromiscuousMode=ifPromiscuousMode, ifMIB=ifMIB, ifHCOutOctets=ifHCOutOctets, ifCompliance2=ifCompliance2, ifCompliance3=ifCompliance3, ifSpecific=ifSpecific, ifTestTable=ifTestTable, ifTableLastChange=ifTableLastChange, ifCounterDiscontinuityTime=ifCounterDiscontinuityTime, linkUp=linkUp, ifInErrors=ifInErrors)
|
||||
19
proliantutils/ilo/snmp/cpqdisk_mibs/RFC1215-MIB.py
Normal file
19
proliantutils/ilo/snmp/cpqdisk_mibs/RFC1215-MIB.py
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# PySNMP MIB module RFC1215-MIB (http://pysnmp.sf.net)
|
||||
#
|
||||
( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString")
|
||||
( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
|
||||
( ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint")
|
||||
( ifIndex, ) = mibBuilder.importSymbols("IF-MIB", "ifIndex")
|
||||
( egpNeighAddr, ) = mibBuilder.importSymbols("RFC1213-MIB", "egpNeighAddr")
|
||||
( NotificationGroup, ModuleCompliance, ) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
|
||||
( Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, mib_2, IpAddress, TimeTicks, Counter64, Unsigned32, iso, Gauge32, ModuleIdentity, ObjectIdentity, Bits, Counter32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "mib-2", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "iso", "Gauge32", "ModuleIdentity", "ObjectIdentity", "Bits", "Counter32")
|
||||
( DisplayString, TextualConvention, ) = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
|
||||
snmp = MibIdentifier((1, 3, 6, 1, 2, 1, 11))
|
||||
coldStart = NotificationType((1, 3, 6, 1, 2, 1, 11) + (0,0)).setObjects(*())
|
||||
warmStart = NotificationType((1, 3, 6, 1, 2, 1, 11) + (0,1)).setObjects(*())
|
||||
linkDown = NotificationType((1, 3, 6, 1, 2, 1, 11) + (0,2)).setObjects(*(("RFC1215-MIB", "ifIndex"),))
|
||||
linkUp = NotificationType((1, 3, 6, 1, 2, 1, 11) + (0,3)).setObjects(*(("RFC1215-MIB", "ifIndex"),))
|
||||
authenticationFailure = NotificationType((1, 3, 6, 1, 2, 1, 11) + (0,4)).setObjects(*())
|
||||
egpNeighborLoss = NotificationType((1, 3, 6, 1, 2, 1, 11) + (0,5)).setObjects(*(("RFC1215-MIB", "egpNeighAddr"),))
|
||||
mibBuilder.exportSymbols("RFC1215-MIB", linkDown=linkDown, authenticationFailure=authenticationFailure, warmStart=warmStart, egpNeighborLoss=egpNeighborLoss, snmp=snmp, linkUp=linkUp, coldStart=coldStart)
|
||||
222
proliantutils/ilo/snmp/snmp_cpqdisk_sizes.py
Executable file
222
proliantutils/ilo/snmp/snmp_cpqdisk_sizes.py
Executable file
@@ -0,0 +1,222 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
__author__ = 'HPE'
|
||||
|
||||
import os
|
||||
|
||||
from pysnmp import hlapi
|
||||
from pysnmp.smi import builder
|
||||
from pysnmp.smi import view
|
||||
|
||||
from proliantutils import exception
|
||||
from proliantutils import log
|
||||
|
||||
LOG = log.get_logger(__name__)
|
||||
|
||||
cpq_mibs_path = os.path.dirname(os.path.abspath(__file__))
|
||||
cpq_mibs_path = os.path.join(cpq_mibs_path, "cpqdisk_mibs")
|
||||
mBuilder = builder.MibBuilder()
|
||||
mBuilder.addMibSources(builder.DirMibSource(cpq_mibs_path))
|
||||
mibBuilder = mBuilder.loadModules('CPQIDA-MIB', 'CPQSCSI-MIB')
|
||||
mibViewController = view.MibViewController(mibBuilder)
|
||||
|
||||
# A dictionary of supported mapped snmp attributes
|
||||
MAPPED_SNMP_ATTRIBUTES = {
|
||||
'authProtocol': {
|
||||
'SHA': hlapi.usmHMACSHAAuthProtocol,
|
||||
'MD5': hlapi.usmHMACMD5AuthProtocol,
|
||||
},
|
||||
'privProtocol': {
|
||||
'AES': hlapi.usmAesCfb128Protocol,
|
||||
'DES': hlapi.usmDESPrivProtocol,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def _create_usm_user_obj(snmp_cred):
|
||||
"""Creates the UsmUserData obj for the given credentials.
|
||||
|
||||
This method creates an instance for the method hlapi.UsmUserData.
|
||||
The UsmUserData() allows the 'auth_protocol' and 'priv_protocol'
|
||||
to be undefined by user if their pass phrases are provided.
|
||||
|
||||
:param snmp_cred: Dictionary of SNMP credentials.
|
||||
auth_user: SNMP user
|
||||
auth_protocol: Auth Protocol
|
||||
auth_prot_pp: Pass phrase value for AuthProtocol.
|
||||
priv_protocol:Privacy Protocol.
|
||||
auth_priv_pp: Pass phrase value for Privacy Protocol.
|
||||
:returns UsmUserData object as per given credentials.
|
||||
"""
|
||||
auth_protocol = snmp_cred.get('auth_protocol')
|
||||
priv_protocol = snmp_cred.get('priv_protocol')
|
||||
auth_user = snmp_cred.get('auth_user')
|
||||
auth_prot_pp = snmp_cred.get('auth_prot_pp')
|
||||
auth_priv_pp = snmp_cred.get('auth_priv_pp')
|
||||
|
||||
if ((not auth_protocol) and priv_protocol):
|
||||
priv_protocol = (
|
||||
MAPPED_SNMP_ATTRIBUTES['privProtocol'][priv_protocol])
|
||||
usm_user_obj = hlapi.UsmUserData(auth_user, auth_prot_pp,
|
||||
auth_priv_pp,
|
||||
privProtocol=priv_protocol)
|
||||
elif ((not priv_protocol) and auth_protocol):
|
||||
auth_protocol = (
|
||||
MAPPED_SNMP_ATTRIBUTES['authProtocol'][auth_protocol])
|
||||
usm_user_obj = hlapi.UsmUserData(auth_user, auth_prot_pp,
|
||||
auth_priv_pp,
|
||||
authProtocol=auth_protocol)
|
||||
elif not all([priv_protocol and auth_protocol]):
|
||||
usm_user_obj = hlapi.UsmUserData(auth_user, auth_prot_pp,
|
||||
auth_priv_pp)
|
||||
else:
|
||||
auth_protocol = (
|
||||
MAPPED_SNMP_ATTRIBUTES['authProtocol'][auth_protocol])
|
||||
priv_protocol = (
|
||||
MAPPED_SNMP_ATTRIBUTES['privProtocol'][priv_protocol])
|
||||
usm_user_obj = hlapi.UsmUserData(auth_user, auth_prot_pp,
|
||||
auth_priv_pp,
|
||||
authProtocol=auth_protocol,
|
||||
privProtocol=priv_protocol)
|
||||
return usm_user_obj
|
||||
|
||||
|
||||
def _parse_mibs(iLOIP, snmp_credentials):
|
||||
"""Parses the MIBs.
|
||||
|
||||
:param iLOIP: IP address of the server on which SNMP discovery
|
||||
has to be executed.
|
||||
:param snmp_credentials: a Dictionary of SNMP credentials.
|
||||
auth_user: SNMP user
|
||||
auth_protocol: Auth Protocol
|
||||
auth_prot_pp: Pass phrase value for AuthProtocol.
|
||||
priv_protocol:Privacy Protocol.
|
||||
auth_priv_pp: Pass phrase value for Privacy Protocol.
|
||||
:returns the dictionary of parsed MIBs.
|
||||
:raises exception.InvalidInputError if pysnmp is unable to get
|
||||
SNMP data due to wrong inputs provided.
|
||||
:raises exception.IloError if pysnmp raises any exception.
|
||||
"""
|
||||
result = {}
|
||||
usm_user_obj = _create_usm_user_obj(snmp_credentials)
|
||||
try:
|
||||
for(errorIndication,
|
||||
errorStatus,
|
||||
errorIndex,
|
||||
varBinds) in hlapi.nextCmd(
|
||||
hlapi.SnmpEngine(),
|
||||
usm_user_obj,
|
||||
hlapi.UdpTransportTarget((iLOIP, 161), timeout=3, retries=3),
|
||||
hlapi.ContextData(),
|
||||
# cpqida cpqDaPhyDrvTable Drive Array Physical Drive Table
|
||||
hlapi.ObjectType(
|
||||
hlapi.ObjectIdentity('1.3.6.1.4.1.232.3.2.5.1')),
|
||||
# cpqscsi SCSI Physical Drive Table
|
||||
hlapi.ObjectType(
|
||||
hlapi.ObjectIdentity('1.3.6.1.4.1.232.5.2.4.1')),
|
||||
# cpqscsi SAS Physical Drive Table
|
||||
hlapi.ObjectType(
|
||||
hlapi.ObjectIdentity('1.3.6.1.4.1.232.5.5.2.1')),
|
||||
lexicographicMode=False,
|
||||
ignoreNonIncreasingOid=True):
|
||||
|
||||
if errorIndication:
|
||||
LOG.error(errorIndication)
|
||||
msg = "SNMP failed to traverse MIBs %s", errorIndication
|
||||
raise exception.IloSNMPInvalidInputFailure(msg)
|
||||
else:
|
||||
if errorStatus:
|
||||
msg = ('Parsing MIBs failed. %s at %s' % (
|
||||
errorStatus.prettyPrint(),
|
||||
errorIndex and varBinds[-1][int(errorIndex)-1]
|
||||
or '?'
|
||||
)
|
||||
)
|
||||
LOG.error(msg)
|
||||
raise exception.IloSNMPInvalidInputFailure(msg)
|
||||
else:
|
||||
for varBindTableRow in varBinds:
|
||||
name, val = tuple(varBindTableRow)
|
||||
oid, label, suffix = (
|
||||
mibViewController.getNodeName(name))
|
||||
key = name.prettyPrint()
|
||||
# Don't traverse outside the tables we requested
|
||||
if not (key.find("SNMPv2-SMI::enterprises.232.3") >= 0
|
||||
or (key.find(
|
||||
"SNMPv2-SMI::enterprises.232.5") >= 0)):
|
||||
break
|
||||
if key not in result:
|
||||
result[key] = {}
|
||||
result[key][label[-1]] = {}
|
||||
result[key][label[-1]][suffix] = val
|
||||
except Exception as e:
|
||||
msg = "SNMP library failed with error %s", e
|
||||
LOG.error(msg)
|
||||
raise exception.IloSNMPExceptionFailure(msg)
|
||||
return result
|
||||
|
||||
|
||||
def _get_disksize_MiB(iLOIP, cred):
|
||||
"""Reads the dictionary of parsed MIBs and gets the disk size.
|
||||
|
||||
:param iLOIP: IP address of the server on which SNMP discovery
|
||||
has to be executed.
|
||||
:param snmp_credentials in a dictionary having following mandatory
|
||||
keys.
|
||||
auth_user: SNMP user
|
||||
auth_protocol: Auth Protocol
|
||||
auth_prot_pp: Pass phrase value for AuthProtocol.
|
||||
priv_protocol:Privacy Protocol.
|
||||
auth_priv_pp: Pass phrase value for Privacy Protocol.
|
||||
|
||||
:returns the dictionary of disk sizes of all physical drives.
|
||||
"""
|
||||
# '1.3.6.1.4.1.232.5.5.1.1', # cpqscsi SAS HBA Table
|
||||
# '1.3.6.1.4.1.232.3.2.3.1', # cpqida Drive Array Logical Drive Table
|
||||
result = _parse_mibs(iLOIP, cred)
|
||||
disksize = {}
|
||||
for uuid in sorted(result):
|
||||
for key in result[uuid]:
|
||||
# We only track the Physical Disk Size
|
||||
if key.find('PhyDrvSize') >= 0:
|
||||
disksize[uuid] = dict()
|
||||
for suffix in sorted(result[uuid][key]):
|
||||
size = result[uuid][key][suffix]
|
||||
disksize[uuid][key] = str(size)
|
||||
return disksize
|
||||
|
||||
|
||||
def get_local_gb(iLOIP, snmp_credentials):
|
||||
"""Gets the maximum disk size among all disks.
|
||||
|
||||
:param iLOIP: IP address of the server on which SNMP discovery
|
||||
has to be executed.
|
||||
:param snmp_credentials in a dictionary having following mandatory
|
||||
keys.
|
||||
auth_user: SNMP user
|
||||
auth_protocol: Auth Protocol
|
||||
auth_prot_pp: Pass phrase value for AuthProtocol.
|
||||
priv_protocol:Privacy Protocol.
|
||||
auth_priv_pp: Pass phrase value for Privacy Protocol.
|
||||
"""
|
||||
disk_sizes = _get_disksize_MiB(iLOIP, snmp_credentials)
|
||||
max_size = 0
|
||||
for uuid in disk_sizes:
|
||||
for key in disk_sizes[uuid]:
|
||||
if int(disk_sizes[uuid][key]) > max_size:
|
||||
max_size = int(disk_sizes[uuid][key])
|
||||
max_size_gb = max_size/1024
|
||||
return max_size_gb
|
||||
0
proliantutils/tests/ilo/snmp/__init__.py
Normal file
0
proliantutils/tests/ilo/snmp/__init__.py
Normal file
51
proliantutils/tests/ilo/snmp/snmp_sample_output.py
Normal file
51
proliantutils/tests/ilo/snmp/snmp_sample_output.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/python
|
||||
# Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
def Integer(value):
|
||||
return value
|
||||
|
||||
|
||||
def ObjectName(value):
|
||||
return (value,)
|
||||
|
||||
|
||||
PHY_DRIVE_MIB_OUTPUT = {
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.1.2.0': {
|
||||
'cpqDaPhyDrvCntlrIndex': {ObjectName('2.0'): Integer(2)}},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.1.2.1': {
|
||||
'cpqDaPhyDrvCntlrIndex': {ObjectName('2.1'): Integer(2)}},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.1.2.2': {
|
||||
'cpqDaPhyDrvCntlrIndex': {ObjectName('2.2'): Integer(2)}},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.1.2.3': {
|
||||
'cpqDaPhyDrvCntlrIndex': {ObjectName('2.3'): Integer(2)}},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.2.2.0': {
|
||||
'cpqDaPhyDrvIndex': {ObjectName('2.0'): Integer(0)}},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.2.2.1': {
|
||||
'cpqDaPhyDrvIndex': {ObjectName('2.1'): Integer(1)}},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.2.2.2': {
|
||||
'cpqDaPhyDrvIndex': {ObjectName('2.2'): Integer(2)}},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.2.2.3': {
|
||||
'cpqDaPhyDrvIndex': {ObjectName('2.3'): Integer(3)}},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.45.2.0': {
|
||||
'cpqDaPhyDrvSize': {ObjectName('2.0'): Integer(286102)}},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.45.2.1': {
|
||||
'cpqDaPhyDrvSize': {ObjectName('2.1'): Integer(286102)}},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.45.2.2': {
|
||||
'cpqDaPhyDrvSize': {ObjectName('2.2'): Integer(286102)}},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.45.2.3': {
|
||||
'cpqDaPhyDrvSize': {ObjectName('2.3'): Integer(286102)}}
|
||||
}
|
||||
70
proliantutils/tests/ilo/snmp/test_snmp_cpqdisk_sizes.py
Normal file
70
proliantutils/tests/ilo/snmp/test_snmp_cpqdisk_sizes.py
Normal file
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
|
||||
from proliantutils.ilo.snmp import snmp_cpqdisk_sizes as snmp
|
||||
from proliantutils.tests.ilo.snmp import snmp_sample_output
|
||||
|
||||
|
||||
class SnmpTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(SnmpTestCase, self).setUp()
|
||||
|
||||
@mock.patch.object(snmp, '_get_disksize_MiB')
|
||||
def test_get_local_gb(self, get_disk_mock):
|
||||
iLOIp = 'a.b.c.d'
|
||||
snmp_credentials = {'auth_user': 'user',
|
||||
'auth_prot_pp': '1234',
|
||||
'auth_priv_pp': '4321',
|
||||
'auth_protocol': 'SHA',
|
||||
'priv_protocol': 'AES',
|
||||
'snmp_inspection': 'true'}
|
||||
disk_snmp_data = {'SNMPv2-SMI::enterprises.232.3.2.5.1.1.45.2.0':
|
||||
{'cpqDaPhyDrvSize': '286102'},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.45.2.1':
|
||||
{'cpqDaPhyDrvSize': '286102'},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.45.2.2':
|
||||
{'cpqDaPhyDrvSize': '572316'},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.45.2.3':
|
||||
{'cpqDaPhyDrvSize': '286102'}}
|
||||
get_disk_mock.return_value = disk_snmp_data
|
||||
actual_size = snmp.get_local_gb(iLOIp, snmp_credentials)
|
||||
expected_size = (572316/1024)
|
||||
self.assertEqual(actual_size, expected_size)
|
||||
get_disk_mock.assert_called_once_with(iLOIp, snmp_credentials)
|
||||
|
||||
@mock.patch.object(snmp, '_parse_mibs')
|
||||
def test__get_disksize_MiB(self, mib_mock):
|
||||
iLOIP = 'a.b.c.d'
|
||||
snmp_credentials = {'auth_user': 'user',
|
||||
'auth_prot_pp': '1234',
|
||||
'auth_priv_pp': '4321',
|
||||
'auth_protocol': 'SHA',
|
||||
'priv_protocol': 'AES',
|
||||
'snmp_inspection': 'true'}
|
||||
mib_mock.return_value = snmp_sample_output.PHY_DRIVE_MIB_OUTPUT
|
||||
actual = snmp._get_disksize_MiB(iLOIP, snmp_credentials)
|
||||
expected = {'SNMPv2-SMI::enterprises.232.3.2.5.1.1.45.2.0':
|
||||
{'cpqDaPhyDrvSize': '286102'},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.45.2.1':
|
||||
{'cpqDaPhyDrvSize': '286102'},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.45.2.2':
|
||||
{'cpqDaPhyDrvSize': '286102'},
|
||||
'SNMPv2-SMI::enterprises.232.3.2.5.1.1.45.2.3':
|
||||
{'cpqDaPhyDrvSize': '286102'}}
|
||||
self.assertEqual(expected, actual)
|
||||
@@ -17,10 +17,12 @@
|
||||
import mock
|
||||
import testtools
|
||||
|
||||
from proliantutils import exception
|
||||
from proliantutils.ilo import client
|
||||
from proliantutils.ilo import ipmi
|
||||
from proliantutils.ilo import ribcl
|
||||
from proliantutils.ilo import ris
|
||||
from proliantutils.ilo.snmp import snmp_cpqdisk_sizes
|
||||
|
||||
|
||||
class IloClientInitTestCase(testtools.TestCase):
|
||||
@@ -47,6 +49,124 @@ class IloClientInitTestCase(testtools.TestCase):
|
||||
c.info)
|
||||
self.assertEqual('product', c.model)
|
||||
|
||||
@mock.patch.object(client.IloClient, '_validate_snmp')
|
||||
@mock.patch.object(ribcl, 'RIBCLOperations')
|
||||
@mock.patch.object(ris, 'RISOperations')
|
||||
def test_init_snmp(self, ris_mock, ribcl_mock, snmp_mock):
|
||||
ribcl_obj_mock = mock.MagicMock()
|
||||
ribcl_mock.return_value = ribcl_obj_mock
|
||||
ribcl_obj_mock.get_product_name.return_value = 'product'
|
||||
snmp_credentials = {'auth_user': 'user',
|
||||
'auth_protocol': 'SHA',
|
||||
'auth_prot_pp': '1234',
|
||||
'priv_protocol': 'AES',
|
||||
'auth_priv_pp': '4321',
|
||||
'snmp_inspection': 'true'}
|
||||
c = client.IloClient("1.2.3.4", "admin", "Admin",
|
||||
timeout=120, port=4430,
|
||||
bios_password='foo',
|
||||
cacert='/somewhere',
|
||||
snmp_credentials=snmp_credentials)
|
||||
|
||||
ris_mock.assert_called_once_with(
|
||||
"1.2.3.4", "admin", "Admin", bios_password='foo',
|
||||
cacert='/somewhere')
|
||||
ribcl_mock.assert_called_once_with(
|
||||
"1.2.3.4", "admin", "Admin", 120, 4430, cacert='/somewhere')
|
||||
self.assertEqual(
|
||||
{'address': "1.2.3.4", 'username': "admin", 'password': "Admin"},
|
||||
c.info)
|
||||
self.assertEqual('product', c.model)
|
||||
self.assertTrue(snmp_mock.called)
|
||||
|
||||
@mock.patch.object(client.IloClient, '_validate_snmp')
|
||||
@mock.patch.object(ribcl, 'RIBCLOperations')
|
||||
@mock.patch.object(ris, 'RISOperations')
|
||||
def test_init_snmp_raises(self, ris_mock, ribcl_mock, snmp_mock):
|
||||
ribcl_obj_mock = mock.MagicMock()
|
||||
ribcl_mock.return_value = ribcl_obj_mock
|
||||
ribcl_obj_mock.get_product_name.return_value = 'product'
|
||||
snmp_mock.side_effect = exception.IloInvalidInputError("msg")
|
||||
snmp_credentials = {'auth_user': 'user',
|
||||
'auth_protocol': 'SHA',
|
||||
'priv_protocol': 'AES',
|
||||
'snmp_inspection': 'true'}
|
||||
self.assertRaises(exception.IloInvalidInputError, client.IloClient,
|
||||
"1.2.3.4", "admin", "Admin",
|
||||
timeout=120, port=4430,
|
||||
bios_password='foo',
|
||||
cacert='/somewhere',
|
||||
snmp_credentials=snmp_credentials)
|
||||
|
||||
ris_mock.assert_called_once_with(
|
||||
"1.2.3.4", "admin", "Admin", bios_password='foo',
|
||||
cacert='/somewhere')
|
||||
ribcl_mock.assert_called_once_with(
|
||||
"1.2.3.4", "admin", "Admin", 120, 4430, cacert='/somewhere')
|
||||
self.assertTrue(snmp_mock.called)
|
||||
|
||||
|
||||
class IloClientSNMPValidateTestCase(testtools.TestCase):
|
||||
|
||||
@mock.patch.object(ribcl.RIBCLOperations, 'get_product_name')
|
||||
def test_validate_snmp(self, product_mock):
|
||||
cred = {'auth_user': 'user',
|
||||
'auth_protocol': 'SHA',
|
||||
'priv_protocol': 'AES',
|
||||
'auth_prot_pp': '1234',
|
||||
'auth_priv_pp': '4321',
|
||||
'snmp_inspection': True}
|
||||
self.snmp_credentials = cred
|
||||
self.client = client.IloClient("1.2.3.4", "admin", "Admin",
|
||||
snmp_credentials=cred)
|
||||
self.assertEqual(self.client.snmp_credentials, cred)
|
||||
|
||||
@mock.patch.object(ribcl.RIBCLOperations, 'get_product_name')
|
||||
def test_validate_snmp_fail_auth_priv_pp_missing(self, product_mock):
|
||||
cred = {'auth_user': 'user',
|
||||
'auth_protocol': 'SHA',
|
||||
'priv_protocol': 'AES',
|
||||
'auth_prot_pp': '1234',
|
||||
'snmp_inspection': True}
|
||||
self.assertRaises(exception.IloInvalidInputError,
|
||||
client.IloClient,
|
||||
"1.2.3.4", "admin", "Admin",
|
||||
snmp_credentials=cred)
|
||||
|
||||
@mock.patch.object(ribcl.RIBCLOperations, 'get_product_name')
|
||||
def test_validate_snmp_auth_prot_pp_missing(self, product_mock):
|
||||
cred = {'auth_user': 'user',
|
||||
'auth_protocol': 'SHA',
|
||||
'priv_protocol': 'AES',
|
||||
'auth_priv_pp': '4321',
|
||||
'snmp_inspection': True}
|
||||
self.assertRaises(exception.IloInvalidInputError,
|
||||
client.IloClient,
|
||||
"1.2.3.4", "admin", "Admin",
|
||||
snmp_credentials=cred)
|
||||
|
||||
@mock.patch.object(ribcl.RIBCLOperations, 'get_product_name')
|
||||
def test_validate_snmp_auth_prot_priv_prot_missing(self, product_mock):
|
||||
cred = {'auth_user': 'user',
|
||||
'auth_prot_pp': '1234',
|
||||
'auth_priv_pp': '4321',
|
||||
'snmp_inspection': True}
|
||||
self.client = client.IloClient("1.2.3.4", "admin", "Admin",
|
||||
snmp_credentials=cred)
|
||||
self.assertEqual(self.client.snmp_credentials, cred)
|
||||
|
||||
@mock.patch.object(ribcl.RIBCLOperations, 'get_product_name')
|
||||
def test_validate_snmp_auth_user_missing(self, product_mock):
|
||||
cred = {'auth_protocol': 'SHA',
|
||||
'priv_protocol': 'AES',
|
||||
'auth_priv_pp': '4321',
|
||||
'auth_prot_pp': '1234',
|
||||
'snmp_inspection': True}
|
||||
self.assertRaises(exception.IloInvalidInputError,
|
||||
client.IloClient,
|
||||
"1.2.3.4", "admin", "Admin",
|
||||
snmp_credentials=cred)
|
||||
|
||||
|
||||
class IloClientTestCase(testtools.TestCase):
|
||||
|
||||
@@ -547,3 +667,97 @@ class IloClientTestCase(testtools.TestCase):
|
||||
self.client.model = 'Gen8'
|
||||
self.client.reset_server()
|
||||
self.assertTrue(reset_server_mock.called)
|
||||
|
||||
@mock.patch.object(client.IloClient, '_call_method')
|
||||
@mock.patch.object(snmp_cpqdisk_sizes, 'get_local_gb')
|
||||
def test_get_essential_prop_no_snmp_ris(self,
|
||||
snmp_mock,
|
||||
call_mock):
|
||||
self.client.model = 'Gen9'
|
||||
properties = {'local_gb': 250}
|
||||
data = {'properties': properties}
|
||||
call_mock.return_value = data
|
||||
self.client.get_essential_properties()
|
||||
call_mock.assert_called_once_with('get_essential_properties')
|
||||
self.assertFalse(snmp_mock.called)
|
||||
|
||||
@mock.patch.object(client.IloClient, '_call_method')
|
||||
@mock.patch.object(snmp_cpqdisk_sizes, 'get_local_gb')
|
||||
def test_get_essential_prop_no_snmp_raises(self,
|
||||
snmp_mock,
|
||||
call_mock):
|
||||
self.client.model = 'Gen9'
|
||||
properties = {'local_gb': 0}
|
||||
data = {'properties': properties}
|
||||
call_mock.return_value = data
|
||||
self.assertRaises(exception.IloError,
|
||||
self.client.get_essential_properties)
|
||||
call_mock.assert_called_once_with('get_essential_properties')
|
||||
self.assertFalse(snmp_mock.called)
|
||||
|
||||
@mock.patch.object(client.IloClient, '_call_method')
|
||||
@mock.patch.object(snmp_cpqdisk_sizes, 'get_local_gb')
|
||||
def test_get_essential_prop_snmp_true(self,
|
||||
snmp_mock,
|
||||
call_mock):
|
||||
self.client.model = 'Gen9'
|
||||
snmp_credentials = {'auth_user': 'user',
|
||||
'auth_prot_pp': '1234',
|
||||
'auth_priv_pp': '4321',
|
||||
'auth_protocol': 'SHA',
|
||||
'priv_protocol': 'AES',
|
||||
'snmp_inspection': 'true'}
|
||||
self.client.snmp_credentials = snmp_credentials
|
||||
properties = {'local_gb': 0}
|
||||
data = {'properties': properties}
|
||||
call_mock.return_value = data
|
||||
snmp_mock.return_value = 250
|
||||
self.client.get_essential_properties()
|
||||
call_mock.assert_called_once_with('get_essential_properties')
|
||||
snmp_mock.assert_called_once_with(self.client.info['address'],
|
||||
snmp_credentials)
|
||||
|
||||
@mock.patch.object(client.IloClient, '_call_method')
|
||||
@mock.patch.object(snmp_cpqdisk_sizes, 'get_local_gb')
|
||||
def test_get_essential_prop_snmp_true_raises(self,
|
||||
snmp_mock,
|
||||
call_mock):
|
||||
self.client.model = 'Gen9'
|
||||
snmp_credentials = {'auth_user': 'user',
|
||||
'auth_prot_pp': '1234',
|
||||
'auth_priv_pp': '4321',
|
||||
'auth_protocol': 'SHA',
|
||||
'priv_protocol': 'AES',
|
||||
'snmp_inspection': 'true'}
|
||||
self.client.snmp_credentials = snmp_credentials
|
||||
properties = {'local_gb': 0}
|
||||
data = {'properties': properties}
|
||||
call_mock.return_value = data
|
||||
snmp_mock.return_value = 0
|
||||
self.assertRaises(exception.IloError,
|
||||
self.client.get_essential_properties)
|
||||
call_mock.assert_called_once_with('get_essential_properties')
|
||||
snmp_mock.assert_called_once_with(self.client.info['address'],
|
||||
snmp_credentials)
|
||||
|
||||
@mock.patch.object(snmp_cpqdisk_sizes, 'get_local_gb')
|
||||
@mock.patch.object(client.IloClient, '_call_method')
|
||||
def test_get_essential_prop_snmp_false_raises(self, call_mock,
|
||||
snmp_mock):
|
||||
|
||||
self.client.model = 'Gen9'
|
||||
snmp_credentials = {'auth_user': 'user',
|
||||
'auth_prot_pp': '1234',
|
||||
'auth_priv_pp': '4321',
|
||||
'auth_protocol': 'SHA',
|
||||
'priv_protocol': 'AES',
|
||||
'snmp_inspection': False}
|
||||
self.client.snmp_inspection = False
|
||||
self.client.snmp_credentials = snmp_credentials
|
||||
properties = {'local_gb': 0}
|
||||
data = {'properties': properties}
|
||||
call_mock.return_value = data
|
||||
self.assertRaises(exception.IloError,
|
||||
self.client.get_essential_properties)
|
||||
call_mock.assert_called_once_with('get_essential_properties')
|
||||
self.assertFalse(snmp_mock.called)
|
||||
|
||||
@@ -3,3 +3,4 @@ oslo.concurrency>=1.8.0
|
||||
oslo.utils>=1.4.0
|
||||
jsonschema>=2.4.0
|
||||
requests>=2.7.0
|
||||
pysnmp>=4.3.2
|
||||
|
||||
Reference in New Issue
Block a user