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);
}
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();
}
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();
}
}
Aggregations