Search in sources :

Example 1 with DefaultCcmV2Parameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters in project cloudbreak by hortonworks.

the class DefaultCcmV2ParameterSupplier method getCcmV2Parameters.

public CcmV2Parameters getCcmV2Parameters(@Nonnull String accountId, @Nonnull Optional<String> environmentCrnOpt, @Nonnull String clusterGatewayDomain, @Nonnull String agentKeyId) {
    InvertingProxyAndAgent invertingProxyAndAgent = getInvertingProxyAndAgent(accountId, environmentCrnOpt, clusterGatewayDomain, agentKeyId);
    InvertingProxy invertingProxy = invertingProxyAndAgent.getInvertingProxy();
    InvertingProxyAgent invertingProxyAgent = invertingProxyAndAgent.getInvertingProxyAgent();
    LOGGER.debug("CcmV2Config successfully retrieved InvertingProxyHost: '{}', InvertingProxyStatus: '{}', InvertingProxyAgentCrn: '{}', " + "EnvironmentCrnOpt: '{}'", invertingProxy.getHostname(), invertingProxy.getStatus(), invertingProxyAgent.getAgentCrn(), Optional.of(invertingProxyAgent.getEnvironmentCrn()));
    return new DefaultCcmV2Parameters(invertingProxy.getHostname(), invertingProxy.getCertificate(), invertingProxyAgent.getAgentCrn(), agentKeyId, invertingProxyAgent.getEncipheredPrivateKey(), invertingProxyAgent.getCertificate());
}
Also used : InvertingProxyAgent(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent) InvertingProxy(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters)

Example 2 with DefaultCcmV2Parameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters in project cloudbreak by hortonworks.

the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmV2IsEnabled.

@Test
public void testFetchAndSaveCcmParametersWhenCcmV2IsEnabled() {
    Stack stack = getAStack();
    stack.setTunnel(Tunnel.CCMV2);
    DefaultCcmV2Parameters defaultCcmV2Parameters = mock(DefaultCcmV2Parameters.class);
    when(ccmV2ParameterSupplier.getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString())).thenReturn(defaultCcmV2Parameters);
    when(defaultCcmV2Parameters.getAgentCrn()).thenReturn("testAgentCrn");
    when(hostDiscoveryService.determineGatewayFqdn(any(), any())).thenReturn("datahub.master0.cldr.work.site");
    CcmConnectivityParameters ccmParameters = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.fetchAndSaveCcmParameters(stack));
    assertEquals(CcmConnectivityMode.CCMV2, ccmParameters.getConnectivityMode(), "CCM V2 should be enabled.");
    assertEquals(defaultCcmV2Parameters, ccmParameters.getCcmV2Parameters(), "CCM V2 Parameters should match.");
    verify(ccmV2ParameterSupplier, times(1)).getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString());
    verifyNoInteractions(ccmParameterSupplier);
    verify(stackService, times(1)).setCcmV2AgentCrnByStackId(100L, "testAgentCrn");
    verify(stackService, never()).setMinaSshdServiceIdByStackId(any(), any());
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) Optional(java.util.Optional) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 3 with DefaultCcmV2Parameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters in project cloudbreak by hortonworks.

the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmV2IsEnabled.

@Test
void testFetchAndSaveCcmParametersWhenCcmV2IsEnabled() {
    Stack stack = getAStack();
    stack.setTunnel(Tunnel.CCMV2);
    DefaultCcmV2Parameters defaultCcmV2Parameters = mock(DefaultCcmV2Parameters.class);
    FreeIpa freeIpa = mock(FreeIpa.class);
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    when(freeIpa.getDomain()).thenReturn("cldr.work.site");
    when(ccmV2ParameterSupplier.getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString())).thenReturn(defaultCcmV2Parameters);
    when(defaultCcmV2Parameters.getAgentCrn()).thenReturn("testAgentCrn");
    when(hostDiscoveryService.determineGatewayFqdn(any(), any())).thenReturn("datahub.master0.cldr.work.site");
    CcmConnectivityParameters ccmParameters = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.fetchAndSaveCcmParameters(stack));
    assertEquals(CcmConnectivityMode.CCMV2, ccmParameters.getConnectivityMode(), "CCM V2 should be enabled.");
    assertEquals(defaultCcmV2Parameters, ccmParameters.getCcmV2Parameters(), "CCM V2 Parameters should match.");
    verify(ccmV2ParameterSupplier, times(1)).getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString());
    verifyNoInteractions(ccmParameterSupplier);
    verify(stackService, times(1)).setCcmV2AgentCrnByStackId(100L, "testAgentCrn");
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) Optional(java.util.Optional) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 4 with DefaultCcmV2Parameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters in project cloudbreak by hortonworks.

the class UserDataBuilderTest method testBuildUserDataWithCCMV2.

@Test
public void testBuildUserDataWithCCMV2() throws IOException {
    CcmV2Parameters ccmV2Parameters = new DefaultCcmV2Parameters("invertingProxyHost", "invertingProxyCertificate", "agentCrn", "agentKeyId", "agentEncipheredPrivateKey", "agentCertificate");
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2Parameters);
    Map<InstanceGroupType, String> userdata = underTest.buildUserData(Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", getPlatformParameters(), "pass", "cert", ccmConnectivityParameters, null);
    String expectedCoreScript = FileReaderUtils.readFileFromClasspath("azure-core-ccm-init.sh");
    String expectedGwScript = FileReaderUtils.readFileFromClasspath("azure-gateway-ccm-v2-init.sh");
    Assert.assertEquals(expectedCoreScript, userdata.get(InstanceGroupType.CORE));
    Assert.assertEquals(expectedGwScript, userdata.get(InstanceGroupType.GATEWAY));
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters) CcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters) Test(org.junit.Test)

Example 5 with DefaultCcmV2Parameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters in project cloudbreak by hortonworks.

the class UserDataBuilderTest method testBuildUserDataWithCCMV2Params.

@Test
@DisplayName("test if CCM V2 parameters are passed the user data contains them")
void testBuildUserDataWithCCMV2Params() throws IOException {
    CcmV2Parameters ccmV2Parameters = new DefaultCcmV2Parameters("invertingProxyHost", "invertingProxyCertificate", "agentCrn", "agentKeyId", "agentEncipheredPrivateKey", "agentCertificate");
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2Parameters);
    PlatformParameters platformParameters = mock(PlatformParameters.class);
    ScriptParams scriptParams = mock(ScriptParams.class);
    when(scriptParams.getDiskPrefix()).thenReturn("sd");
    when(scriptParams.getStartLabel()).thenReturn(98);
    when(platformParameters.scriptParams()).thenReturn(scriptParams);
    String userData = underTest.buildUserData(ACCOUNT_ID, environment, Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", platformParameters, "pass", "cert", ccmConnectivityParameters, null);
    String expectedUserData = FileReaderUtils.readFileFromClasspath("azure-ccm-v2-init.sh");
    assertEquals(expectedUserData, userData);
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters) ScriptParams(com.sequenceiq.cloudbreak.cloud.model.ScriptParams) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) CcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

DefaultCcmV2Parameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters)5 CcmConnectivityParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters)4 Test (org.junit.jupiter.api.Test)3 CcmV2Parameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters)2 Optional (java.util.Optional)2 InvertingProxy (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy)1 InvertingProxyAgent (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent)1 PlatformParameters (com.sequenceiq.cloudbreak.cloud.PlatformParameters)1 ScriptParams (com.sequenceiq.cloudbreak.cloud.model.ScriptParams)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)1 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)1 Stack (com.sequenceiq.freeipa.entity.Stack)1 Test (org.junit.Test)1 DisplayName (org.junit.jupiter.api.DisplayName)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1