use of com.sequenceiq.cloudbreak.cloud.service.GetCloudParameterException 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.cloud.service.GetCloudParameterException in project cloudbreak by hortonworks.
the class UserDataService method createUserData.
public void createUserData(Long stackId) throws CloudbreakImageNotFoundException {
Stack stack = stackService.getByIdWithLists(stackId);
String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
Future<PlatformParameters> platformParametersFuture = intermediateBuilderExecutor.submit(() -> connector.getPlatformParameters(stack, userCrn));
SecurityConfig securityConfig = securityConfigService.generateAndSaveSecurityConfig(stack);
stack.setSecurityConfig(securityConfig);
stackService.save(stack);
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 = ccmUserDataService.fetchAndSaveCcmParameters(stack);
Optional<ProxyConfig> proxyConfig = proxyConfigDtoService.getByEnvironmentCrn(stack.getEnvironmentCrn());
Map<InstanceGroupType, String> userData = userDataBuilder.buildUserData(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 parmaters", e);
throw new GetCloudParameterException("Failed to get Platform parmaters", e);
}
}
use of com.sequenceiq.cloudbreak.cloud.service.GetCloudParameterException in project cloudbreak by hortonworks.
the class EnvironmentValidatorService method validateSecurityGroups.
public ValidationResult validateSecurityGroups(EnvironmentEditDto editDto, Environment environment) {
ValidationResultBuilder validationResultBuilder = ValidationResult.builder();
getSecurityGroupIdSet(editDto).forEach(sg -> {
try {
fetchSecurityGroup(editDto, environment, sg);
} catch (BadRequestException e) {
LOGGER.info("Security group cannot be fetched, because BadRequest occurred with: " + e.getMessage());
validationResultBuilder.error(e.getMessage());
} catch (GetCloudParameterException e) {
LOGGER.info("Security group cannot be fetched, because: " + e.getMessage());
validationResultBuilder.error(e.getCause().getMessage());
}
});
return validationResultBuilder.build();
}
Aggregations