diff --git a/netbox_agent/vendors/supermicro.py b/netbox_agent/vendors/supermicro.py index b10b7fd..3e9fd6e 100644 --- a/netbox_agent/vendors/supermicro.py +++ b/netbox_agent/vendors/supermicro.py @@ -23,8 +23,17 @@ class SupermicroHost(ServerBase): self.manufacturer = 'Supermicro' def is_blade(self): - blade = self.system[0]['Product Name'].startswith('SBI') - blade |= self.system[0]['Product Name'].startswith('SYS') + product_name = self.get_product_name() + # Blades + blade = product_name.startswith('SBI') + blade |= product_name.startswith('SBA') + # Twin + blade |= 'TR-' in product_name + # BigTwin + blade |= 'BT-' in product_name + # Microcloud + blade |= product_name.startswith('SYS-5039') + blade |= product_name.startswith('SYS-5038') return blade def get_blade_slot(self): @@ -37,21 +46,19 @@ class SupermicroHost(ServerBase): return None def get_service_tag(self): - return self.baseboard[0]['Serial Number'].strip() + return self.system[0]['Serial Number'].strip() def get_product_name(self): - if self.is_blade(): - return self.baseboard[0]['Product Name'].strip() return self.system[0]['Product Name'].strip() def get_chassis(self): if self.is_blade(): - return self.system[0]['Product Name'].strip() + return self.chassis[0]['Product Name'].strip() return self.get_product_name() def get_chassis_service_tag(self): if self.is_blade(): - return self.system[0]['Serial Number'].strip() + return self.chassis[0]['Serial Number'].strip() return self.get_service_tag() def get_chassis_name(self): diff --git a/tests/fixtures/dmidecode/SYS-5039MS-H12TRF-OS012.txt b/tests/fixtures/dmidecode/SYS-5039MS-H12TRF-OS012.txt new file mode 100644 index 0000000..f1c4af7 --- /dev/null +++ b/tests/fixtures/dmidecode/SYS-5039MS-H12TRF-OS012.txt @@ -0,0 +1,536 @@ +# dmidecode 3.1 +Getting SMBIOS data from sysfs. +SMBIOS 3.0 present. +32 structures occupying 2366 bytes. +Table at 0x6FB76000. + +Handle 0x0000, DMI type 0, 24 bytes +BIOS Information + Vendor: American Megatrends Inc. + Version: 2.2 + Release Date: 05/16/2018 + Address: 0xF0000 + Runtime Size: 64 kB + ROM Size: 16 MB + Characteristics: + PCI is supported + BIOS is upgradeable + BIOS shadowing is allowed + Boot from CD is supported + Selectable boot is supported + BIOS ROM is socketed + EDD is supported + 5.25"/1.2 MB floppy services are supported (int 13h) + 3.5"/720 kB floppy services are supported (int 13h) + 3.5"/2.88 MB floppy services are supported (int 13h) + Print screen service is supported (int 5h) + Serial services are supported (int 14h) + Printer services are supported (int 17h) + ACPI is supported + USB legacy is supported + BIOS boot specification is supported + Targeted content distribution is supported + UEFI is supported + BIOS Revision: 5.11 + +Handle 0x0001, DMI type 1, 27 bytes +System Information + Manufacturer: Supermicro + Product Name: SYS-5039MS-H12TRF-OS012 + Version: 0123456789 + Serial Number: E235735X6B01665 + UUID: 00000000-0000-0000-0000-0CC47AE14338 + Wake-up Type: Power Switch + SKU Number: To be filled by O.E.M. + Family: To be filled by O.E.M. + +Handle 0x0002, DMI type 2, 15 bytes +Base Board Information + Manufacturer: Supermicro + Product Name: X11SSE-F + Version: 1.01 + Serial Number: ZM169S040205 + Asset Tag: To be filled by O.E.M. + Features: + Board is a hosting board + Board is replaceable + Location In Chassis: To be filled by O.E.M. + Chassis Handle: 0x0003 + Type: Motherboard + Contained Object Handles: 0 + +Handle 0x0003, DMI type 3, 22 bytes +Chassis Information + Manufacturer: Supermicro + Type: Other + Lock: Not Present + Version: 0123456789 + Serial Number: C9390AF40A20098 + Asset Tag: To be filled by O.E.M. + Boot-up State: Safe + Power Supply State: Safe + Thermal State: Safe + Security Status: None + OEM Information: 0x00000000 + Height: Unspecified + Number Of Power Cords: 1 + Contained Elements: 0 + SKU Number: To be filled by O.E.M. + +Handle 0x0004, DMI type 9, 17 bytes +System Slot Information + Designation: CPU MICRO-LP PCI-E 3.0 X8 + Type: x8 PCI Express 3 x8 + Current Usage: In Use + Length: Short + ID: 1 + Characteristics: + 3.3 V is provided + Opening is shared + PME signal is supported + Bus Address: 0000:01:00.0 + +Handle 0x0005, DMI type 11, 5 bytes +OEM Strings + String 1: Intel Skylake-S/Skylake-H/Greenlow + String 2: Supermicro motherboard-X11 Series + +Handle 0x0006, DMI type 32, 20 bytes +System Boot Information + Status: No errors detected + +Handle 0x0007, DMI type 39, 22 bytes +System Power Supply + Power Unit Group: 1 + Location: PSU1 + Name: PWS-2K04F-1R + Manufacturer: SUPERMICRO + Serial Number: P2K4FCG37KT0851 + Asset Tag: N/A + Model Part Number: PWS-2K04F-1R + Revision: 1.0 + Max Power Capacity: 2000 W + Status: Present, OK + Type: Switching + Input Voltage Range Switching: Auto-switch + Plugged: Yes + Hot Replaceable: No + +Handle 0x0008, DMI type 39, 22 bytes +System Power Supply + Power Unit Group: 2 + Location: PSU2 + Name: PWS-2K04F-1R + Manufacturer: SUPERMICRO + Serial Number: P2K4FCG37KT0852 + Asset Tag: N/A + Model Part Number: PWS-2K04F-1R + Revision: 1.0 + Max Power Capacity: 2000 W + Status: Present, OK + Type: Switching + Input Voltage Range Switching: Auto-switch + Plugged: Yes + Hot Replaceable: No + +Handle 0x0009, DMI type 41, 11 bytes +Onboard Device + Reference Designation: ASPEED Video AST2400 + Type: Video + Status: Enabled + Type Instance: 1 + Bus Address: 0000:04:00.0 + +Handle 0x000A, DMI type 38, 18 bytes +IPMI Device Information + Interface Type: KCS (Keyboard Control Style) + Specification Version: 2.0 + I2C Slave Address: 0x10 + NV Storage Device: Not Present + Base Address: 0x0000000000000CA2 (I/O) + Register Spacing: Successive Byte Boundaries + +Handle 0x000B, DMI type 7, 19 bytes +Cache Information + Socket Designation: L1 Cache + Configuration: Enabled, Not Socketed, Level 1 + Operational Mode: Write Back + Location: Internal + Installed Size: 128 kB + Maximum Size: 128 kB + Supported SRAM Types: + Synchronous + Installed SRAM Type: Synchronous + Speed: Unknown + Error Correction Type: Parity + System Type: Data + Associativity: 8-way Set-associative + +Handle 0x000C, DMI type 7, 19 bytes +Cache Information + Socket Designation: L1 Cache + Configuration: Enabled, Not Socketed, Level 1 + Operational Mode: Write Back + Location: Internal + Installed Size: 128 kB + Maximum Size: 128 kB + Supported SRAM Types: + Synchronous + Installed SRAM Type: Synchronous + Speed: Unknown + Error Correction Type: Parity + System Type: Instruction + Associativity: 8-way Set-associative + +Handle 0x000D, DMI type 7, 19 bytes +Cache Information + Socket Designation: L2 Cache + Configuration: Enabled, Not Socketed, Level 2 + Operational Mode: Write Back + Location: Internal + Installed Size: 1024 kB + Maximum Size: 1024 kB + Supported SRAM Types: + Synchronous + Installed SRAM Type: Synchronous + Speed: Unknown + Error Correction Type: Single-bit ECC + System Type: Unified + Associativity: 4-way Set-associative + +Handle 0x000E, DMI type 7, 19 bytes +Cache Information + Socket Designation: L3 Cache + Configuration: Enabled, Not Socketed, Level 3 + Operational Mode: Write Back + Location: Internal + Installed Size: 8192 kB + Maximum Size: 8192 kB + Supported SRAM Types: + Synchronous + Installed SRAM Type: Synchronous + Speed: Unknown + Error Correction Type: Multi-bit ECC + System Type: Unified + Associativity: 16-way Set-associative + +Handle 0x000F, DMI type 4, 48 bytes +Processor Information + Socket Designation: CPU + Type: Central Processor + Family: Xeon + Manufacturer: Intel(R) Corporation + ID: E3 06 05 00 FF FB EB BF + Signature: Type 0, Family 6, Model 94, Stepping 3 + Flags: + FPU (Floating-point unit on-chip) + VME (Virtual mode extension) + DE (Debugging extension) + PSE (Page size extension) + TSC (Time stamp counter) + MSR (Model specific registers) + PAE (Physical address extension) + MCE (Machine check exception) + CX8 (CMPXCHG8 instruction supported) + APIC (On-chip APIC hardware supported) + SEP (Fast system call) + MTRR (Memory type range registers) + PGE (Page global enable) + MCA (Machine check architecture) + CMOV (Conditional move instruction supported) + PAT (Page attribute table) + PSE-36 (36-bit page size extension) + CLFSH (CLFLUSH instruction supported) + DS (Debug store) + ACPI (ACPI supported) + MMX (MMX technology supported) + FXSR (FXSAVE and FXSTOR instructions supported) + SSE (Streaming SIMD extensions) + SSE2 (Streaming SIMD extensions 2) + SS (Self-snoop) + HTT (Multi-threading) + TM (Thermal monitor supported) + PBE (Pending break enabled) + Version: Intel(R) Xeon(R) CPU E3-1245 v5 @ 3.50GHz + Voltage: 1.1 V + External Clock: 100 MHz + Max Speed: 3900 MHz + Current Speed: 3500 MHz + Status: Populated, Enabled + Upgrade: Other + L1 Cache Handle: 0x000C + L2 Cache Handle: 0x000D + L3 Cache Handle: 0x000E + Serial Number: To Be Filled By O.E.M. + Asset Tag: To Be Filled By O.E.M. + Part Number: To Be Filled By O.E.M. + Core Count: 4 + Core Enabled: 4 + Thread Count: 8 + Characteristics: + 64-bit capable + Multi-Core + Hardware Thread + Execute Protection + Enhanced Virtualization + Power/Performance Control + +Handle 0x0010, DMI type 16, 23 bytes +Physical Memory Array + Location: System Board Or Motherboard + Use: System Memory + Error Correction Type: Single-bit ECC + Maximum Capacity: 64 GB + Error Information Handle: Not Provided + Number Of Devices: 4 + +Handle 0x0011, DMI type 17, 40 bytes +Memory Device + Array Handle: 0x0010 + Error Information Handle: Not Provided + Total Width: Unknown + Data Width: Unknown + Size: No Module Installed + Form Factor: Unknown + Set: None + Locator: DIMMA1 + Bank Locator: P0_Node0_Channel0_Dimm0 + Type: Unknown + Type Detail: None + Speed: Unknown + Manufacturer: Not Specified + Serial Number: Not Specified + Asset Tag: Not Specified + Part Number: Not Specified + Rank: Unknown + Configured Clock Speed: Unknown + Minimum Voltage: Unknown + Maximum Voltage: Unknown + Configured Voltage: Unknown + +Handle 0x0012, DMI type 17, 40 bytes +Memory Device + Array Handle: 0x0010 + Error Information Handle: Not Provided + Total Width: 72 bits + Data Width: 64 bits + Size: 16384 MB + Form Factor: DIMM + Set: None + Locator: DIMMA2 + Bank Locator: P0_Node0_Channel0_Dimm1 + Type: DDR4 + Type Detail: Synchronous + Speed: 2400 MT/s + Manufacturer: Micron + Serial Number: 13DA8BB7 + Asset Tag: DIMMA2_AssetTag(16/36) + Part Number: 18ADF2G72AZ-2G3B1 + Rank: 2 + Configured Clock Speed: 2133 MT/s + Minimum Voltage: 1.2 V + Maximum Voltage: 1.2 V + Configured Voltage: 1.2 V + +Handle 0x0013, DMI type 17, 40 bytes +Memory Device + Array Handle: 0x0010 + Error Information Handle: Not Provided + Total Width: Unknown + Data Width: Unknown + Size: No Module Installed + Form Factor: Unknown + Set: None + Locator: DIMMB1 + Bank Locator: P0_Node0_Channel1_Dimm0 + Type: Unknown + Type Detail: None + Speed: Unknown + Manufacturer: Not Specified + Serial Number: Not Specified + Asset Tag: Not Specified + Part Number: Not Specified + Rank: Unknown + Configured Clock Speed: Unknown + Minimum Voltage: Unknown + Maximum Voltage: Unknown + Configured Voltage: Unknown + +Handle 0x0014, DMI type 17, 40 bytes +Memory Device + Array Handle: 0x0010 + Error Information Handle: Not Provided + Total Width: 72 bits + Data Width: 64 bits + Size: 16384 MB + Form Factor: DIMM + Set: None + Locator: DIMMB2 + Bank Locator: P0_Node0_Channel1_Dimm1 + Type: DDR4 + Type Detail: Synchronous + Speed: 2400 MT/s + Manufacturer: Micron + Serial Number: 13DA8C08 + Asset Tag: DIMMB2_AssetTag(16/36) + Part Number: 18ADF2G72AZ-2G3B1 + Rank: 2 + Configured Clock Speed: 2133 MT/s + Minimum Voltage: 1.2 V + Maximum Voltage: 1.2 V + Configured Voltage: 1.2 V + +Handle 0x0015, DMI type 19, 31 bytes +Memory Array Mapped Address + Starting Address: 0x00000000000 + Ending Address: 0x007FFFFFFFF + Range Size: 32 GB + Physical Array Handle: 0x0010 + Partition Width: 2 + +Handle 0x0016, DMI type 15, 73 bytes +System Event Log + Area Length: 65535 bytes + Header Start Offset: 0x0000 + Header Length: 16 bytes + Data Start Offset: 0x0010 + Access Method: Memory-mapped physical 32-bit address + Access Address: 0xFF610000 + Status: Valid, Not Full + Change Token: 0x00000001 + Header Format: Type 1 + Supported Log Type Descriptors: 25 + Descriptor 1: Single-bit ECC memory error + Data Format 1: Multiple-event handle + Descriptor 2: Multi-bit ECC memory error + Data Format 2: Multiple-event handle + Descriptor 3: Parity memory error + Data Format 3: None + Descriptor 4: Bus timeout + Data Format 4: None + Descriptor 5: I/O channel block + Data Format 5: None + Descriptor 6: Software NMI + Data Format 6: None + Descriptor 7: POST memory resize + Data Format 7: None + Descriptor 8: POST error + Data Format 8: POST results bitmap + Descriptor 9: PCI parity error + Data Format 9: Multiple-event handle + Descriptor 10: PCI system error + Data Format 10: Multiple-event handle + Descriptor 11: CPU failure + Data Format 11: None + Descriptor 12: EISA failsafe timer timeout + Data Format 12: None + Descriptor 13: Correctable memory log disabled + Data Format 13: None + Descriptor 14: Logging disabled + Data Format 14: None + Descriptor 15: System limit exceeded + Data Format 15: None + Descriptor 16: Asynchronous hardware timer expired + Data Format 16: None + Descriptor 17: System configuration information + Data Format 17: None + Descriptor 18: Hard disk information + Data Format 18: None + Descriptor 19: System reconfigured + Data Format 19: None + Descriptor 20: Uncorrectable CPU-complex error + Data Format 20: None + Descriptor 21: Log area reset/cleared + Data Format 21: None + Descriptor 22: System boot + Data Format 22: None + Descriptor 23: End of log + Data Format 23: None + Descriptor 24: OEM-specific + Data Format 24: OEM-specific + Descriptor 25: OEM-specific + Data Format 25: OEM-specific + +Handle 0x0017, DMI type 20, 35 bytes +Memory Device Mapped Address + Starting Address: 0x00000000000 + Ending Address: 0x003FFFFFFFF + Range Size: 16 GB + Physical Device Handle: 0x0012 + Memory Array Mapped Address Handle: 0x0015 + Partition Row Position: Unknown + Interleave Position: 1 + Interleaved Data Depth: 2 + +Handle 0x0018, DMI type 20, 35 bytes +Memory Device Mapped Address + Starting Address: 0x00400000000 + Ending Address: 0x007FFFFFFFF + Range Size: 16 GB + Physical Device Handle: 0x0014 + Memory Array Mapped Address Handle: 0x0015 + Partition Row Position: Unknown + Interleave Position: 2 + Interleaved Data Depth: 2 + +Handle 0x0019, DMI type 221, 26 bytes +OEM-specific Type + Header and Data: + DD 1A 19 00 03 01 00 04 01 00 08 00 02 00 00 00 + 00 C6 00 03 00 00 05 00 00 00 + Strings: + Reference Code - CPU + uCode Version + TXT ACM version + +Handle 0x001A, DMI type 221, 68 bytes +OEM-specific Type + Header and Data: + DD 44 1A 00 09 01 00 04 01 00 08 00 02 03 FF FF + FF FF FF 04 00 FF FF FF 31 00 05 00 FF FF FF 31 + 00 06 00 FF FF FF FF FF 07 00 3E 00 00 00 00 08 + 00 34 00 00 00 00 09 00 3E 00 00 00 00 0A 00 34 + 00 00 00 00 + Strings: + Reference Code - SKL PCH + PCH-CRID Status + Disabled + PCH-CRID Original Value + PCH-CRID New Value + OPROM - RST - RAID + SKL PCH H Bx Hsio Version + SKL PCH H Dx Hsio Version + SKL PCH LP Bx Hsio Version + SKL PCH LP Cx Hsio Version + +Handle 0x001B, DMI type 221, 54 bytes +OEM-specific Type + Header and Data: + DD 36 1B 00 07 01 00 04 01 00 08 00 02 00 02 01 + 00 00 00 03 00 04 01 00 00 00 04 05 FF FF FF FF + FF 06 00 FF FF FF 07 00 07 00 FF FF FF 07 00 08 + 00 FF FF FF 00 00 + Strings: + Reference Code - SA - System Agent + Reference Code - MRC + SA - PCIe Version + SA-CRID Status + Disabled + SA-CRID Original Value + SA-CRID New Value + OPROM - VBIOS + +Handle 0x001C, DMI type 40, 27 bytes +Additional Information 1 + +Handle 0x001D, DMI type 40, 27 bytes +Additional Information 1 + +Handle 0x001E, DMI type 136, 6 bytes +OEM-specific Type + Header and Data: + 88 06 1E 00 00 00 + +Handle 0x001F, DMI type 127, 4 bytes +End Of Table + diff --git a/tests/server.py b/tests/server.py index 6e781ad..b14d92d 100644 --- a/tests/server.py +++ b/tests/server.py @@ -1,5 +1,8 @@ from netbox_agent.dmidecode import parse from netbox_agent.server import ServerBase +from netbox_agent.vendors.hp import HPHost +from netbox_agent.vendors.qct import QCTHost +from netbox_agent.vendors.supermicro import SupermicroHost from tests.conftest import parametrize_with_fixtures @@ -19,10 +22,43 @@ def test_init(fixture): ]) def test_hp_service_tag(fixture): dmi = parse(fixture) - server = ServerBase(dmi) + server = HPHost(dmi) assert server.get_service_tag() == '4242' +@parametrize_with_fixtures( + 'dmidecode/', only_filenames=[ + 'SYS-5039MS-H12TRF-OS012.txt' + ]) +def test_supermicro_blade(fixture): + dmi = parse(fixture) + server = SupermicroHost(dmi) + assert server.get_service_tag() == 'E235735X6B01665' + assert server.get_chassis_service_tag() == 'C9390AF40A20098' + assert server.is_blade() is True + + +@parametrize_with_fixtures( + 'dmidecode/', only_filenames=[ + 'SM_SYS-6018R' + ]) +def test_supermicro_pizza(fixture): + dmi = parse(fixture) + server = SupermicroHost(dmi) + assert server.get_service_tag() == 'A177950X7709591' + assert server.is_blade() is False + + +@parametrize_with_fixtures( + 'dmidecode/', only_filenames=[ + 'QCT_X10E-9N' + ]) +def test_qct_x10(fixture): + dmi = parse(fixture) + server = QCTHost(dmi) + assert server.get_service_tag() == 'QTFCQ57140285' + + @parametrize_with_fixtures( 'dmidecode/', only_filenames=[ 'unknown.txt'