Search in sources :

Example 1 with RemoveDnsResponse

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);
        }
    };
}
Also used : RemoveDnsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) CleanupEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent) UpdateDnsSoaRecordsRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 2 with RemoveDnsResponse

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);
            }
        }
    };
}
Also used : RemoveDnsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse) RemoveHostsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.host.RemoveHostsResponse) RemoveDnsRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsRequest) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 3 with RemoveDnsResponse

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);
            }
        }
    };
}
Also used : RemoveDnsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse) RemoveVaultEntriesRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.vault.RemoveVaultEntriesRequest) RemoveVaultEntriesResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.vault.RemoveVaultEntriesResponse) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 4 with RemoveDnsResponse

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;
}
Also used : RemoveDnsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse)

Example 5 with RemoveDnsResponse

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));
    }
}
Also used : RemoveDnsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse) Set(java.util.Set) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) RemoveDnsRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsRequest) Event(reactor.bus.Event) Map(java.util.Map)

Aggregations

RemoveDnsResponse (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse)6 Map (java.util.Map)4 Bean (org.springframework.context.annotation.Bean)3 RemoveDnsRequest (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsRequest)2 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)1 CleanupEvent (com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent)1 RemoveHostsResponse (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.host.RemoveHostsResponse)1 RemoveVaultEntriesRequest (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.vault.RemoveVaultEntriesRequest)1 RemoveVaultEntriesResponse (com.sequenceiq.freeipa.flow.freeipa.cleanup.event.vault.RemoveVaultEntriesResponse)1 DownscaleFailureEvent (com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent)1 UpdateDnsSoaRecordsRequest (com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest)1 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)1 Set (java.util.Set)1 Event (reactor.bus.Event)1