Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/badfish/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,9 @@ async def reboot_server(self, graceful=True):

async def reset_idrac(self, wait=False):
if self.vendor != "Dell":
self.logger.warning("Vendor isn't a Dell, if you are trying this on a Supermicro or HPE, use --bmc-reset instead.")
self.logger.warning(
"Vendor isn't a Dell, if you are trying this on a Supermicro or HPE, use --bmc-reset instead."
)
return False
self.logger.debug("Running reset iDRAC.")
_reset_types = await self.get_reset_types(manager=True)
Expand Down Expand Up @@ -1163,7 +1165,9 @@ async def reset_idrac(self, wait=False):

async def reset_bmc(self):
if self.vendor not in ("Supermicro", "HPE"):
self.logger.warning("Vendor isn't a Supermicro or HPE, if you are trying this on a Dell, use --racreset instead.")
self.logger.warning(
"Vendor isn't a Supermicro or HPE, if you are trying this on a Dell, use --racreset instead."
)
return False
self.logger.debug("Running reset BMC.")
_reset_types = await self.get_reset_types(manager=True, bmc=True)
Expand Down
20 changes: 5 additions & 15 deletions tests/test_vendor_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@


ROOT_RESP_UNKNOWN_OEM = (
'{"Managers":{"@odata.id":"/redfish/v1/Managers"},'
'"RedfishVersion":"1.0.2","Oem":{"Lenovo":{}}}'
'{"Managers":{"@odata.id":"/redfish/v1/Managers"},' '"RedfishVersion":"1.0.2","Oem":{"Lenovo":{}}}'
)
MAN_RESP = '{"Members":[{"@odata.id":"/redfish/v1/Managers/1"}]}'

Expand All @@ -24,9 +23,7 @@ async def _init_vendor(root_body: str) -> str:
logger = MagicMock(spec=logging.Logger)
bf = Badfish("test_host", "user", "pass", logger, 1)
bf.http_client = MagicMock()
bf.http_client.get_request = AsyncMock(
side_effect=[_make_resp(root_body), _make_resp(MAN_RESP)]
)
bf.http_client.get_request = AsyncMock(side_effect=[_make_resp(root_body), _make_resp(MAN_RESP)])
await bf.find_managers_resource()
return bf.vendor

Expand All @@ -42,18 +39,14 @@ async def test_vendor_dell():

@pytest.mark.asyncio
async def test_vendor_supermicro():
root = (
'{"Managers":{"@odata.id":"/redfish/v1/Managers"},'
'"RedfishVersion":"1.0.2","Oem":{"Supermicro":{}}}'
)
root = '{"Managers":{"@odata.id":"/redfish/v1/Managers"},' '"RedfishVersion":"1.0.2","Oem":{"Supermicro":{}}}'
assert await _init_vendor(root) == "Supermicro"


@pytest.mark.asyncio
async def test_vendor_hpe():
root = (
'{"Managers":{"@odata.id":"/redfish/v1/Managers"},'
'"RedfishVersion":"1.0.2","Oem":{"Hpe":{"Manager":[{}]}}}'
'{"Managers":{"@odata.id":"/redfish/v1/Managers"},' '"RedfishVersion":"1.0.2","Oem":{"Hpe":{"Manager":[{}]}}}'
)
assert await _init_vendor(root) == "HPE"

Expand All @@ -65,8 +58,5 @@ async def test_vendor_unknown_oem():

@pytest.mark.asyncio
async def test_vendor_no_oem():
root = (
'{"Managers":{"@odata.id":"/redfish/v1/Managers"},'
'"RedfishVersion":"1.0.2"}'
)
root = '{"Managers":{"@odata.id":"/redfish/v1/Managers"},' '"RedfishVersion":"1.0.2"}'
assert await _init_vendor(root) == "Unknown"
Loading