Ejemplo n.º 1
0
 def test_corrupted_data(self):
     with mock.patch('include.common.shell_command.ShellCommand.get_stdout', return_value=SPACE_INSTEAD_OF_TABS) as something:
         with self.assertRaises(KeyError):
             get_memory_info("whatever")
     with mock.patch('include.common.shell_command.ShellCommand.get_stdout', return_value=MEMORY_NO_SERIAL_NO) as something:
         with self.assertRaises(KeyError):
             get_memory_info("whatever")
Ejemplo n.º 2
0
    def test_multiple_memories_response(self):
        self.assertEqual(_parse_handle_section(iter(MULTIPLE_MEMORIES.splitlines())),
                                    {'_title': 'Handle 0x0042, DMI type 16, 23 bytes'})

        with mock.patch('include.common.shell_command.ShellCommand.get_stdout', return_value=MULTIPLE_MEMORIES) as something:
            self.assertEqual(get_memory_info("whatever"), MEM_TO_OBJ)
            self.assertEqual(_parse_dmi(MULTIPLE_MEMORIES, TYPE.keys()[0]), MEM_TO_OBJ)
            self.assertEqual(_profile(TYPE.keys()[0]), MEM_TO_OBJ)
            self.assertEqual(get_memory_info('7730A787'), MEM1)
            self.assertEqual(get_memory_info('73305687'), MEM2)
Ejemplo n.º 3
0
    def set_fields(cls, memory, data, context=None):

        memory.deviceLocator = str(data[LSHW_SLOT])
        if memory.deviceLocator == "DIMM A":
            memory.deviceLocator = "A0"
        if memory.deviceLocator == "DIMM B":
            memory.deviceLocator = "A1"
        memory.dataWidthBits = int(data[LSHW_WIDTH][XML_HASH_TEXT])
        memory_details = dmidecode.get_memory_info(memory.fruInfo.serialNumber)
        if DMI_TOTAL_WIDTH in memory_details:
            memory.busWidthBits = memory_details[DMI_TOTAL_WIDTH].split(
                ' ')[MEMORY_DATA_SECTION]
        if DMI_RANK in memory_details:
            memory.rankCount = memory_details[DMI_RANK]
        if DMI_CNF_CLOCK_SPEED in memory_details:
            memory.operatingSpeedMHz = memory_details[
                DMI_CNF_CLOCK_SPEED].split(' ')[MEMORY_DATA_SECTION]
        if DMI_MAX_VOLTAGE in memory_details:
            memory.maximumVoltageVolt = memory_details[DMI_MAX_VOLTAGE].split(
                ' ')[MEMORY_DATA_SECTION]
        if DMI_MIN_VOLTAGE in memory_details:
            memory.minimumVoltageVolt = memory_details[DMI_MIN_VOLTAGE].split(
                ' ')[MEMORY_DATA_SECTION]
        if DMI_VOLTAGE in memory_details:
            memory.voltageVolt = memory_details[DMI_VOLTAGE].split(
                ' ')[MEMORY_DATA_SECTION]

        return memory
Ejemplo n.º 4
0
    def test_no_root_response(self):
        with mock.patch('include.common.shell_command.ShellCommand.get_stdout', return_value=NO_SENSE_RESPONSE) as something:
            self.assertEqual(get_memory_info("whatever"), [])

        self.assertEqual(_parse_handle_section(iter(NO_SENSE_RESPONSE.splitlines())),
                                    {'_title': 'Handle 0x0050, DMI type 131, 64 bytes'})
        self.assertEqual(_parse_dmi(NO_SENSE_RESPONSE, 5), [])
Ejemplo n.º 5
0
    def test_no_memory_response(self):
        self.assertEqual(_parse_handle_section(iter(PROPER_HANDLE_SECTION.splitlines())),
                                    {'_title': 'Handle 0x0050, DMI type 131, 64 bytes'})

        with mock.patch('include.common.shell_command.ShellCommand.get_stdout', return_value=PROPER_HANDLE_SECTION) as something:
            self.assertEqual(get_memory_info("whatever"), [])

        self.assertEqual(_parse_dmi(PROPER_HANDLE_SECTION, 5), [])
Ejemplo n.º 6
0
    def set_fields(cls, dimm, data, context=None):

        dimm.deviceLocator = str(data[LSHW_SLOT])
        if dimm.deviceLocator == "DIMM A":
            dimm.deviceLocator = "A0"
        if dimm.deviceLocator == "DIMM B":
            dimm.deviceLocator = "A1"
        dimm.dataWidthBits = int(data[LSHW_WIDTH][XML_HASH_TEXT])
        dimm_details = dmidecode.get_memory_info(dimm.fruInfo.serialNumber)
        if DMI_TOTAL_WIDTH in dimm_details:
            dimm.busWidthBits = dimm_details[DMI_TOTAL_WIDTH].split(' ')[MEMORY_DATA_SECTION]
        if DMI_RANK in dimm_details:
            dimm.rankCount = dimm_details[DMI_RANK]
        if DMI_CNF_CLOCK_SPEED in dimm_details:
            dimm.operatingSpeedMHz = dimm_details[DMI_CNF_CLOCK_SPEED].split(' ')[MEMORY_DATA_SECTION]
        if DMI_MAX_VOLTAGE in dimm_details:
            dimm.maximumVoltageVolt = dimm_details[DMI_MAX_VOLTAGE].split(' ')[MEMORY_DATA_SECTION]
        if DMI_MIN_VOLTAGE in dimm_details:
            dimm.minimumVoltageVolt = dimm_details[DMI_MIN_VOLTAGE].split(' ')[MEMORY_DATA_SECTION]
        if DMI_VOLTAGE in dimm_details:
            dimm.voltageVolt = dimm_details[DMI_VOLTAGE].split(' ')[MEMORY_DATA_SECTION]

        return dimm
Ejemplo n.º 7
0
    def test_no_root_response(self):
        with mock.patch('include.common.shell_command.ShellCommand.get_stdout',
                        return_value=NO_ROOT_RESPONSE) as something:
            self.assertEqual(get_memory_info("whatever"), [])

        self.assertEqual(_parse_dmi(NO_ROOT_RESPONSE, 5), [])