Search in sources :

Example 6 with SecurityConfig

use of com.sequenceiq.cloudbreak.domain.SecurityConfig in project cloudbreak by hortonworks.

the class ImageService method create.

@Transactional(TxType.NEVER)
public void create(Stack stack, PlatformParameters params, String imageCatalog, Optional<String> imageId, Optional<Blueprint> blueprint) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
    try {
        Platform platform = platform(stack.cloudPlatform());
        String platformString = platform(stack.cloudPlatform()).value().toLowerCase();
        String region = stack.getRegion();
        SecurityConfig securityConfig = stack.getSecurityConfig();
        String cbPrivKey = securityConfig.getCloudbreakSshPrivateKeyDecoded();
        byte[] cbSshKeyDer = PkiUtil.getPublicKeyDer(cbPrivKey);
        String sshUser = stack.getStackAuthentication().getLoginUserName();
        String cbCert = securityConfig.getClientCertRaw();
        Map<InstanceGroupType, String> userData = userDataBuilder.buildUserData(platform, cbSshKeyDer, sshUser, params, securityConfig.getSaltBootPassword(), cbCert);
        StatedImage imgFromCatalog = determineImageFromCatalog(imageId, platformString, imageCatalog, blueprint);
        LOGGER.info("Determined image from catalog: {}", imgFromCatalog);
        String imageName = determineImageName(platformString, region, imgFromCatalog.getImage());
        LOGGER.info("Selected VM image for CloudPlatform '{}' and region '{}' is: {} from: {} image catalog", platformString, region, imageName, imgFromCatalog.getImageCatalogUrl());
        List<Component> components = getComponents(stack, userData, imgFromCatalog.getImage(), imageName, imgFromCatalog.getImageCatalogUrl(), imgFromCatalog.getImageCatalogName(), imgFromCatalog.getImage().getUuid());
        componentConfigProvider.store(components);
    } catch (JsonProcessingException e) {
        throw new CloudbreakServiceException("Failed to create json", e);
    }
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) InstanceGroupType(com.sequenceiq.cloudbreak.api.model.InstanceGroupType) SecurityConfig(com.sequenceiq.cloudbreak.domain.SecurityConfig) CloudbreakServiceException(com.sequenceiq.cloudbreak.service.CloudbreakServiceException) Component(com.sequenceiq.cloudbreak.domain.Component) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Transactional(javax.transaction.Transactional)

Example 7 with SecurityConfig

use of com.sequenceiq.cloudbreak.domain.SecurityConfig in project cloudbreak by hortonworks.

the class TlsSecurityService method buildGatewayConfig.

public GatewayConfig buildGatewayConfig(Long stackId, InstanceMetaData gatewayInstance, Integer gatewayPort, SaltClientConfig saltClientConfig, Boolean knoxGatewayEnabled) {
    SecurityConfig securityConfig = securityConfigRepository.findOneByStackId(stackId);
    String connectionIp = getGatewayIp(securityConfig, gatewayInstance);
    HttpClientConfig conf = buildTLSClientConfig(stackId, connectionIp, gatewayInstance);
    return new GatewayConfig(connectionIp, gatewayInstance.getPublicIpWrapper(), gatewayInstance.getPrivateIp(), gatewayInstance.getDiscoveryFQDN(), gatewayPort, conf.getServerCert(), conf.getClientCert(), conf.getClientKey(), saltClientConfig.getSaltPassword(), saltClientConfig.getSaltBootPassword(), saltClientConfig.getSignatureKeyPem(), knoxGatewayEnabled, InstanceMetadataType.GATEWAY_PRIMARY.equals(gatewayInstance.getInstanceMetadataType()), securityConfig.getSaltSignPrivateKeyDecoded(), securityConfig.getSaltSignPublicKeyDecoded());
}
Also used : HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) SecurityConfig(com.sequenceiq.cloudbreak.domain.SecurityConfig) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Aggregations

SecurityConfig (com.sequenceiq.cloudbreak.domain.SecurityConfig)7 Stack (com.sequenceiq.cloudbreak.domain.Stack)3 Transactional (javax.transaction.Transactional)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 CertificateResponse (com.sequenceiq.cloudbreak.api.model.CertificateResponse)1 DetailedStackStatus (com.sequenceiq.cloudbreak.api.model.DetailedStackStatus)1 InstanceGroupType (com.sequenceiq.cloudbreak.api.model.InstanceGroupType)1 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)1 Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)1 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)1 CloudbreakApiException (com.sequenceiq.cloudbreak.controller.CloudbreakApiException)1 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)1 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)1 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)1 Component (com.sequenceiq.cloudbreak.domain.Component)1 StackStatus (com.sequenceiq.cloudbreak.domain.StackStatus)1 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.service.CloudbreakServiceException)1 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)1