style: ruff format and the lint rules of the driver standard
Mechanical: ruff format, and ruff check --fix with the rule set every NAPALM driver uses (E, F, I, UP, B at line length 100, Python 3.10). Mapping and Iterable come from collections.abc, imports are sorted. What ruff cannot fix comes in the next commit.
This commit is contained in:
1 parent
5b24675a12
commit
09029ca0a4
29 files changed
+985
-456
No files matched your search
@@ -34,14 +34,39 @@ def test_account_defaults():
|
||||
|
||||
|
||||
def test_to_napalm_users(rackmount):
|
||||
accounts = [parse_account(rackmount(f"/redfish/v1/AccountService/Accounts/{i}"))
|
||||
for i in (1, 2)]
|
||||
accounts.append({"id": "3", "username": "netork", "role_id": "ReadOnly", "enabled": True,
|
||||
"locked": False, "account_types": []})
|
||||
accounts.append({"id": "4", "username": "ops", "role_id": "Operator", "enabled": False,
|
||||
"locked": False, "account_types": []})
|
||||
accounts.append({"id": "5", "username": "custom", "role_id": "OemSpecial", "enabled": True,
|
||||
"locked": False, "account_types": []})
|
||||
accounts = [
|
||||
parse_account(rackmount(f"/redfish/v1/AccountService/Accounts/{i}")) for i in (1, 2)
|
||||
]
|
||||
accounts.append(
|
||||
{
|
||||
"id": "3",
|
||||
"username": "netork",
|
||||
"role_id": "ReadOnly",
|
||||
"enabled": True,
|
||||
"locked": False,
|
||||
"account_types": [],
|
||||
}
|
||||
)
|
||||
accounts.append(
|
||||
{
|
||||
"id": "4",
|
||||
"username": "ops",
|
||||
"role_id": "Operator",
|
||||
"enabled": False,
|
||||
"locked": False,
|
||||
"account_types": [],
|
||||
}
|
||||
)
|
||||
accounts.append(
|
||||
{
|
||||
"id": "5",
|
||||
"username": "custom",
|
||||
"role_id": "OemSpecial",
|
||||
"enabled": True,
|
||||
"locked": False,
|
||||
"account_types": [],
|
||||
}
|
||||
)
|
||||
accounts.append(None)
|
||||
assert to_napalm_users(accounts) == {
|
||||
"Administrator": {"level": 15, "password": "", "sshkeys": []},
|
||||
|
||||
@@ -39,10 +39,12 @@ def test_sources_legacy_only(localstorage):
|
||||
|
||||
|
||||
def test_sources_mixed_and_missing():
|
||||
src = environment_sources({
|
||||
"ThermalSubsystem": {"@odata.id": "/redfish/v1/Chassis/X/ThermalSubsystem"},
|
||||
"Power": {"@odata.id": "/redfish/v1/Chassis/X/Power"},
|
||||
})
|
||||
src = environment_sources(
|
||||
{
|
||||
"ThermalSubsystem": {"@odata.id": "/redfish/v1/Chassis/X/ThermalSubsystem"},
|
||||
"Power": {"@odata.id": "/redfish/v1/Chassis/X/Power"},
|
||||
}
|
||||
)
|
||||
assert src["thermal"]["schema"] == "ThermalSubsystem"
|
||||
assert src["power"]["schema"] == "Power"
|
||||
assert environment_sources({}) == {"thermal": None, "power": None, "sensors": None}
|
||||
@@ -68,42 +70,70 @@ def test_thermal(rackmount):
|
||||
"reading, health, alert, critical",
|
||||
[
|
||||
(41, "OK", False, False),
|
||||
(42, "OK", True, False), # at UpperThresholdNonCritical
|
||||
(45, "OK", True, True), # at UpperThresholdCritical
|
||||
(49, "OK", True, True), # above UpperThresholdFatal
|
||||
(4, "OK", True, True), # below LowerThresholdCritical
|
||||
(9, "OK", True, False), # below LowerThresholdNonCritical
|
||||
(42, "OK", True, False), # at UpperThresholdNonCritical
|
||||
(45, "OK", True, True), # at UpperThresholdCritical
|
||||
(49, "OK", True, True), # above UpperThresholdFatal
|
||||
(4, "OK", True, True), # below LowerThresholdCritical
|
||||
(9, "OK", True, False), # below LowerThresholdNonCritical
|
||||
(30, "Warning", True, False),
|
||||
(30, "Critical", True, True),
|
||||
],
|
||||
)
|
||||
def test_thermal_thresholds(reading, health, alert, critical):
|
||||
env = parse_thermal({"Temperatures": [{
|
||||
"Name": "T", "ReadingCelsius": reading, "Status": {"State": "Enabled", "Health": health},
|
||||
"UpperThresholdNonCritical": 42, "UpperThresholdCritical": 45, "UpperThresholdFatal": 48,
|
||||
"LowerThresholdNonCritical": 10, "LowerThresholdCritical": 5,
|
||||
}]})
|
||||
env = parse_thermal(
|
||||
{
|
||||
"Temperatures": [
|
||||
{
|
||||
"Name": "T",
|
||||
"ReadingCelsius": reading,
|
||||
"Status": {"State": "Enabled", "Health": health},
|
||||
"UpperThresholdNonCritical": 42,
|
||||
"UpperThresholdCritical": 45,
|
||||
"UpperThresholdFatal": 48,
|
||||
"LowerThresholdNonCritical": 10,
|
||||
"LowerThresholdCritical": 5,
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert env["temperature"]["T"] == {
|
||||
"temperature": float(reading), "is_alert": alert, "is_critical": critical}
|
||||
"temperature": float(reading),
|
||||
"is_alert": alert,
|
||||
"is_critical": critical,
|
||||
}
|
||||
|
||||
|
||||
def test_thermal_old_schema_names_and_duplicates():
|
||||
# Thermal 1.0 uses FanName; Supermicro repeats names across members.
|
||||
env = parse_thermal({
|
||||
"Fans": [
|
||||
{"MemberId": "0", "FanName": "FAN1", "Reading": 3000, "Status": {"State": "Enabled",
|
||||
"Health": "OK"}},
|
||||
{"MemberId": "1", "FanName": "FAN2", "Status": {"State": "Absent"}},
|
||||
{"MemberId": "2", "FanName": "FAN3", "Reading": 0,
|
||||
"Status": {"State": "Enabled", "Health": "Critical"}},
|
||||
{"MemberId": "3", "FanName": "FAN1", "Reading": 2900,
|
||||
"Status": {"State": "Enabled", "Health": "OK"}},
|
||||
],
|
||||
"Temperatures": [
|
||||
{"MemberId": "0", "Name": "System Temp", "ReadingCelsius": 30},
|
||||
{"MemberId": "1", "Name": "System Temp", "ReadingCelsius": 31},
|
||||
],
|
||||
})
|
||||
env = parse_thermal(
|
||||
{
|
||||
"Fans": [
|
||||
{
|
||||
"MemberId": "0",
|
||||
"FanName": "FAN1",
|
||||
"Reading": 3000,
|
||||
"Status": {"State": "Enabled", "Health": "OK"},
|
||||
},
|
||||
{"MemberId": "1", "FanName": "FAN2", "Status": {"State": "Absent"}},
|
||||
{
|
||||
"MemberId": "2",
|
||||
"FanName": "FAN3",
|
||||
"Reading": 0,
|
||||
"Status": {"State": "Enabled", "Health": "Critical"},
|
||||
},
|
||||
{
|
||||
"MemberId": "3",
|
||||
"FanName": "FAN1",
|
||||
"Reading": 2900,
|
||||
"Status": {"State": "Enabled", "Health": "OK"},
|
||||
},
|
||||
],
|
||||
"Temperatures": [
|
||||
{"MemberId": "0", "Name": "System Temp", "ReadingCelsius": 30},
|
||||
{"MemberId": "1", "Name": "System Temp", "ReadingCelsius": 31},
|
||||
],
|
||||
}
|
||||
)
|
||||
assert env["fans"] == {
|
||||
"FAN1": {"status": True},
|
||||
"FAN3": {"status": False},
|
||||
@@ -126,10 +156,14 @@ def test_power(rackmount):
|
||||
|
||||
|
||||
def test_power_unknown_values_are_minus_one():
|
||||
env = parse_power({"PowerSupplies": [
|
||||
{"MemberId": "0", "Name": "PS1", "Status": {"State": "Enabled", "Health": "OK"}},
|
||||
{"MemberId": "1", "Name": "PS2", "Status": {"State": "Absent"}},
|
||||
]})
|
||||
env = parse_power(
|
||||
{
|
||||
"PowerSupplies": [
|
||||
{"MemberId": "0", "Name": "PS1", "Status": {"State": "Enabled", "Health": "OK"}},
|
||||
{"MemberId": "1", "Name": "PS2", "Status": {"State": "Absent"}},
|
||||
]
|
||||
}
|
||||
)
|
||||
assert env["power"] == {"PS1": {"status": True, "capacity": -1.0, "output": -1.0}}
|
||||
assert env["consumed_watts"] is None
|
||||
assert env["voltages"] == {}
|
||||
@@ -211,8 +245,8 @@ def test_sensor_temperature_by_units(rackmount):
|
||||
assert s["units"] == "Cel"
|
||||
assert s["physical_context"] == "CPU"
|
||||
assert s["health"] == "Warning"
|
||||
assert s["is_alert"] is True # 44 >= UpperCaution 42
|
||||
assert s["is_critical"] is False # 44 < UpperCritical 45
|
||||
assert s["is_alert"] is True # 44 >= UpperCaution 42
|
||||
assert s["is_critical"] is False # 44 < UpperCritical 45
|
||||
|
||||
|
||||
def test_sensor_power(rackmount):
|
||||
@@ -234,28 +268,37 @@ def test_sensor_voltage_and_fan(rackmount):
|
||||
|
||||
|
||||
def test_sensor_without_reading():
|
||||
s = parse_sensor({"Id": "X", "Name": "X", "ReadingUnits": "Cel",
|
||||
"Status": {"State": "Disabled"}})
|
||||
s = parse_sensor(
|
||||
{"Id": "X", "Name": "X", "ReadingUnits": "Cel", "Status": {"State": "Disabled"}}
|
||||
)
|
||||
assert s["reading"] is None
|
||||
assert s["is_alert"] is False
|
||||
|
||||
|
||||
def test_thermal_metrics(rackmount):
|
||||
env = parse_thermal_metrics(rackmount(CHASSIS + "/ThermalSubsystem/ThermalMetrics"))
|
||||
assert env == {"temperature": {
|
||||
"Intake": {"temperature": 24.8, "is_alert": False, "is_critical": False},
|
||||
"Exhaust": {"temperature": 40.5, "is_alert": False, "is_critical": False},
|
||||
}}
|
||||
assert env == {
|
||||
"temperature": {
|
||||
"Intake": {"temperature": 24.8, "is_alert": False, "is_critical": False},
|
||||
"Exhaust": {"temperature": 40.5, "is_alert": False, "is_critical": False},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def test_build_environment_from_new_resources(rackmount):
|
||||
fans = [parse_fan(rackmount(f"{CHASSIS}/ThermalSubsystem/Fans/{f}"))
|
||||
for f in ("Bay1", "Bay2", "CPU1", "CPU2")]
|
||||
fans = [
|
||||
parse_fan(rackmount(f"{CHASSIS}/ThermalSubsystem/Fans/{f}"))
|
||||
for f in ("Bay1", "Bay2", "CPU1", "CPU2")
|
||||
]
|
||||
bay1 = f"{CHASSIS}/PowerSubsystem/PowerSupplies/Bay1"
|
||||
psus = [parse_power_supply(rackmount(bay1), rackmount(bay1 + "/Metrics")),
|
||||
parse_power_supply(rackmount(f"{CHASSIS}/PowerSubsystem/PowerSupplies/Bay2"))]
|
||||
sensors = [parse_sensor(rackmount(f"{CHASSIS}/Sensors/{s}"))
|
||||
for s in ("CPU1Temp", "IntakeTemp", "CPUFan1", "TotalPower", "PS1InputVoltage")]
|
||||
psus = [
|
||||
parse_power_supply(rackmount(bay1), rackmount(bay1 + "/Metrics")),
|
||||
parse_power_supply(rackmount(f"{CHASSIS}/PowerSubsystem/PowerSupplies/Bay2")),
|
||||
]
|
||||
sensors = [
|
||||
parse_sensor(rackmount(f"{CHASSIS}/Sensors/{s}"))
|
||||
for s in ("CPU1Temp", "IntakeTemp", "CPUFan1", "TotalPower", "PS1InputVoltage")
|
||||
]
|
||||
env = build_environment(fans=fans, power_supplies=psus, sensors=sensors)
|
||||
assert env["fans"] == {
|
||||
"Fan Bay 1": {"status": True},
|
||||
@@ -269,18 +312,29 @@ def test_build_environment_from_new_resources(rackmount):
|
||||
assert env["temperature"] == {
|
||||
"CPU #1 Temperature": {"temperature": 44.0, "is_alert": True, "is_critical": False},
|
||||
"Front Panel Intake Temperature": {
|
||||
"temperature": 24.8, "is_alert": False, "is_critical": False},
|
||||
"temperature": 24.8,
|
||||
"is_alert": False,
|
||||
"is_critical": False,
|
||||
},
|
||||
}
|
||||
assert env["consumed_watts"] == 374.0
|
||||
assert env["voltages"] == {
|
||||
"Power Supply #1 Input Voltage": {
|
||||
"voltage": 119.27, "is_alert": False, "is_critical": False},
|
||||
"voltage": 119.27,
|
||||
"is_alert": False,
|
||||
"is_critical": False,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def test_build_environment_empty():
|
||||
assert build_environment() == {
|
||||
"fans": {}, "temperature": {}, "power": {}, "voltages": {}, "consumed_watts": None}
|
||||
"fans": {},
|
||||
"temperature": {},
|
||||
"power": {},
|
||||
"voltages": {},
|
||||
"consumed_watts": None,
|
||||
}
|
||||
|
||||
|
||||
def test_power_supply_legacy_item(rackmount):
|
||||
|
||||
@@ -83,12 +83,20 @@ def test_memory_absent(rackmount):
|
||||
|
||||
def test_memory_older_schema():
|
||||
# Memory 1.0-1.x: DeviceLocator instead of Location, speed in OperatingSpeedMhz.
|
||||
dimm = parse_memory({
|
||||
"Id": "1", "Name": "Memory 1", "DeviceLocator": "P1-DIMMA1", "CapacityMiB": 16384,
|
||||
"OperatingSpeedMhz": 2133, "Manufacturer": "Samsung ", "PartNumber": "M393A2G40DB0-CPB",
|
||||
"SerialNumber": "12345678", "MemoryDeviceType": "DDR4",
|
||||
"Status": {"State": "Enabled", "Health": "OK"},
|
||||
})
|
||||
dimm = parse_memory(
|
||||
{
|
||||
"Id": "1",
|
||||
"Name": "Memory 1",
|
||||
"DeviceLocator": "P1-DIMMA1",
|
||||
"CapacityMiB": 16384,
|
||||
"OperatingSpeedMhz": 2133,
|
||||
"Manufacturer": "Samsung ",
|
||||
"PartNumber": "M393A2G40DB0-CPB",
|
||||
"SerialNumber": "12345678",
|
||||
"MemoryDeviceType": "DDR4",
|
||||
"Status": {"State": "Enabled", "Health": "OK"},
|
||||
}
|
||||
)
|
||||
assert dimm["location"] == "P1-DIMMA1"
|
||||
assert dimm["speed_mhz"] == 2133
|
||||
assert dimm["manufacturer"] == "Samsung"
|
||||
@@ -110,16 +118,18 @@ def test_storage(localstorage):
|
||||
assert st["name"] == "Local Storage Controller"
|
||||
assert st["state"] == "Enabled"
|
||||
assert st["health"] == "OK"
|
||||
assert st["controllers"] == [{
|
||||
"name": "Contoso Integrated RAID",
|
||||
"manufacturer": "Contoso",
|
||||
"model": "12Gbs Integrated RAID",
|
||||
"serial_number": "2M220100SL",
|
||||
"firmware_version": "1.0.0.7",
|
||||
"speed_gbps": 12,
|
||||
"state": "Enabled",
|
||||
"health": "OK",
|
||||
}]
|
||||
assert st["controllers"] == [
|
||||
{
|
||||
"name": "Contoso Integrated RAID",
|
||||
"manufacturer": "Contoso",
|
||||
"model": "12Gbs Integrated RAID",
|
||||
"serial_number": "2M220100SL",
|
||||
"firmware_version": "1.0.0.7",
|
||||
"speed_gbps": 12,
|
||||
"state": "Enabled",
|
||||
"health": "OK",
|
||||
}
|
||||
]
|
||||
assert st["drive_paths"] == [
|
||||
"/redfish/v1/Chassis/1U/Drives/35D38F11ACEF7BD3",
|
||||
"/redfish/v1/Chassis/1U/Drives/3F5A8C54207B7233",
|
||||
@@ -163,7 +173,11 @@ def test_simple_storage(rackmount):
|
||||
assert st["name"] == "Simple Storage Controller"
|
||||
assert st["health"] == "OK"
|
||||
assert [d["name"] for d in st["drives"]] == [
|
||||
"SATA Bay 1", "SATA Bay 2", "SATA Bay 3", "SATA Bay 4"]
|
||||
"SATA Bay 1",
|
||||
"SATA Bay 2",
|
||||
"SATA Bay 3",
|
||||
"SATA Bay 4",
|
||||
]
|
||||
bay1, bay2, bay3, _ = st["drives"]
|
||||
assert bay1["model"] == "3000GT8"
|
||||
assert bay1["capacity_bytes"] == 8000000000000
|
||||
|
||||
@@ -88,29 +88,33 @@ def test_ethernet_link_state(props, is_up, is_enabled):
|
||||
|
||||
def test_ethernet_unset_addresses_and_formats():
|
||||
# Supermicro and others report unset addresses as 0.0.0.0 or "::" and MACs in lower case.
|
||||
eth = parse_ethernet_interface({
|
||||
"Id": "1",
|
||||
"MACAddress": "0c:c4:7a:aa:bb:cc",
|
||||
"SpeedMbps": None,
|
||||
"IPv4Addresses": [
|
||||
{"Address": "0.0.0.0", "SubnetMask": "0.0.0.0"},
|
||||
{"Address": "10.1.2.3", "SubnetMask": "255.255.255.0"},
|
||||
{"Address": "10.1.2.4", "SubnetMask": "garbage"},
|
||||
{"Address": None},
|
||||
],
|
||||
"IPv6Addresses": [
|
||||
{"Address": "::", "PrefixLength": 0},
|
||||
{"Address": "2001:DB8::5", "PrefixLength": 64},
|
||||
{"Address": "2001:db8::6"},
|
||||
],
|
||||
})
|
||||
eth = parse_ethernet_interface(
|
||||
{
|
||||
"Id": "1",
|
||||
"MACAddress": "0c:c4:7a:aa:bb:cc",
|
||||
"SpeedMbps": None,
|
||||
"IPv4Addresses": [
|
||||
{"Address": "0.0.0.0", "SubnetMask": "0.0.0.0"},
|
||||
{"Address": "10.1.2.3", "SubnetMask": "255.255.255.0"},
|
||||
{"Address": "10.1.2.4", "SubnetMask": "garbage"},
|
||||
{"Address": None},
|
||||
],
|
||||
"IPv6Addresses": [
|
||||
{"Address": "::", "PrefixLength": 0},
|
||||
{"Address": "2001:DB8::5", "PrefixLength": 64},
|
||||
{"Address": "2001:db8::6"},
|
||||
],
|
||||
}
|
||||
)
|
||||
assert eth["interface"]["mac_address"] == "0C:C4:7A:AA:BB:CC"
|
||||
assert eth["interface"]["speed"] == -1.0
|
||||
assert eth["interface"]["mtu"] == 0
|
||||
assert eth["interface"]["description"] == ""
|
||||
assert eth["ipv4"] == {"10.1.2.3": {"prefix_length": 24}}
|
||||
assert eth["ipv6"] == {"2001:db8::5": {"prefix_length": 64},
|
||||
"2001:db8::6": {"prefix_length": 128}}
|
||||
assert eth["ipv6"] == {
|
||||
"2001:db8::5": {"prefix_length": 64},
|
||||
"2001:db8::6": {"prefix_length": 128},
|
||||
}
|
||||
|
||||
|
||||
# --- NetworkProtocol -----------------------------------------------------------------------
|
||||
@@ -133,7 +137,11 @@ def test_network_protocol(rackmount):
|
||||
}
|
||||
assert np["ntp"] == {"enabled": None, "servers": []}
|
||||
assert np["snmp"] == {
|
||||
"enabled": True, "port": 161, "v1": True, "v2c": False, "v3": True,
|
||||
"enabled": True,
|
||||
"port": 161,
|
||||
"v1": True,
|
||||
"v2c": False,
|
||||
"v3": True,
|
||||
"communities": [
|
||||
{"name": "Read-only community", "access": "Limited"},
|
||||
{"name": "Full access community", "access": "Full"},
|
||||
@@ -149,8 +157,14 @@ def test_network_protocol_ntp(telemetry):
|
||||
}
|
||||
assert np["protocols"]["NTP"] == {"enabled": True, "port": None}
|
||||
# Older SNMP schema: only ProtocolEnabled and Port.
|
||||
assert np["snmp"] == {"enabled": True, "port": 161, "v1": None, "v2c": None, "v3": None,
|
||||
"communities": []}
|
||||
assert np["snmp"] == {
|
||||
"enabled": True,
|
||||
"port": 161,
|
||||
"v1": None,
|
||||
"v2c": None,
|
||||
"v3": None,
|
||||
"communities": [],
|
||||
}
|
||||
|
||||
|
||||
def test_network_protocol_port_without_flag():
|
||||
@@ -162,5 +176,11 @@ def test_network_protocol_ntp_blank_entries():
|
||||
servers = ["", None, " pool.ntp.org ", "pool.ntp.org"]
|
||||
np = parse_network_protocol({"NTP": {"ProtocolEnabled": True, "NTPServers": servers}})
|
||||
assert np["ntp"]["servers"] == ["pool.ntp.org"]
|
||||
assert np["snmp"] == {"enabled": None, "port": None, "v1": None, "v2c": None, "v3": None,
|
||||
"communities": []}
|
||||
assert np["snmp"] == {
|
||||
"enabled": None,
|
||||
"port": None,
|
||||
"v1": None,
|
||||
"v2c": None,
|
||||
"v3": None,
|
||||
"communities": [],
|
||||
}
|
||||
@@ -26,13 +26,15 @@ def test_service_root_links(rackmount):
|
||||
|
||||
|
||||
def test_service_root_vendor_and_oem():
|
||||
root = parse_service_root({
|
||||
"RedfishVersion": "1.0.1",
|
||||
"Vendor": "Supermicro",
|
||||
"Product": "X10DRL-i",
|
||||
"Oem": {"Supermicro": {"@odata.type": "#SmcServiceRoot"}},
|
||||
"Systems": {"@odata.id": "/redfish/v1/Systems"},
|
||||
})
|
||||
root = parse_service_root(
|
||||
{
|
||||
"RedfishVersion": "1.0.1",
|
||||
"Vendor": "Supermicro",
|
||||
"Product": "X10DRL-i",
|
||||
"Oem": {"Supermicro": {"@odata.type": "#SmcServiceRoot"}},
|
||||
"Systems": {"@odata.id": "/redfish/v1/Systems"},
|
||||
}
|
||||
)
|
||||
assert root["vendor"] == "Supermicro"
|
||||
assert root["product"] == "X10DRL-i"
|
||||
assert root["oem_vendors"] == ["Supermicro"]
|
||||
|
||||
@@ -47,16 +47,18 @@ def test_system_links(rackmount):
|
||||
|
||||
def test_system_placeholders_and_blanks_are_none():
|
||||
# Supermicro boards report the DMI defaults the board vendor never filled in.
|
||||
s = parse_system({
|
||||
"Id": "1",
|
||||
"Manufacturer": "Supermicro",
|
||||
"Model": "X10DRL-i",
|
||||
"SerialNumber": "0123456789",
|
||||
"SKU": "To Be Filled By O.E.M.",
|
||||
"HostName": "",
|
||||
"UUID": " ",
|
||||
"PartNumber": "Default string",
|
||||
})
|
||||
s = parse_system(
|
||||
{
|
||||
"Id": "1",
|
||||
"Manufacturer": "Supermicro",
|
||||
"Model": "X10DRL-i",
|
||||
"SerialNumber": "0123456789",
|
||||
"SKU": "To Be Filled By O.E.M.",
|
||||
"HostName": "",
|
||||
"UUID": " ",
|
||||
"PartNumber": "Default string",
|
||||
}
|
||||
)
|
||||
assert s["manufacturer"] == "Supermicro"
|
||||
assert s["model"] == "X10DRL-i"
|
||||
assert s["serial_number"] is None
|
||||
@@ -88,8 +90,15 @@ def test_reset_action_inline_allowable_values(rackmount):
|
||||
reset = parse_reset_action(rackmount(SYSTEM))
|
||||
assert reset["target"] == SYSTEM + "/Actions/ComputerSystem.Reset"
|
||||
assert reset["allowed"] == [
|
||||
"On", "ForceOff", "GracefulShutdown", "GracefulRestart", "ForceRestart",
|
||||
"Nmi", "ForceOn", "PushPowerButton", "FullPowerCycle",
|
||||
"On",
|
||||
"ForceOff",
|
||||
"GracefulShutdown",
|
||||
"GracefulRestart",
|
||||
"ForceRestart",
|
||||
"Nmi",
|
||||
"ForceOn",
|
||||
"PushPowerButton",
|
||||
"FullPowerCycle",
|
||||
]
|
||||
assert reset["action_info"] is None
|
||||
|
||||
@@ -104,13 +113,25 @@ def test_reset_action_with_action_info(telemetry):
|
||||
|
||||
def test_action_info(telemetry):
|
||||
allowed = parse_action_info(telemetry("/redfish/v1/Systems/1/ResetActionInfo"))
|
||||
assert allowed == ["On", "ForceOff", "GracefulShutdown", "GracefulRestart",
|
||||
"ForceRestart", "Nmi", "ForceOn", "PushPowerButton"]
|
||||
assert allowed == [
|
||||
"On",
|
||||
"ForceOff",
|
||||
"GracefulShutdown",
|
||||
"GracefulRestart",
|
||||
"ForceRestart",
|
||||
"Nmi",
|
||||
"ForceOn",
|
||||
"PushPowerButton",
|
||||
]
|
||||
|
||||
|
||||
def test_action_info_other_parameter():
|
||||
info = {"Parameters": [{"Name": "ResetType", "AllowableValues": ["On"]},
|
||||
{"Name": "Delay", "AllowableValues": ["0", "5"]}]}
|
||||
info = {
|
||||
"Parameters": [
|
||||
{"Name": "ResetType", "AllowableValues": ["On"]},
|
||||
{"Name": "Delay", "AllowableValues": ["0", "5"]},
|
||||
]
|
||||
}
|
||||
assert parse_action_info(info, "Delay") == ["0", "5"]
|
||||
assert parse_action_info(info, "Missing") is None
|
||||
assert parse_action_info({}) is None
|
||||
|
||||
Reference in new issue
Block a user