def locate_bay(self, controller, enclosure, bay, state = 'on'): state_text = 'ON' if state != 'on' or state != 'ON': state_text = 'OFF' cmd = [sas2ircu_cmd, controller, 'LOCATE', '%s:%s' % (enclosure, bay), state_text] Command.run(cmd)
def locate_bay(self, controller, enclosure, bay, state='on'): state_text = 'ON' if state != 'on' or state != 'ON': state_text = 'OFF' cmd = [ sas2ircu_cmd, controller, 'LOCATE', '%s:%s' % (enclosure, bay), state_text ] Command.run(cmd)
def start_test(self, short = 1): '''Start a test of the drive Params: ------- short: int 1 = run short test, 0 = run long test. Short is the default ''' test = '--test=short' if short != 1: test = '--test=long' cmd = [smartctl_cmd, test, self.dev] Command.run(cmd)
def discoverNumCPUs(self): ''' Checks /proc/cpuinfo for the number of processors ''' (lines, exitcode) = Command.run(['/bin/cat', '/proc/cpuinfo']) regex = re.compile('^processor\s+:') return len(filter(regex.match, lines))
def discoverIncorrectBIOSSettings(cls, expectedFilename, dumpCmd): """ Discover incorrect BIOS settings Params ------ expectedFilename: string A filename of expected bios settings dumpCmd: array Command to dump bios settings Returns A dictionary of key value pairs of incorrect bios settings """ try: # Read expected bios settings expectedFile = Blade.openFile(expectedFilename) expected = Blade.parseBios(expectedFile) # Read actual bios settings (actualFile, exitcode) = Command.run(dumpCmd) actual = Blade.parseBios(actualFile) return Blade.compareBiosSettings(expected, actual) except (OSError, IOError) as e: Log.error(str(e)) sys.exit(1) return None
def discoverIncorrectBIOSSettings(cls, expectedFilename, dumpCmd): """ Discover incorrect BIOS settings Params ------ expectedFilename: string A filename of expected bios settings dumpCmd: array Command to dump bios settings Returns A dictionary of key value pairs of incorrect bios settings """ try: # Read expected bios settings expectedFile = Blade.openFile(expectedFilename) expected = Blade.parseBios(expectedFile) # Read actual bios settings (actualFile, exitcode) = Command.run(dumpCmd) actual = Blade.parseBios(actualFile) return Blade.compareBiosSettings(expected, actual) except (OSError, IOError) as e: Log.error(str(e)) sys.exit(1) return None
def discoverNumCPUs(self): ''' Checks /proc/cpuinfo for the number of processors ''' (lines, exitcode) = Command.run(['/bin/cat', '/proc/cpuinfo']) regex = re.compile('^processor\s+:') return len(filter(regex.match, lines))
def walk(self, oid): """ Perform an SNMP walk Params ----- oid : string The starting OID """ version = '-v1' if self.version == 2: version = '-v2' args = [ snmpwalk_cmd, '-t', '120', version, '-c', self.readCommunity, self.host, oid ] Log.debug(100, ' '.join(args)) (output, exitcode) = Command.run(args) values = None if exitcode == 0 and output: values = [] for line in output: line.rstrip('\n') if len(line) > 0: values.append(self.parseSNMPLine(line)) return values
def walk(self, oid): """ Perform an SNMP walk Params ----- oid : string The starting OID """ version = '-v1' if self.version == 2: version = '-v2' args = [snmpwalk_cmd, '-t', '120', version, '-c', self.readCommunity, self.host, oid] Log.debug(100, ' '.join(args)) (output, exitcode) = Command.run(args) values = None if exitcode == 0 and output: values = [] for line in output: line.rstrip('\n') if len(line) > 0: values.append(self.parseSNMPLine(line)) return values
def discoverMac0(self): ''' Returns the mac address of eth0 ''' (output, exitcode) = Command.run(['/sbin/ip', 'addr', 'show', 'eth0']) regex = re.compile('^\s+link\/ether') filteredLines = filter(regex.match, output) firstLineSplit = filteredLines[0].split() return firstLineSplit[1]
def discoverMemory(self): ''' Returns the amount of physical memory on this computer ''' (lines, exitcode) = Command.run(['free']) regex = re.compile('^Mem:\s+') memLine = filter(regex.match, lines) memLineParts = memLine[0].split() return memLineParts[1]
def discoverMemory(self): ''' Returns the amount of physical memory on this computer ''' (lines, exitcode) = Command.run(['free']) regex = re.compile('^Mem:\s+') memLine = filter(regex.match, lines) memLineParts = memLine[0].split() return memLineParts[1]
def discoverMac0(self): ''' Returns the mac address of eth0 ''' (output, exitcode) = Command.run(['/sbin/ip', 'addr', 'show', 'eth0']) regex = re.compile('^\s+link\/ether') filteredLines = filter(regex.match, output) firstLineSplit = filteredLines[0].split() return firstLineSplit[1]
def set(self, oid, oidType, value): """ Perform an SNMP set """ version = '-v1' if self.version == 2: version = '-v2' args = [snmpset_cmd, '-t', '120', version, '-c', self.writeCommunity, self.host, oid, oidType, value] return Command.run(args)
def ping(self): """ Returns ------- None if the chassis was not pingable """ (output, exitcode) = Command.run(["/bin/ping", "-c1", "-w100", self.host]) if exitcode == 0: return True return None
def ping(self): """ Returns ------- None if the chassis was not pingable """ (output, exitcode) = Command.run(["/bin/ping", "-c1", "-w100", self.host]) if exitcode == 0: return True return None
def set(self, oid, oidType, value): """ Perform an SNMP set """ version = '-v1' if self.version == 2: version = '-v2' args = [ snmpset_cmd, '-t', '120', version, '-c', self.writeCommunity, self.host, oid, oidType, value ] return Command.run(args)