Example #1
0
    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)
Example #2
0
    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)
Example #3
0
 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)
Example #4
0
    def get_info(self):
        smart_attrs = {
            '^\s*Model Family:\s+(.*)': 'model_family',
            '^\s*Device Model:\s+(.*)': 'device_model',
            '^\s*Serial Number:\s+(.*)': 'serial_number',
            '^\s*LU WWN Device Id:\s+(.*)': 'wwn',
            '^\s*Firmware Version:\s+(.*)': 'firmware_version',
            '^\s*User Capacity:\s+(.*)': 'user_capacity',
            '^\s*Sector Size:\s+(.*)': 'sector_size_b',
            '^\s*Device is:\s+(.*)': 'device_is',
            '^\s*ATA Version is:\s+(.*)': 'ata_version',
            '^\s*SATA Version is:\s+(.*)': 'sata_version',
            '^\s*Local Time is:\s+(.*)': 'local_time',
            '^\s*SMART support is: Available - device has SMART capability.\s*$': 'available',
            '^\s*SMART support is:\s+(.*)': 'smart_enabled',
            '^\s*SMART overall-health self-assessment test result:\s+(.*)': 'test',
        }

        cmd = [smartctl_cmd, '-a', self.dev]

        attrs = Command.run_and_extract_attrs(cmd, smart_attrs)

#        for (key, value) in attrs.iteritems():
#            if callable(value.strip):
#                attrs[key] = value.strip()

        return attrs
Example #5
0
    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
Example #6
0
    def get_info(self):
        hdparm_attrs = {
            '^\s*Serial Number:\s*(.*)\s*$': 'serial_number',
            '^\s*Firmware Revision:\s*(.*)\s*$': 'firmware',
            '^\s*Transport:\s*(.*)\s*$':     'transport',
            '^\s*NAA:\s*(.*)\s*$':           'naa',
            '^\s*IEEE OUI:\s*(.*)\s*$':      'ieee_oui',
            '^\s*Unique ID:\s*(.*)\s*$':     'unique_id',
            '^\s*Logical Unit WWN Device Identifier:\s*(.*)\s*$': 'wwn',
            '^\s*Model Number:\s+(.*)\s*$':  'model_number',
            '^\s*CHS current addressable sectors\s*:\s*(\d+)': 'chs_current_addressable_sectors',
            '^\s*LBA\s+user\s+addressable\s+sectors\s*:\s*(\d+)': 'lba_user_addressable_sectors',
            '^\s*LBA48  user addressable sectors:\s*(\d+)': 'lba48_user_addressable_sectors',
            '^\s*Logical/Physical Sector size:\s*(\d+)': 'sector_size_bytes',
            '^\s*device size with M = 1024\*1024:\s*(\d+)': 'size_mb',
}

        cmd = [hdparm_cmd, '-I', self.dev]

        attrs = Command.run_and_extract_attrs(cmd, hdparm_attrs)

        for (key, value) in attrs.iteritems():
            attrs[key] = value.strip()

        # Convert integer values to integers
        int_attrs = ['size_mb', 'sector_size_bytes', 'lba48_user_addressable_sectors', 'chs_current_addressable_sectors']

        for attr in int_attrs:
            value = attrs.get(attr, None)
            if value is not None:
                attrs[attr] = int(value)

        return attrs
Example #7
0
    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
Example #8
0
 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))
Example #9
0
    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
Example #10
0
    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
Example #11
0
 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))
Example #12
0
 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]
Example #13
0
 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]
Example #14
0
 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]
Example #15
0
 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]
Example #16
0
    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
Example #17
0
    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)
Example #18
0
 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
Example #19
0
    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)
Example #20
0
    def speed_test(self, offset=None):
        cmd = [hdparm_cmd, '-t', '--direct']

        if offset:
            cmd.append('--offset')
            cmd.append('%d' % offset)

        cmd.append(self.dev)

        patterns = {'^\s*Timing.*=\s*([0-9\.]+)': 'speed'}

        attrs = Command.run_and_extract_attrs(cmd, patterns)

        float_attrs = ['speed']

        for attr in float_attrs:
            value = attrs.get(attr, None)
            if value is not None:
                attrs[attr] = float(value)

        return attrs['speed']
Example #21
0
    def get_info(self):
        hdparm_attrs = {
            '^\s*Serial Number:\s*(.*)\s*$': 'serial_number',
            '^\s*Firmware Revision:\s*(.*)\s*$': 'firmware',
            '^\s*Transport:\s*(.*)\s*$': 'transport',
            '^\s*NAA:\s*(.*)\s*$': 'naa',
            '^\s*IEEE OUI:\s*(.*)\s*$': 'ieee_oui',
            '^\s*Unique ID:\s*(.*)\s*$': 'unique_id',
            '^\s*Logical Unit WWN Device Identifier:\s*(.*)\s*$': 'wwn',
            '^\s*Model Number:\s+(.*)\s*$': 'model_number',
            '^\s*CHS current addressable sectors\s*:\s*(\d+)':
            'chs_current_addressable_sectors',
            '^\s*LBA\s+user\s+addressable\s+sectors\s*:\s*(\d+)':
            'lba_user_addressable_sectors',
            '^\s*LBA48  user addressable sectors:\s*(\d+)':
            'lba48_user_addressable_sectors',
            '^\s*Logical/Physical Sector size:\s*(\d+)': 'sector_size_bytes',
            '^\s*device size with M = 1024\*1024:\s*(\d+)': 'size_mb',
        }

        cmd = [hdparm_cmd, '-I', self.dev]

        attrs = Command.run_and_extract_attrs(cmd, hdparm_attrs)

        for (key, value) in attrs.iteritems():
            attrs[key] = value.strip()

        # Convert integer values to integers
        int_attrs = [
            'size_mb', 'sector_size_bytes', 'lba48_user_addressable_sectors',
            'chs_current_addressable_sectors'
        ]

        for attr in int_attrs:
            value = attrs.get(attr, None)
            if value is not None:
                attrs[attr] = int(value)

        return attrs
Example #22
0
    def speed_test(self, offset=None):
        cmd = [hdparm_cmd, '-t', '--direct']

        if offset:
            cmd.append('--offset')
            cmd.append('%d' % offset)

        cmd.append(self.dev)
        
        patterns = {
            '^\s*Timing.*=\s*([0-9\.]+)': 'speed'
        }

        attrs = Command.run_and_extract_attrs(cmd, patterns)

        float_attrs = ['speed']

        for attr in float_attrs:
            value = attrs.get(attr, None)
            if value is not None:
                attrs[attr] = float(value)

        return attrs['speed']