Search in sources :

Example 6 with CcmConnectivityParameters

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

the class UserDataBuilderTest method testBuildUserDataWithCCMV2JumpgateParams.

@ParameterizedTest(name = "Forced TLS mode = {0}, entitlement = {1}, filename = {2}")
@MethodSource("tlsCases")
@DisplayName("test if CCM V2 Jumpgate parameters are passed the user data contains them")
void testBuildUserDataWithCCMV2JumpgateParams(CcmV2TlsType ccmV2TlsType, boolean oneWayTlsEntitlementEnabled, String expectedContentFileName) throws IOException {
    CcmV2JumpgateParameters ccmV2JumpgateParameters = new DefaultCcmV2JumpgateParameters("invertingProxyHost", "invertingProxyCertificate", "agentCrn", "agentKeyId", "agentEncipheredPrivateKey", "agentCertificate", "environmentCrn", "agentMachineUserAccessKeyId", "agentMachineUserEncipheredAccessKey");
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2JumpgateParameters);
    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);
    lenient().when(entitlementService.ccmV2UseOneWayTls(ACCOUNT_ID)).thenReturn(oneWayTlsEntitlementEnabled);
    environment.setCcmV2TlsType(ccmV2TlsType);
    String userData = underTest.buildUserData(ACCOUNT_ID, environment, Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", platformParameters, "pass", "cert", ccmConnectivityParameters, null);
    String expectedUserData = FileReaderUtils.readFileFromClasspath(expectedContentFileName);
    assertEquals(expectedUserData, userData);
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) ScriptParams(com.sequenceiq.cloudbreak.cloud.model.ScriptParams) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) CcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource) DisplayName(org.junit.jupiter.api.DisplayName)

Example 7 with CcmConnectivityParameters

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

the class UserDataService method createUserData.

private void createUserData(Stack stack, Supplier<CcmConnectivityParameters> ccmParametersSupplier) {
    DetailedEnvironmentResponse environment = environmentClientService.getByCrn(stack.getEnvironmentCrn());
    Credential credential = credentialService.getCredentialByEnvCrn(stack.getEnvironmentCrn());
    Future<PlatformParameters> platformParametersFuture = intermediateBuilderExecutor.submit(() -> platformParameterService.getPlatformParameters(stack, credential));
    SecurityConfig securityConfig = stack.getSecurityConfig();
    SaltSecurityConfig saltSecurityConfig = securityConfig.getSaltSecurityConfig();
    String cbPrivKey = saltSecurityConfig.getSaltBootSignPrivateKey();
    byte[] cbSshKeyDer = PkiUtil.getPublicKeyDer(new String(Base64.decodeBase64(cbPrivKey)));
    String sshUser = stack.getStackAuthentication().getLoginUserName();
    String cbCert = securityConfig.getClientCert();
    String saltBootPassword = saltSecurityConfig.getSaltBootPassword();
    try {
        PlatformParameters platformParameters = platformParametersFuture.get();
        CcmConnectivityParameters ccmParameters = ccmParametersSupplier.get();
        Optional<ProxyConfig> proxyConfig = proxyConfigDtoService.getByEnvironmentCrn(stack.getEnvironmentCrn());
        String userData = userDataBuilder.buildUserData(stack.getAccountId(), environment, Platform.platform(stack.getCloudPlatform()), cbSshKeyDer, sshUser, platformParameters, saltBootPassword, cbCert, ccmParameters, proxyConfig.orElse(null));
        imageService.decorateImageWithUserDataForStack(stack, userData);
    } catch (InterruptedException | ExecutionException e) {
        LOGGER.error("Failed to get Platform parameters", e);
        throw new GetCloudParameterException("Failed to get Platform parameters", e);
    }
}
Also used : Credential(com.sequenceiq.freeipa.dto.Credential) GetCloudParameterException(com.sequenceiq.cloudbreak.cloud.service.GetCloudParameterException) ProxyConfig(com.sequenceiq.cloudbreak.dto.ProxyConfig) SaltSecurityConfig(com.sequenceiq.freeipa.entity.SaltSecurityConfig) CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) SaltSecurityConfig(com.sequenceiq.freeipa.entity.SaltSecurityConfig) SecurityConfig(com.sequenceiq.freeipa.entity.SecurityConfig) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) ExecutionException(java.util.concurrent.ExecutionException)

Example 8 with CcmConnectivityParameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters 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 9 with CcmConnectivityParameters

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

the class CcmUserDataService method getCcmV2JumpgateConnectivityParameters.

private CcmConnectivityParameters getCcmV2JumpgateConnectivityParameters(Stack stack, String keyId) {
    String generatedClusterDomain = getGatewayFqdn(stack);
    CcmV2JumpgateParameters ccmV2JumpgateParameters = ccmV2JumpgateParameterSupplier.getCcmV2JumpgateParameters(stack.getAccountId(), Optional.of(stack.getEnvironmentCrn()), generatedClusterDomain, keyId);
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2JumpgateParameters);
    saveCcmV2Config(stack.getId(), ccmV2JumpgateParameters);
    return ccmConnectivityParameters;
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) CcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters)

Example 10 with CcmConnectivityParameters

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

the class CcmUserDataService method fetchAndSaveCcmParameters.

public CcmConnectivityParameters fetchAndSaveCcmParameters(Stack stack) {
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters();
    String keyId = CcmResourceUtil.getKeyId(stack.getResourceCrn());
    if (stack.getTunnel().useCcmV1()) {
        ccmConnectivityParameters = getCcmConnectivityParameters(stack, keyId);
    } else if (stack.getTunnel().useCcmV2()) {
        ccmConnectivityParameters = getCcmV2ConnectivityParameters(stack, keyId);
    } else if (stack.getTunnel().useCcmV2Jumpgate()) {
        ccmConnectivityParameters = getCcmV2JumpgateConnectivityParameters(stack, keyId);
    } else {
        LOGGER.debug("CCM not enabled for stack.");
    }
    return ccmConnectivityParameters;
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters)

Aggregations

CcmConnectivityParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters)28 Test (org.junit.jupiter.api.Test)12 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)7 PlatformParameters (com.sequenceiq.cloudbreak.cloud.PlatformParameters)6 Stack (com.sequenceiq.freeipa.entity.Stack)6 Test (org.junit.Test)6 DefaultCcmV2JumpgateParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters)5 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)5 ProxyConfig (com.sequenceiq.cloudbreak.dto.ProxyConfig)5 CcmParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmParameters)4 CcmV2Parameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters)4 DefaultCcmParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmParameters)4 DefaultCcmV2Parameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters)4 ScriptParams (com.sequenceiq.cloudbreak.cloud.model.ScriptParams)4 DisplayName (org.junit.jupiter.api.DisplayName)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 CcmV2JumpgateParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters)3 Optional (java.util.Optional)3 DefaultInstanceParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultInstanceParameters)2 DefaultServerParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultServerParameters)2