use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.collecthostnames.CollectAdditionalHostnamesRequest in project cloudbreak by hortonworks.
the class FreeIpaDownscaleActions method downscaleCollectAdditionalHostnamesAction.
@Bean(name = "DOWNSCALE_COLLECT_ADDITIONAL_HOSTNAMES_STATE")
public Action<?, ?> downscaleCollectAdditionalHostnamesAction() {
return new AbstractDownscaleAction<>(ClusterProxyUpdateRegistrationSuccess.class) {
@Override
protected void doExecute(StackContext context, ClusterProxyUpdateRegistrationSuccess payload, Map<Object, Object> variables) throws Exception {
Stack stack = context.getStack();
stackUpdater.updateStackStatus(stack.getId(), getInProgressStatus(variables), "Collecting additional hostnames.");
CollectAdditionalHostnamesRequest request = new CollectAdditionalHostnamesRequest(stack.getId());
sendEvent(context, request.selector(), request);
}
};
}
use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.collecthostnames.CollectAdditionalHostnamesRequest in project cloudbreak by hortonworks.
the class CollectAdditionalHostnamesHandlerTest method testResultContainsServerFqdns.
@Test
void testResultContainsServerFqdns() throws Exception {
String fqdn1 = "foo1.example.com";
String fqdn2 = "foo2.example.com";
FreeIpaClient mockIpaClient = Mockito.mock(FreeIpaClient.class);
IpaServer mockIpaServer1 = Mockito.mock(IpaServer.class);
IpaServer mockIpaServer2 = Mockito.mock(IpaServer.class);
when(freeIpaClientFactory.getFreeIpaClientForStackId(any())).thenReturn(mockIpaClient);
when(mockIpaClient.findAllServers()).thenReturn(Set.of(mockIpaServer1, mockIpaServer2));
when(mockIpaServer1.getFqdn()).thenReturn(fqdn1);
when(mockIpaServer2.getFqdn()).thenReturn(fqdn2);
CollectAdditionalHostnamesRequest request = new CollectAdditionalHostnamesRequest(1L);
underTest.accept(new Event<>(request));
ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class);
verify(eventBus).notify(eq("COLLECTADDITIONALHOSTNAMESRESPONSE"), eventCaptor.capture());
Event event = eventCaptor.getValue();
assertTrue(event.getData() instanceof CollectAdditionalHostnamesResponse);
CollectAdditionalHostnamesResponse response = (CollectAdditionalHostnamesResponse) event.getData();
assertEquals(Set.of(fqdn1, fqdn2), response.getHostnames());
}
use of com.sequenceiq.freeipa.flow.freeipa.downscale.event.collecthostnames.CollectAdditionalHostnamesRequest in project cloudbreak by hortonworks.
the class CollectAdditionalHostnamesHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<CollectAdditionalHostnamesRequest> event) {
CollectAdditionalHostnamesRequest request = event.getData();
Selectable result;
try {
Long stackId = request.getResourceId();
Set<String> fqdns = getHostnamesFromFreeIpaServers(stackId);
result = new CollectAdditionalHostnamesResponse(request.getResourceId(), fqdns);
} catch (Exception e) {
LOGGER.error("Collecting additional hostnames failed", e);
result = new DownscaleFailureEvent(DOWNSCALE_COLLECT_ADDITIONAL_HOSTNAMES_FAILED_EVENT.event(), request.getResourceId(), "Downscale Collect Additional Hostnames", Set.of(), Map.of(), e);
}
return result;
}
Aggregations