2020-02-02 20:08:56 +01:00
|
|
|
from netbox_agent.dmidecode import parse
|
|
|
|
from netbox_agent.server import ServerBase
|
2020-07-13 20:34:04 +02:00
|
|
|
from netbox_agent.vendors.hp import HPHost
|
|
|
|
from netbox_agent.vendors.qct import QCTHost
|
|
|
|
from netbox_agent.vendors.supermicro import SupermicroHost
|
2020-02-02 20:08:56 +01:00
|
|
|
from tests.conftest import parametrize_with_fixtures
|
|
|
|
|
|
|
|
|
|
|
|
@parametrize_with_fixtures('dmidecode/')
|
|
|
|
def test_init(fixture):
|
|
|
|
dmi = parse(fixture)
|
|
|
|
server = ServerBase(dmi)
|
|
|
|
assert server
|
|
|
|
|
|
|
|
|
|
|
|
@parametrize_with_fixtures(
|
|
|
|
'dmidecode/', only_filenames=[
|
|
|
|
'HP_SL4540_Gen8',
|
|
|
|
'HP_BL460c_Gen9',
|
|
|
|
'HP_DL380p_Gen8',
|
2020-02-03 00:38:23 +01:00
|
|
|
'HP_SL4540_Gen8'
|
2020-09-18 12:29:17 +02:00
|
|
|
'HP_ProLiant_BL460c_Gen10_Graphics_Exp'
|
2020-02-03 00:38:23 +01:00
|
|
|
])
|
2020-02-02 20:08:56 +01:00
|
|
|
def test_hp_service_tag(fixture):
|
|
|
|
dmi = parse(fixture)
|
2020-07-13 20:34:04 +02:00
|
|
|
server = HPHost(dmi)
|
2020-02-02 20:08:56 +01:00
|
|
|
assert server.get_service_tag() == '4242'
|
2020-02-03 00:38:23 +01:00
|
|
|
|
|
|
|
|
2020-08-20 18:03:36 +02:00
|
|
|
@parametrize_with_fixtures(
|
|
|
|
'dmidecode/', only_filenames=[
|
|
|
|
'HP_ProLiant_m710x'
|
|
|
|
])
|
|
|
|
def test_moonshot_blade(fixture):
|
|
|
|
dmi = parse(fixture)
|
|
|
|
server = HPHost(dmi)
|
|
|
|
assert server.get_service_tag() == 'CN66480BLA'
|
|
|
|
assert server.get_chassis_service_tag() == 'CZ3702MD5K'
|
|
|
|
assert server.is_blade() is True
|
2020-09-18 12:29:17 +02:00
|
|
|
assert server.own_expansion_slot() is False
|
2020-08-20 18:03:36 +02:00
|
|
|
|
|
|
|
|
2020-07-13 20:34:04 +02:00
|
|
|
@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'
|
2020-12-15 11:32:11 +01:00
|
|
|
assert server.get_chassis() == 'SYS-5039MS-H12TRF-OS012'
|
2020-07-13 20:34:04 +02:00
|
|
|
assert server.is_blade() is True
|
|
|
|
|
2020-07-29 00:21:08 +02:00
|
|
|
|
2020-07-13 20:34:04 +02:00
|
|
|
@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'
|
2020-12-15 11:32:11 +01:00
|
|
|
assert server.get_chassis() == 'SYS-6018R-TDTPR'
|
2020-07-13 20:34:04 +02:00
|
|
|
assert server.is_blade() is False
|
|
|
|
|
2020-07-29 00:21:08 +02:00
|
|
|
|
2020-07-28 18:51:15 +02:00
|
|
|
@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'
|
|
|
|
|
2020-07-29 00:21:08 +02:00
|
|
|
|
2020-02-03 00:38:23 +01:00
|
|
|
@parametrize_with_fixtures(
|
|
|
|
'dmidecode/', only_filenames=[
|
|
|
|
'unknown.txt'
|
|
|
|
])
|
|
|
|
def test_generic_host_service_tag(fixture):
|
|
|
|
dmi = parse(fixture)
|
|
|
|
server = ServerBase(dmi)
|
|
|
|
assert server.get_service_tag() == '42'
|
|
|
|
|
|
|
|
|
|
|
|
@parametrize_with_fixtures(
|
|
|
|
'dmidecode/', only_filenames=[
|
|
|
|
'unknown.txt'
|
|
|
|
])
|
|
|
|
def test_generic_host_product_name(fixture):
|
|
|
|
dmi = parse(fixture)
|
|
|
|
server = ServerBase(dmi)
|
|
|
|
assert server.get_product_name() == 'SR'
|
2020-09-18 12:29:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
@parametrize_with_fixtures(
|
|
|
|
'dmidecode/', only_filenames=[
|
|
|
|
'HP_ProLiant_BL460c_Gen10_Graphics_Exp'
|
|
|
|
])
|
|
|
|
def test_hp_blade_with_gpu_expansion(fixture):
|
|
|
|
dmi = parse(fixture)
|
|
|
|
server = HPHost(dmi)
|
|
|
|
assert server.get_service_tag() == '4242'
|
|
|
|
assert server.get_chassis_service_tag() == '4343'
|
|
|
|
assert server.is_blade() is True
|
|
|
|
assert server.own_expansion_slot() is True
|
|
|
|
assert server.get_expansion_service_tag() == '4242 expansion'
|