Search in sources :

Example 16 with ProxyConfig

use of com.sequenceiq.cloudbreak.dto.ProxyConfig 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)

Example 17 with ProxyConfig

use of com.sequenceiq.cloudbreak.dto.ProxyConfig in project cloudbreak by hortonworks.

the class FreeIpaConfigService method determineAndSetBackup.

private FreeIpaBackupConfigView determineAndSetBackup(Stack stack) {
    Backup backup = stack.getBackup();
    final FreeIpaBackupConfigView.Builder builder = new FreeIpaBackupConfigView.Builder();
    if (backup != null) {
        builder.withEnabled(true).withMonthlyFullEnabled(backup.isMonthlyFullEnabled()).withHourlyEnabled(backup.isHourlyEnabled()).withInitialFullEnabled(backup.isInitialFullEnabled()).withLocation(backup.getStorageLocation());
        if (backup.getS3() != null) {
            builder.withPlatform(CloudPlatform.AWS.name());
            builder.withAwsRegion(stack.getRegion());
            LOGGER.debug("Backups will be configured to use S3 storage in {} region.", stack.getRegion());
        } else if (backup.getAdlsGen2() != null) {
            builder.withPlatform(CloudPlatform.AZURE.name()).withAzureInstanceMsi(backup.getAdlsGen2().getManagedIdentity());
            LOGGER.debug("Backups will be configured to use Azure Blob storage");
        } else if (backup.getGcs() != null) {
            builder.withPlatform(CloudPlatform.GCP.name()).withGcpServiceAccount(backup.getGcs().getServiceAccountEmail());
            LOGGER.debug("Backups will be configured to use GCP storage");
        }
        Optional<ProxyConfig> proxyConfig = proxyConfigDtoService.getByEnvironmentCrn(stack.getEnvironmentCrn());
        proxyConfig.ifPresent(config -> {
            LOGGER.debug("Proxy will be configured for backup: {}", config.getName());
            builder.withProxyUrl(config.getFullProxyUrl());
        });
    } else {
        builder.withEnabled(false);
        LOGGER.debug("Backups will not be configured.");
    }
    return builder.build();
}
Also used : Backup(com.sequenceiq.freeipa.api.model.Backup) ProxyConfig(com.sequenceiq.cloudbreak.dto.ProxyConfig)

Example 18 with ProxyConfig

use of com.sequenceiq.cloudbreak.dto.ProxyConfig in project cloudbreak by hortonworks.

the class ProxyConfigService method createProxyPillarConfig.

public Map<String, SaltPillarProperties> createProxyPillarConfig(String environmentCrn) {
    Optional<ProxyConfig> proxyConfig = proxyConfigDtoService.getByEnvironmentCrn(environmentCrn);
    if (proxyConfig.isPresent()) {
        ProxyConfig config = proxyConfig.get();
        Map<String, Object> proxy = new HashMap<>();
        proxy.put("host", config.getServerHost());
        proxy.put("port", config.getServerPort());
        proxy.put("protocol", config.getProtocol());
        config.getProxyAuthentication().ifPresent(auth -> {
            proxy.put("user", auth.getUserName());
            proxy.put("password", auth.getPassword());
        });
        proxy.put("noProxyHosts", config.getNoProxyHosts());
        return Map.of(PROXY_KEY, new SaltPillarProperties(PROXY_SLS_PATH, singletonMap(PROXY_KEY, proxy)));
    } else {
        return Map.of();
    }
}
Also used : HashMap(java.util.HashMap) ProxyConfig(com.sequenceiq.cloudbreak.dto.ProxyConfig) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)

Aggregations

ProxyConfig (com.sequenceiq.cloudbreak.dto.ProxyConfig)18 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 Test (org.junit.jupiter.api.Test)6 CcmConnectivityParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters)5 CdpResourceApi (com.cloudera.api.swagger.CdpResourceApi)4 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)4 ApiClient (com.cloudera.api.swagger.client.ApiClient)4 ApiHostList (com.cloudera.api.swagger.model.ApiHostList)4 ApiHostRef (com.cloudera.api.swagger.model.ApiHostRef)4 ApiRemoteDataContext (com.cloudera.api.swagger.model.ApiRemoteDataContext)4 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)4 TemplatePreparationObject (com.sequenceiq.cloudbreak.template.TemplatePreparationObject)4 GeneralClusterConfigs (com.sequenceiq.cloudbreak.template.model.GeneralClusterConfigs)4 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 PlatformParameters (com.sequenceiq.cloudbreak.cloud.PlatformParameters)3 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)3 ProxyResponse (com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse)3 Test (org.junit.Test)3