@@ -902,12 +902,14 @@ def flush(module, bmc):
902
902
:param bmc: A dracclient.client.DRACClient instance
903
903
"""
904
904
debug (module , "Flushing BIOS and/or RAID settings by rebooting" )
905
- # Reboot the node.
905
+ current_state = bmc .get_power_state ()
906
+ goal_state = 'POWER_ON' if current_state == 'POWER_OFF' else 'REBOOT'
907
+ # Reboot or power on the node.
906
908
try :
907
- bmc .set_power_state ('REBOOT' )
909
+ bmc .set_power_state (goal_state )
908
910
except drac_exc .BaseClientException as e :
909
- module .fail_json (msg = "Failed to reboot to apply pending BIOS "
910
- "settings: %s" % repr (e ))
911
+ module .fail_json (msg = "Failed to set power state to %s to apply "
912
+ "pending BIOS settings: %s" % ( goal_state , repr (e ) ))
911
913
912
914
# Wait for the reboot to flush pending jobs.
913
915
try :
@@ -916,6 +918,14 @@ def flush(module, bmc):
916
918
module .fail_json (msg = "Failed waiting for reboot to flush "
917
919
"pending BIOS settings: %s" % repr (e ))
918
920
921
+ # Power off the node if it was previously powered off.
922
+ if current_state == 'POWER_OFF' :
923
+ try :
924
+ bmc .set_power_state ('POWER_OFF' )
925
+ except drac_exc .BaseClientException as e :
926
+ module .fail_json (msg = "Failed to set power state to off: %s"
927
+ % repr (e ))
928
+
919
929
920
930
def abandon_bios (module , bmc ):
921
931
"""Abandon uncommitted pending BIOS configuration changes.
0 commit comments