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