use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.host.RemoveHostsResponse in project cloudbreak by hortonworks.
the class RemoveHostsResponseToDownscaleFailureEventConverter method convert.
@Override
public DownscaleFailureEvent convert(Object payload) {
RemoveHostsResponse removeHostsResponse = (RemoveHostsResponse) payload;
DownscaleFailureEvent event = new DownscaleFailureEvent(removeHostsResponse.getResourceId(), "Hosts removal", removeHostsResponse.getHostCleanupSuccess(), removeHostsResponse.getHostCleanupFailed(), new Exception("Payload failed: " + payload));
return event;
}
use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.host.RemoveHostsResponse in project cloudbreak by hortonworks.
the class FreeIpaCleanupActions method removeHostsAction.
@Bean(name = "REMOVE_HOSTS_STATE")
public Action<?, ?> removeHostsAction() {
return new AbstractFreeIpaCleanupAction<>(RevokeCertsResponse.class) {
@Override
protected void doExecute(FreeIpaContext context, RevokeCertsResponse payload, Map<Object, Object> variables) {
if (shouldSkipState(payload, variables) || payload.getHosts() == null || payload.getHosts().isEmpty()) {
LOGGER.info("Host is empty, skipping removing hosts");
RemoveHostsResponse response = new RemoveHostsResponse(payload, Collections.emptySet(), Collections.emptyMap());
sendEvent(context, response);
} else {
RemoveHostsRequest request = new RemoveHostsRequest(payload, context.getStack());
sendEvent(context, request);
}
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.host.RemoveHostsResponse in project cloudbreak by hortonworks.
the class FreeIpaCleanupActions method removeDnsEntriesAction.
@Bean(name = "REMOVE_DNS_ENTRIES_STATE")
public Action<?, ?> removeDnsEntriesAction() {
return new AbstractFreeIpaCleanupAction<>(RemoveHostsResponse.class) {
@Override
protected void doExecute(FreeIpaContext context, RemoveHostsResponse payload, Map<Object, Object> variables) {
if (shouldSkipState(payload, variables) || (payload.getHosts() == null || payload.getHosts().isEmpty()) && (payload.getIps() == null || payload.getIps().isEmpty())) {
LOGGER.info("Host is empty, skipping removing hosts");
RemoveDnsResponse response = new RemoveDnsResponse(payload, Collections.emptySet(), Collections.emptyMap());
sendEvent(context, response);
} else {
RemoveDnsRequest request = new RemoveDnsRequest(payload);
sendEvent(context, request);
}
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.host.RemoveHostsResponse in project cloudbreak by hortonworks.
the class RemoveHostsResponseToCleanupFailureEventConverter method convert.
@Override
public CleanupFailureEvent convert(Object payload) {
RemoveHostsResponse removeHostsResponse = (RemoveHostsResponse) payload;
CleanupFailureEvent event = new CleanupFailureEvent(removeHostsResponse, "Hosts removal", removeHostsResponse.getHostCleanupFailed(), removeHostsResponse.getHostCleanupSuccess());
return event;
}
use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.host.RemoveHostsResponse in project cloudbreak by hortonworks.
the class HostRemoveHandler method accept.
@Override
public void accept(Event<RemoveHostsRequest> event) {
RemoveHostsRequest request = event.getData();
try {
Pair<Set<String>, Map<String, String>> removeHostsResult = cleanupService.removeHosts(request.getResourceId(), request.getHosts());
RemoveHostsResponse response = new RemoveHostsResponse(request, removeHostsResult.getFirst(), removeHostsResult.getSecond());
eventBus.notify(response.getHostCleanupFailed().isEmpty() ? EventSelectorUtil.selector(RemoveHostsResponse.class) : EventSelectorUtil.failureSelector(RemoveHostsResponse.class), new Event<>(event.getHeaders(), response));
} catch (Exception e) {
LOGGER.error("Removing failed for hosts: [{}]", request.getHosts(), e);
Map<String, String> failureResult = request.getHosts().stream().collect(Collectors.toMap(h -> h, h -> e.getMessage()));
RemoveHostsResponse response = new RemoveHostsResponse(request, Collections.emptySet(), failureResult);
eventBus.notify(EventSelectorUtil.failureSelector(RemoveHostsResponse.class), new Event<>(event.getHeaders(), response));
}
}
Aggregations