Search in sources :

Example 1 with CcmParameters

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

the class CcmUserDataService method getCcmConnectivityParameters.

private CcmConnectivityParameters getCcmConnectivityParameters(Stack stack, String keyId) {
    CcmConnectivityParameters ccmConnectivityParameters;
    String actorCrn = Objects.requireNonNull(crnService.getUserCrn(), "userCrn is null");
    int gatewayPort = Optional.ofNullable(stack.getGatewayport()).orElse(ServiceFamilies.GATEWAY.getDefaultPort());
    Map<KnownServiceIdentifier, Integer> tunneledServicePorts = Collections.singletonMap(KnownServiceIdentifier.GATEWAY, gatewayPort);
    CcmParameters ccmV1Parameters = ccmParameterSupplier.getCcmParameters(actorCrn, stack.getAccountId(), keyId, tunneledServicePorts).orElse(null);
    ccmConnectivityParameters = new CcmConnectivityParameters(ccmV1Parameters);
    saveCcmV1Config(stack.getId(), ccmV1Parameters);
    return ccmConnectivityParameters;
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) KnownServiceIdentifier(com.sequenceiq.cloudbreak.ccm.endpoint.KnownServiceIdentifier) CcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmParameters)

Example 2 with CcmParameters

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

the class CcmUserDataService method getCcmConnectivityParameters.

private CcmConnectivityParameters getCcmConnectivityParameters(Stack stack) {
    CcmConnectivityParameters ccmConnectivityParameters;
    String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
    String actorCrn = Objects.requireNonNull(userCrn, "userCrn is null");
    ImmutableMap.Builder<KnownServiceIdentifier, Integer> builder = ImmutableMap.builder();
    int gatewayPort = Optional.ofNullable(stack.getGatewayPort()).orElse(ServiceFamilies.GATEWAY.getDefaultPort());
    builder.put(KnownServiceIdentifier.GATEWAY, gatewayPort);
    // Optionally configure a tunnel for (nginx fronting) Knox
    if (stack.getCluster().getGateway() != null) {
        // JSA TODO Do we support a non-default port for the nginx that fronts Knox?
        builder.put(KnownServiceIdentifier.KNOX, ServiceFamilies.KNOX.getDefaultPort());
    }
    Map<KnownServiceIdentifier, Integer> tunneledServicePorts = builder.build();
    CcmParameters ccmV1Parameters = ccmParameterSupplier.getCcmParameters(actorCrn, ThreadBasedUserCrnProvider.getAccountId(), CcmResourceUtil.getKeyId(stack.getResourceCrn()), tunneledServicePorts).orElse(null);
    ccmConnectivityParameters = new CcmConnectivityParameters(ccmV1Parameters);
    saveCcmV1Config(stack.getId(), ccmV1Parameters);
    return ccmConnectivityParameters;
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) KnownServiceIdentifier(com.sequenceiq.cloudbreak.ccm.endpoint.KnownServiceIdentifier) CcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmParameters) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 3 with CcmParameters

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

the class UserDataBuilderTest method testBuildUserDataWithCCM.

@Test
public void testBuildUserDataWithCCM() throws IOException {
    BaseServiceEndpoint serviceEndpoint = new BaseServiceEndpoint(new HostEndpoint("ccm.cloudera.com"));
    DefaultServerParameters serverParameters = new DefaultServerParameters(serviceEndpoint, "pub-key", "mina-id");
    DefaultInstanceParameters instanceParameters = new DefaultInstanceParameters("tunnel-id", "key-id", "private-key");
    DefaultTunnelParameters nginxTunnel = new DefaultTunnelParameters(KnownServiceIdentifier.GATEWAY, 9443);
    DefaultTunnelParameters knoxTunnel = new DefaultTunnelParameters(KnownServiceIdentifier.KNOX, 8443);
    CcmParameters ccmParameters = new DefaultCcmParameters(serverParameters, instanceParameters, List.of(nginxTunnel, knoxTunnel));
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmParameters);
    Map<InstanceGroupType, String> userdata = underTest.buildUserData(Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", getPlatformParameters(), "pass", "cert", ccmConnectivityParameters, null);
    String expectedGwScript = FileReaderUtils.readFileFromClasspath("azure-gateway-ccm-init.sh");
    String expectedCoreScript = FileReaderUtils.readFileFromClasspath("azure-core-ccm-init.sh");
    Assert.assertEquals(expectedGwScript, userdata.get(InstanceGroupType.GATEWAY));
    Assert.assertEquals(expectedCoreScript, userdata.get(InstanceGroupType.CORE));
}
Also used : DefaultCcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmParameters) CcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmParameters) CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) DefaultCcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmParameters) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) BaseServiceEndpoint(com.sequenceiq.cloudbreak.ccm.endpoint.BaseServiceEndpoint) DefaultInstanceParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultInstanceParameters) HostEndpoint(com.sequenceiq.cloudbreak.ccm.endpoint.HostEndpoint) DefaultServerParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultServerParameters) DefaultTunnelParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultTunnelParameters) Test(org.junit.Test)

Example 4 with CcmParameters

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

the class UserDataBuilderTest method testBuildUserDataWithCCMParams.

@Test
@DisplayName("test if CCM parameters are passed the user data contains them")
void testBuildUserDataWithCCMParams() throws IOException {
    BaseServiceEndpoint serviceEndpoint = new BaseServiceEndpoint(new HostEndpoint("ccm.cloudera.com"));
    DefaultServerParameters serverParameters = new DefaultServerParameters(serviceEndpoint, "pub-key", "mina-id");
    DefaultInstanceParameters instanceParameters = new DefaultInstanceParameters("tunnel-id", "key-id", "private-key");
    DefaultTunnelParameters nginxTunnel = new DefaultTunnelParameters(KnownServiceIdentifier.GATEWAY, 9443);
    CcmParameters ccmParameters = new DefaultCcmParameters(serverParameters, instanceParameters, List.of(nginxTunnel));
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmParameters);
    ProxyAuthentication proxyAuthentication = ProxyAuthentication.builder().withUserName("user").withPassword("pwd").build();
    ProxyConfig proxyConfig = ProxyConfig.builder().withServerHost("proxy.host").withServerPort(1234).withProxyAuthentication(proxyAuthentication).withNoProxyHosts("noproxy.com").withProtocol("https").build();
    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, proxyConfig);
    String expectedUserData = FileReaderUtils.readFileFromClasspath("azure-ccm-init.sh");
    assertEquals(expectedUserData, userData);
}
Also used : DefaultCcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmParameters) ProxyAuthentication(com.sequenceiq.cloudbreak.dto.ProxyAuthentication) ScriptParams(com.sequenceiq.cloudbreak.cloud.model.ScriptParams) ProxyConfig(com.sequenceiq.cloudbreak.dto.ProxyConfig) DefaultCcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmParameters) CcmParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmParameters) CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) BaseServiceEndpoint(com.sequenceiq.cloudbreak.ccm.endpoint.BaseServiceEndpoint) DefaultInstanceParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultInstanceParameters) HostEndpoint(com.sequenceiq.cloudbreak.ccm.endpoint.HostEndpoint) DefaultServerParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultServerParameters) DefaultTunnelParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultTunnelParameters) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

CcmConnectivityParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters)4 CcmParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmParameters)4 DefaultCcmParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmParameters)2 DefaultInstanceParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultInstanceParameters)2 DefaultServerParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultServerParameters)2 DefaultTunnelParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultTunnelParameters)2 BaseServiceEndpoint (com.sequenceiq.cloudbreak.ccm.endpoint.BaseServiceEndpoint)2 HostEndpoint (com.sequenceiq.cloudbreak.ccm.endpoint.HostEndpoint)2 KnownServiceIdentifier (com.sequenceiq.cloudbreak.ccm.endpoint.KnownServiceIdentifier)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 PlatformParameters (com.sequenceiq.cloudbreak.cloud.PlatformParameters)1 ScriptParams (com.sequenceiq.cloudbreak.cloud.model.ScriptParams)1 ProxyAuthentication (com.sequenceiq.cloudbreak.dto.ProxyAuthentication)1 ProxyConfig (com.sequenceiq.cloudbreak.dto.ProxyConfig)1 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)1 Test (org.junit.Test)1 DisplayName (org.junit.jupiter.api.DisplayName)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1