Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 4
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))
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 7
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))
Ejemplo n.º 8
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
Ejemplo n.º 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
Ejemplo n.º 10
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]
Ejemplo n.º 11
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]
Ejemplo n.º 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]
Ejemplo n.º 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]
Ejemplo n.º 14
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)
Ejemplo n.º 15
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
Ejemplo n.º 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
Ejemplo n.º 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)