use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest 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.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest in project cloudbreak by hortonworks.
the class UpdateDnsSoaRecordsHandlerTest method testResultContainsServerFqdns.
@Test
void testResultContainsServerFqdns() throws Exception {
String zoneName = "example.com.";
String fqdn1 = "foo1.example.com";
String fqdn2 = "foo2.example.com";
FreeIpaClient mockIpaClient = mock(FreeIpaClient.class);
IpaServer mockIpaServer1 = mock(IpaServer.class);
IpaServer mockIpaServer2 = mock(IpaServer.class);
DnsZone dnsZone = mock(DnsZone.class);
when(freeIpaClientFactory.getFreeIpaClientForStackId(any())).thenReturn(mockIpaClient);
when(mockIpaClient.findAllServers()).thenReturn(Set.of(mockIpaServer1, mockIpaServer2));
Mockito.lenient().when(mockIpaServer1.getFqdn()).thenReturn(fqdn1);
when(mockIpaServer2.getFqdn()).thenReturn(fqdn2);
when(mockIpaClient.findAllDnsZone()).thenReturn(Set.of(dnsZone));
when(dnsZone.getIdnssoamname()).thenReturn(fqdn1 + ".");
when(dnsZone.getIdnsname()).thenReturn(zoneName);
CleanupEvent cleanupEvent = new CleanupEvent(1L, Set.of(), Set.of(fqdn1), Set.of(), Set.of(), Set.of(), "", "", "", "");
UpdateDnsSoaRecordsRequest request = new UpdateDnsSoaRecordsRequest(cleanupEvent);
underTest.accept(new Event<>(request));
verify(eventBus).notify(eq("UPDATEDNSSOARECORDSRESPONSE"), any(Event.class));
verify(mockIpaClient).setDnsZoneAuthoritativeNameserver(eq(zoneName), eq(fqdn2 + "."));
}
use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest in project cloudbreak by hortonworks.
the class UpdateDnsSoaRecordsHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<UpdateDnsSoaRecordsRequest> event) {
UpdateDnsSoaRecordsRequest request = event.getData();
Selectable result;
try {
Long stackId = request.getResourceId();
Set<String> fqdns = request.getHosts().stream().map(hostname -> StringUtils.appendIfMissing(hostname, ".")).collect(Collectors.toSet());
updateSoaRecords(stackId, fqdns);
result = new UpdateDnsSoaRecordsResponse(request.getResourceId());
} catch (Exception e) {
LOGGER.error("Downscale updating DNS SOA records failed", e);
result = new DownscaleFailureEvent(DOWNSCALE_UPDATE_DNS_SOA_RECORDS_FAILED_EVENT.event(), request.getResourceId(), "Downscale Update DNS SOA Records", Set.of(), Map.of(), e);
}
return result;
}
Aggregations