Skip to content

Commit beb712e

Browse files
committed
Accept HTTP 400 status code for Redfish fencing when host is already off
Some Redfish implementations (e.g., HPE iLo on ProLiant DL360 Gen11) return HTTP 400 Bad Request when attempting to power off a host that is already powered off, while others (e.g., Dell iDRAC) return HTTP 409 Conflict. This commit extends the existing 409 handling to also accept 400 status code, ensuring InstanceHA works correctly with HPE iLo and other vendors that return 400 in this scenario. The code now: - Checks if the server is already powered off when receiving 400 or 409 - Verifies the actual power state via Redfish API - Considers the fencing successful if the host is already OFF - Provides improved logging that includes the status code in error cases This fixes the issue where InstanceHA would fail to proceed with evacuation when a host is already powered off on HPE ProLiant servers.
1 parent 04d2def commit beb712e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

templates/instanceha/bin/instanceha.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,17 +686,18 @@ def _host_fence(host, action):
686686
return True
687687
logging.error('Power off of %s timed out' % host)
688688
return False
689-
elif r.status_code == 409:
689+
elif r.status_code in [400, 409]:
690690
# Check if server is already powered off
691+
# Some vendors (e.g., HPE iLo) return 400, others (e.g., Dell iDRAC) return 409
691692
power_state = _redfish_get_power_state(url, user, passwd, timeout)
692693
if power_state == 'OFF':
693694
logging.info('Power off of %s ok (already off)' % host)
694695
return True
695696
else:
696-
logging.error('Could not power off %s (409 but not OFF: %s)' % (host, power_state))
697+
logging.error('Could not power off %s (%d but not OFF: %s)' % (host, r.status_code, power_state))
697698
return False
698699
else:
699-
logging.error('Could not power off %s' % host)
700+
logging.error('Could not power off %s (status code: %d)' % (host, r.status_code))
700701
return False
701702
else:
702703
r = _redfish_reset(url, user, passwd, timeout, "On")

0 commit comments

Comments
 (0)