use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method updateDnsSoaRecordsAction.
@Bean(name = "DOWNSCALE_UPDATE_DNS_SOA_RECORDS_STATE")
public Action<?, ?> updateDnsSoaRecordsAction() {
return new AbstractDownscaleAction<>(RemoveDnsResponse.class) {
@Override
protected void doExecute(StackContext context, RemoveDnsResponse payload, Map<Object, Object> variables) {
stackUpdater.updateStackStatus(context.getStack().getId(), getInProgressStatus(variables), "Update DNS SOA records");
CleanupEvent cleanupEvent = buildCleanupEvent(context, getDownscaleHosts(variables));
UpdateDnsSoaRecordsRequest request = new UpdateDnsSoaRecordsRequest(cleanupEvent);
sendEvent(context, request);
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse 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.dns.RemoveDnsResponse in project cloudbreak by hortonworks.
the class FreeIpaCleanupActions method removeVaultEntriesAction.
@Bean(name = "REMOVE_VAULT_ENTRIES_STATE")
public Action<?, ?> removeVaultEntriesAction() {
return new AbstractFreeIpaCleanupAction<>(RemoveDnsResponse.class) {
@Override
protected void doExecute(FreeIpaContext context, RemoveDnsResponse payload, Map<Object, Object> variables) {
if (shouldSkipState(payload, variables) || payload.getHosts() == null || payload.getHosts().isEmpty()) {
LOGGER.info("Host is empty, skipping removing vault entries");
RemoveVaultEntriesResponse response = new RemoveVaultEntriesResponse(payload, Collections.emptySet(), Collections.emptyMap());
sendEvent(context, response);
} else {
RemoveVaultEntriesRequest request = new RemoveVaultEntriesRequest(payload, context.getStack());
sendEvent(context, request);
}
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse in project cloudbreak by hortonworks.
the class RemoveDnsResponseToCleanupFailureEventConverter method convert.
@Override
public CleanupFailureEvent convert(Object payload) {
RemoveDnsResponse removeDnsResponse = (RemoveDnsResponse) payload;
CleanupFailureEvent event = new CleanupFailureEvent(removeDnsResponse, "DNS record removal", removeDnsResponse.getDnsCleanupFailed(), removeDnsResponse.getDnsCleanupSuccess());
return event;
}
use of com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse in project cloudbreak by hortonworks.
the class DnsRemoveHandler method accept.
@Override
public void accept(Event<RemoveDnsRequest> event) {
RemoveDnsRequest request = event.getData();
try {
FreeIpa freeIpa = freeIpaService.findByStackId(request.getResourceId());
Pair<Set<String>, Map<String, String>> removeDnsResult = cleanupService.removeDnsEntries(request.getResourceId(), request.getHosts(), request.getIps(), freeIpa.getDomain());
RemoveDnsResponse response = new RemoveDnsResponse(request, removeDnsResult.getFirst(), removeDnsResult.getSecond());
eventBus.notify(response.getDnsCleanupFailed().isEmpty() ? EventSelectorUtil.selector(RemoveDnsResponse.class) : EventSelectorUtil.failureSelector(RemoveDnsResponse.class), new Event<>(event.getHeaders(), response));
} catch (Exception e) {
LOGGER.error("Removing DNS entries failed for hosts: [{}]", request.getHosts(), e);
Map<String, String> failureResult = request.getHosts().stream().collect(Collectors.toMap(h -> h, h -> e.getMessage()));
RemoveDnsResponse response = new RemoveDnsResponse(request, Collections.emptySet(), failureResult);
eventBus.notify(EventSelectorUtil.failureSelector(RemoveDnsResponse.class), new Event<>(event.getHeaders(), response));
}
}
Aggregations