def collectMac(self): """ Collect MAC address information for each blade Returns: Two arrays. First array are mac addresses for eth0, second array for eth1. """ mac = [ {}, {} ] for interface in range(2): oid = 'BLADE-MIB::bladeMACAddress%dVpd' % (int(interface) + int(1)) # Start async snmpwalk. This call returns immediately # and spawns a background thread to perform the SNMPWalk snmpWalk = SNMPWalk.withConfigFile(self.host, oid) macDict = {} # While the snmpwalk is running while not snmpWalk.eof: # Get snmp oid/value pairs off the queue while not snmpWalk.queue.empty(): (oid, value) = snmpWalk.queue.get() (mibName, attr, lastOctet) = snmpWalk.extractOidParts(oid) mac[interface][lastOctet] = value snmpWalk.join() return mac
def collectFanPackInfo(self): oid = 'BLADE-MIB::fanPack' # Start async snmpwalk. This call returns immediately # and spawns a background thread to perform the SNMPWalk snmpWalk = SNMPWalk.withConfigFile(self.host, oid) # While the snmpwalk is running while not snmpWalk.eof: # Get snmp oid/value pairs off the queue while not snmpWalk.queue.empty(): (oid, value) = snmpWalk.queue.get() (mibName, attr, lastOctet) = snmpWalk.extractOidParts(oid) if attr != 'fanPackIndex': if hasattr(self, attr): attrValue = getattr(self, attr) attrValue.append(value) setattr(self, attr, attrValue) else: setattr(self, attr, [value]) snmpWalk.join()
def powerState(self): """ Get the power state for all slots """ walkAttr = 'remoteControlBladePowerState' oid = 'BLADE-MIB::%s' % walkAttr # Start async snmpwalk. This call returns immediately # and spawns a background thread to perform the SNMPWalk snmpWalk = SNMPWalk.withConfigFile(self.host, oid) state = [] # While the snmpwalk is running while not snmpWalk.eof: # Get snmp oid/value pairs off the queue while not snmpWalk.queue.empty(): (oid, value) = snmpWalk.queue.get() (mibName, attr, lastOctet) = snmpWalk.extractOidParts(oid) if attr == walkAttr: if value == 'on(1)': state.append(1) else: state.append(0) snmpWalk.join() Log.debug(100, 'ch %03d power state: %s' % (self.num, state)) return state
def collectMac(self): """ Collect MAC address information for each blade Returns: Two arrays. First array are mac addresses for eth0, second array for eth1. """ mac = [{}, {}] for interface in range(2): oid = 'BLADE-MIB::bladeMACAddress%dVpd' % (int(interface) + int(1)) # Start async snmpwalk. This call returns immediately # and spawns a background thread to perform the SNMPWalk snmpWalk = SNMPWalk.withConfigFile(self.host, oid) macDict = {} # While the snmpwalk is running while not snmpWalk.eof: # Get snmp oid/value pairs off the queue while not snmpWalk.queue.empty(): (oid, value) = snmpWalk.queue.get() (mibName, attr, lastOctet) = snmpWalk.extractOidParts(oid) mac[interface][lastOctet] = value snmpWalk.join() return mac
def collectAndClearEventLog(self, couch): log = {} # OIDs to retrieve oids = ['BLADE-MIB::readEnhancedEventLogAttribute', 'BLADE-MIB::readEnhancedEventLogMessage'] # Get the mapping of blade serial numbers to blade document ids serialNumberToDocId = Blade.serialNumberToDocId(couch) for oid in oids: # Start async snmpwalk. This call returns immediately # and spawns a background thread to perform the SNMPWalk snmpWalk = SNMPWalk.withConfigFile(self.host, oid) # While the snmpwalk is running while not snmpWalk.eof: # Get snmp oid/value pairs off the queue while not snmpWalk.queue.empty(): (oid, value) = snmpWalk.queue.get() (mibName, oidBase, lastOctet) = snmpWalk.extractOidParts(oid) if oidBase != 'readEnhancedEventLogNumber': # Start with an empty dictionary dict = {} # Get the existing log entry, if it exists if log.has_key(lastOctet): dict = log[lastOctet] # Update the dictionary with this line from the snmpwalk if oidBase == 'readEnhancedEventLogAttribute': dict.update(self.parseEventLogAttribute(value, serialNumberToDocId)) else: match = re.search('^Text:(.*)$', value) if match: value = match.group(1) dict.update({'message': value}) # Update the log entry list log[lastOctet] = dict # On the final snmp walk command, create CouchDB objects if dict and oidBase == 'readEnhancedEventLogMessage': logEntry = LogEntry(dict) logEntry.persist(couch) # Join snmpwalk background thread snmpWalk.join() snmp = SNMP.withConfigFile(self.host) snmp.set('BLADE-MIB::clearEventLog.0', 'i', '1') Log.info('%s system log entries collected from %s' % (len(log), self.name))
def collectAndClearEventLog(self, couch): log = {} # OIDs to retrieve oids = [ 'BLADE-MIB::readEnhancedEventLogAttribute', 'BLADE-MIB::readEnhancedEventLogMessage' ] # Get the mapping of blade serial numbers to blade document ids serialNumberToDocId = Blade.serialNumberToDocId(couch) for oid in oids: # Start async snmpwalk. This call returns immediately # and spawns a background thread to perform the SNMPWalk snmpWalk = SNMPWalk.withConfigFile(self.host, oid) # While the snmpwalk is running while not snmpWalk.eof: # Get snmp oid/value pairs off the queue while not snmpWalk.queue.empty(): (oid, value) = snmpWalk.queue.get() (mibName, oidBase, lastOctet) = snmpWalk.extractOidParts(oid) if oidBase != 'readEnhancedEventLogNumber': # Start with an empty dictionary dict = {} # Get the existing log entry, if it exists if log.has_key(lastOctet): dict = log[lastOctet] # Update the dictionary with this line from the snmpwalk if oidBase == 'readEnhancedEventLogAttribute': dict.update( self.parseEventLogAttribute( value, serialNumberToDocId)) else: match = re.search('^Text:(.*)$', value) if match: value = match.group(1) dict.update({'message': value}) # Update the log entry list log[lastOctet] = dict # On the final snmp walk command, create CouchDB objects if dict and oidBase == 'readEnhancedEventLogMessage': logEntry = LogEntry(dict) logEntry.persist(couch) # Join snmpwalk background thread snmpWalk.join() snmp = SNMP.withConfigFile(self.host) snmp.set('BLADE-MIB::clearEventLog.0', 'i', '1') Log.info('%s system log entries collected from %s' % (len(log), self.name))