Search in sources :

Example 1 with TunnelEntry

use of com.sequenceiq.cloudbreak.clusterproxy.TunnelEntry in project cloudbreak by hortonworks.

the class ClusterProxyService method tunnelEntries.

private List<TunnelEntry> tunnelEntries(Stack stack) {
    List<TunnelEntry> entries = new ArrayList<>();
    stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata().forEach(md -> {
        String gatewayIp = md.getPrivateIp();
        TunnelEntry gatewayTunnel = new TunnelEntry(md.getInstanceId(), KnownServiceIdentifier.GATEWAY.name(), gatewayIp, ServiceFamilies.GATEWAY.getDefaultPort(), stack.getMinaSshdServiceId());
        TunnelEntry knoxTunnel = new TunnelEntry(md.getInstanceId(), KnownServiceIdentifier.KNOX.name(), gatewayIp, ServiceFamilies.KNOX.getDefaultPort(), stack.getMinaSshdServiceId());
        entries.add(gatewayTunnel);
        entries.add(knoxTunnel);
    });
    return entries;
}
Also used : ArrayList(java.util.ArrayList) TunnelEntry(com.sequenceiq.cloudbreak.clusterproxy.TunnelEntry)

Example 2 with TunnelEntry

use of com.sequenceiq.cloudbreak.clusterproxy.TunnelEntry in project cloudbreak by hortonworks.

the class ClusterProxyServiceTest method testClusterProxyRegistrationWhenCCMV1.

@Test
public void testClusterProxyRegistrationWhenCCMV1() {
    Stack aStack = getAStack();
    aStack.setTunnel(Tunnel.CCM);
    aStack.setMinaSshdServiceId("minaSshdServiceId");
    GatewayConfig gatewayConfig = new GatewayConfig("connectionAddress", "publicAddress", PRIVATE_ADDRESS, 9443, "instanceId", false);
    ConfigRegistrationResponse configRegResponse = mock(ConfigRegistrationResponse.class);
    FreeIpa freeIpa = new FreeIpa();
    freeIpa.setDomain("ipadom");
    when(stackService.getStackById(STACK_ID)).thenReturn(aStack);
    when(clusterProxyEnablementService.isClusterProxyApplicable(any())).thenReturn(true);
    when(gatewayConfigService.getPrimaryGatewayConfig(aStack)).thenReturn(gatewayConfig);
    when(securityConfigService.findOneByStack(aStack)).thenReturn(null);
    when(clusterProxyRegistrationClient.registerConfig(any())).thenReturn(configRegResponse);
    when(stackUpdater.updateClusterProxyRegisteredFlag(aStack, true)).thenReturn(aStack);
    when(freeIpaService.findByStack(aStack)).thenReturn(freeIpa);
    underTest.registerFreeIpaForBootstrap(STACK_ID);
    ArgumentCaptor<ConfigRegistrationRequest> captor = ArgumentCaptor.forClass(ConfigRegistrationRequest.class);
    verify(clusterProxyRegistrationClient).registerConfig(captor.capture());
    ConfigRegistrationRequest proxyRegistrationReq = captor.getValue();
    assertThat(proxyRegistrationReq.getClusterCrn()).isEqualTo(STACK_RESOURCE_CRN);
    assertThat(proxyRegistrationReq.getAccountId()).isEqualTo(TEST_ACCOUNT_ID);
    assertFalse(proxyRegistrationReq.isUseCcmV2(), "CCMV2 should not be enabled.");
    assertTrue(proxyRegistrationReq.isUseTunnel(), "CCMV1 tunnel should be enabled");
    assertEquals(List.of(new TunnelEntry("instanceId", "GATEWAY", PRIVATE_ADDRESS, 9443, "minaSshdServiceId")), proxyRegistrationReq.getTunnels(), "CCMV1 tunnel should be configured.");
    assertThat(proxyRegistrationReq.getServices()).contains(new ClusterServiceConfig("freeipa", List.of("https://privateAddress:9443"), List.of(), null));
    assertThat(proxyRegistrationReq.getServices()).contains(new ClusterServiceConfig("freeipa.ipadom", List.of("https://privateAddress:9443"), List.of(), null));
}
Also used : FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) ConfigRegistrationResponse(com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationResponse) ClusterServiceConfig(com.sequenceiq.cloudbreak.clusterproxy.ClusterServiceConfig) ConfigRegistrationRequest(com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequest) Stack(com.sequenceiq.freeipa.entity.Stack) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) TunnelEntry(com.sequenceiq.cloudbreak.clusterproxy.TunnelEntry) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

TunnelEntry (com.sequenceiq.cloudbreak.clusterproxy.TunnelEntry)2 ClusterServiceConfig (com.sequenceiq.cloudbreak.clusterproxy.ClusterServiceConfig)1 ConfigRegistrationRequest (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationRequest)1 ConfigRegistrationResponse (com.sequenceiq.cloudbreak.clusterproxy.ConfigRegistrationResponse)1 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)1 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1