Skip to content

Commit 823111d

Browse files
Create Event in case of OOBM failure (#4418)
1 parent 5f8289f commit 823111d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

server/src/main/java/org/apache/cloudstack/outofbandmanagement/PowerOperationTask.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717

1818
package org.apache.cloudstack.outofbandmanagement;
1919

20+
import com.cloud.event.ActionEventUtils;
21+
import com.cloud.event.EventTypes;
22+
import com.cloud.event.EventVO;
2023
import com.cloud.host.Host;
24+
import org.apache.cloudstack.context.CallContext;
2125
import org.apache.log4j.Logger;
2226

2327
public class PowerOperationTask implements Runnable {
@@ -43,8 +47,14 @@ public void run() {
4347
try {
4448
service.executePowerOperation(host, powerOperation, null);
4549
} catch (Exception e) {
46-
LOG.warn(String.format("Out-of-band management background task operation=%s for host id=%d failed with: %s",
47-
powerOperation.name(), host.getId(), e.getMessage()));
50+
LOG.warn(String.format("Out-of-band management background task operation=%s for host %s failed with: %s",
51+
powerOperation.name(), host.getName(), e.getMessage()));
52+
53+
String eventMessage = String
54+
.format("Error while issuing out-of-band management action %s for host: %s", powerOperation.name(), host.getName());
55+
56+
ActionEventUtils.onCreatedActionEvent(CallContext.current().getCallingUserId(), CallContext.current().getCallingAccountId(), EventVO.LEVEL_WARN,
57+
EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ACTION, true, eventMessage);
4858
}
4959
}
5060
}

0 commit comments

Comments
 (0)