@@ -47,7 +47,7 @@ public final class KVMHAProvider extends HAAbstractHostProvider implements HAPro
4747
4848 @ Override
4949 public boolean isEligible (final Host host ) {
50- if (outOfBandManagementService .isOutOfBandManagementEnabled (host )){
50+ if (outOfBandManagementService .isOutOfBandManagementEnabled (host )) {
5151 return !isInMaintenanceMode (host ) && !isDisabled (host ) &&
5252 hostActivityChecker .getNeighbors (host ).length > 0 &&
5353 (Hypervisor .HypervisorType .KVM .equals (host .getHypervisorType ()) ||
@@ -57,45 +57,54 @@ public boolean isEligible(final Host host) {
5757 }
5858
5959 @ Override
60- public boolean isHealthy (final Host r ) throws HACheckerException {
61- return hostActivityChecker .isHealthy (r );
60+ public boolean isHealthy (final Host host ) throws HACheckerException {
61+ return hostActivityChecker .isHealthy (host );
6262 }
6363
6464 @ Override
65- public boolean hasActivity (final Host r , final DateTime suspectTime ) throws HACheckerException {
66- return hostActivityChecker .isActive (r , suspectTime );
65+ public boolean hasActivity (final Host host , final DateTime suspectTime ) throws HACheckerException {
66+ return hostActivityChecker .isActive (host , suspectTime );
6767 }
6868
6969 @ Override
70- public boolean recover (Host r ) throws HARecoveryException {
70+ public boolean recover (Host host ) throws HARecoveryException {
7171 try {
72- if (outOfBandManagementService .isOutOfBandManagementEnabled (r )) {
73- final OutOfBandManagementResponse resp = outOfBandManagementService .executePowerOperation (r , PowerOperation .RESET , null );
72+ if (outOfBandManagementService .isOutOfBandManagementEnabled (host )) {
73+ final OutOfBandManagementResponse resp = outOfBandManagementService .executePowerOperation (host , PowerOperation .RESET , null );
7474 return resp .getSuccess ();
7575 } else {
76- logger .warn ("OOBM recover operation failed for the host {}" , r );
76+ logger .warn ("OOBM recover operation failed for the host {}" , host );
7777 return false ;
7878 }
79- } catch (Exception e ){
80- logger .warn ("OOBM service is not configured or enabled for this host {} error is {}" , r , e .getMessage ());
81- throw new HARecoveryException (String .format (" OOBM service is not configured or enabled for this host %s" , r ), e );
79+ } catch (Exception e ) {
80+ String msg = "Failed to recover host " + host ;
81+ if (host != null && !outOfBandManagementService .isOutOfBandManagementEnabledForHost (host .getId ())) {
82+ msg = "OOBM service is not configured or enabled for this host " + host ;
83+ }
84+
85+ logger .warn ("{}, error is {}" , msg , e .getMessage ());
86+ throw new HARecoveryException (msg , e );
8287 }
8388 }
8489
8590 @ Override
86- public boolean fence (Host r ) throws HAFenceException {
87-
91+ public boolean fence (Host host ) throws HAFenceException {
8892 try {
89- if (outOfBandManagementService .isOutOfBandManagementEnabled (r )){
90- final OutOfBandManagementResponse resp = outOfBandManagementService .executePowerOperation (r , PowerOperation .OFF , null );
93+ if (outOfBandManagementService .isOutOfBandManagementEnabled (host )){
94+ final OutOfBandManagementResponse resp = outOfBandManagementService .executePowerOperation (host , PowerOperation .OFF , null );
9195 return resp .getSuccess ();
9296 } else {
93- logger .warn ("OOBM fence operation failed for this host {}" , r );
97+ logger .warn ("OOBM fence operation failed for this host {}" , host );
9498 return false ;
9599 }
96- } catch (Exception e ){
97- logger .warn ("OOBM service is not configured or enabled for this host {} error is {}" , r , e .getMessage ());
98- throw new HAFenceException (String .format ("OBM service is not configured or enabled for this host %s" , r .getName ()), e );
100+ } catch (Exception e ) {
101+ String msg = "Failed to fence host " + host ;
102+ if (host != null && !outOfBandManagementService .isOutOfBandManagementEnabledForHost (host .getId ())) {
103+ msg = "OOBM service is not configured or enabled for this host " + host ;
104+ }
105+
106+ logger .warn ("{}, error is {}" , msg , e .getMessage ());
107+ throw new HAFenceException (msg , e );
99108 }
100109 }
101110
0 commit comments