Beispiel #1
0
 def test_parse(self):
     p = parse_dmidecode(DATA)
     self.maxDiff = None
     self.assertEqual(p['model'], 'ProLiant BL460c G6')
     self.assertEqual(p['sn'], 'GB8926V807')
     self.assertEqual(p['uuid'], '38373035-3436-4247-3839-323656383037')
     self.assertEqual(len(p['cpu']), 2)
     self.assertEqual(len(p['mem']), 4)
     self.assertEqual(p['cpu'][0], {
         '64bit': True,
         'cores': 4,
         'family': 'Quad-Core Xeon',
         'flags': [
             'CLFSH (CLFLUSH instruction supported)',
             'MCA (Machine check architecture)',
             'DE (Debugging extension)',
             'TM (Thermal monitor supported)',
             'TSC (Time stamp counter)',
             'PSE-36 (36-bit page size extension)',
             'MMX (MMX technology supported)',
             'FPU (Floating-point unit on-chip)',
             'SSE2 (Streaming SIMD extensions 2)',
             'MSR (Model specific registers)',
             'PSE (Page size extension)',
             'SS (Self-snoop)',
             'FXSR (Fast floating-point save and restore)',
             'MTRR (Memory type range registers)',
             'VME (Virtual mode extension)',
             'PBE (Pending break enabled)',
             'ACPI (ACPI supported)',
             'APIC (On-chip APIC hardware supported)',
             'SEP (Fast system call)',
             'SSE (Streaming SIMD extensions)',
             'PAT (Page attribute table)',
             'PAE (Physical address extension)',
             'CMOV (Conditional move instruction supported)',
             'PGE (Page global enable)',
             'MCE (Machine check exception)',
             'CX8 (CMPXCHG8 instruction supported)',
             'DS (Debug store)',
             'HTT (Hyper-threading technology)',
         ],
         'label': 'Proc 1',
         'model': 'Intel(R) Xeon(R) CPU E5506 @ 2.13GHz',
         'speed': 2133,
         'threads': 4,
     })
     self.assertEqual(p['mem'][0], {
         'label': u'PROC 1 DIMM 2A',
         'size': 4096,
         'speed': 1333,
         'type': u'DDR3',
     })
Beispiel #2
0
 def test_parse(self):
     p = parse_dmidecode(DATA)
     self.maxDiff = None
     self.assertEqual(p['model'], 'ProLiant BL460c G6')
     self.assertEqual(p['sn'], 'GB8926V807')
     self.assertEqual(p['uuid'], '38373035-3436-4247-3839-323656383037')
     self.assertEqual(len(p['cpu']), 2)
     self.assertEqual(len(p['mem']), 4)
     self.assertEqual(p['cpu'][0], {
         '64bit': True,
         'cores': 4,
         'family': 'Quad-Core Xeon',
         'flags': [
             'CLFSH (CLFLUSH instruction supported)',
             'MCA (Machine check architecture)',
             'DE (Debugging extension)',
             'TM (Thermal monitor supported)',
             'TSC (Time stamp counter)',
             'PSE-36 (36-bit page size extension)',
             'MMX (MMX technology supported)',
             'FPU (Floating-point unit on-chip)',
             'SSE2 (Streaming SIMD extensions 2)',
             'MSR (Model specific registers)',
             'PSE (Page size extension)',
             'SS (Self-snoop)',
             'FXSR (Fast floating-point save and restore)',
             'MTRR (Memory type range registers)',
             'VME (Virtual mode extension)',
             'PBE (Pending break enabled)',
             'ACPI (ACPI supported)',
             'APIC (On-chip APIC hardware supported)',
             'SEP (Fast system call)',
             'SSE (Streaming SIMD extensions)',
             'PAT (Page attribute table)',
             'PAE (Physical address extension)',
             'CMOV (Conditional move instruction supported)',
             'PGE (Page global enable)',
             'MCE (Machine check exception)',
             'CX8 (CMPXCHG8 instruction supported)',
             'DS (Debug store)',
             'HTT (Hyper-threading technology)',
         ],
         'label': 'Proc 1',
         'model': 'Intel(R) Xeon(R) CPU E5506 @ 2.13GHz',
         'speed': 2133,
         'threads': 4,
     })
     self.assertEqual(p['mem'][0], {
         'label': u'PROC 1 DIMM 2A',
         'size': 4096,
         'speed': 1333,
         'type': u'DDR3',
     })
Beispiel #3
0
def run_dmidecode(ssh, ethernets):
    """Handle dmidecode data"""

    stdin, stdout, stderr = ssh.exec_command("/usr/bin/sudo /usr/sbin/dmidecode")
    try:
        info = parse_dmidecode(stdout.read())
    except (DMIDecodeError, IOError):
        # No dmidecode, fall back to dumb device
        if not ethernets:
            # No serial number and no macs -- no way to make a device
            return None
        dev = Device.create(
            ethernets=ethernets, model_name="Linux", model_type=DeviceType.unknown, priority=SAVE_PRIORITY
        )
    else:
        dev = handle_dmidecode(info, ethernets, SAVE_PRIORITY)
    return dev
Beispiel #4
0
def run_dmidecode(ssh, ethernets):
    """Handle dmidecode data"""

    stdin, stdout, stderr = ssh.exec_command(
            "/usr/bin/sudo /usr/sbin/dmidecode")
    try:
        info = parse_dmidecode(stdout.read())
    except (DMIDecodeError, IOError):
        # No dmidecode, fall back to dumb device
        if not ethernets:
            # No serial number and no macs -- no way to make a device
            return ''
        dev = Device.create(ethernets=ethernets, model_name='Linux',
                        model_type=DeviceType.unknown,
                        priority=SAVE_PRIORITY)
    else:
        dev = handle_dmidecode(info, ethernets, SAVE_PRIORITY)
    return dev