Search in sources :

Example 21 with Platform

use of com.sequenceiq.cloudbreak.cloud.model.Platform 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 22 with Platform

use of com.sequenceiq.cloudbreak.cloud.model.Platform in project cloudbreak by hortonworks.

the class MockPlatformResources method getDefaultRegion.

private Region getDefaultRegion() {
    Map<Platform, Region> defaultRegionsMap = Maps.newHashMap();
    if (isNoneEmpty(defaultRegions)) {
        for (String entry : defaultRegions.split(",")) {
            String[] keyValue = entry.split(":");
            defaultRegionsMap.put(platform(keyValue[0]), Region.region(keyValue[1]));
        }
        Region platformRegion = defaultRegionsMap.get(platform(MockConstants.MOCK));
        if (platformRegion != null && !isEmpty(platformRegion.value())) {
            return getRegionByName(platformRegion.value());
        }
    }
    return regions.keySet().iterator().next();
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) Region(com.sequenceiq.cloudbreak.cloud.model.Region)

Example 23 with Platform

use of com.sequenceiq.cloudbreak.cloud.model.Platform in project cloudbreak by hortonworks.

the class GetDiskTypesHandler method accept.

@Override
public void accept(Event<GetDiskTypesRequest> getDiskTypesRequestEvent) {
    LOGGER.info("Received event: {}", getDiskTypesRequestEvent);
    GetDiskTypesRequest request = getDiskTypesRequestEvent.getData();
    try {
        Map<Platform, Collection<DiskType>> platformDiskTypes = Maps.newHashMap();
        Map<Platform, DiskType> defaultDiskTypes = Maps.newHashMap();
        Map<Platform, Map<String, VolumeParameterType>> diskMappings = Maps.newHashMap();
        Map<Platform, Map<DiskType, DisplayName>> diskDisplayNames = Maps.newHashMap();
        for (Entry<Platform, Collection<Variant>> connector : cloudPlatformConnectors.getPlatformVariants().getPlatformToVariants().entrySet()) {
            DiskTypes diskTypes = cloudPlatformConnectors.getDefault(connector.getKey()).parameters().diskTypes();
            defaultDiskTypes.put(connector.getKey(), diskTypes.defaultType());
            platformDiskTypes.put(connector.getKey(), diskTypes.types());
            diskMappings.put(connector.getKey(), diskTypes.diskMapping());
            diskDisplayNames.put(connector.getKey(), diskTypes.displayNames());
        }
        GetDiskTypesResult getDiskTypesResult = new GetDiskTypesResult(request, new PlatformDisks(platformDiskTypes, defaultDiskTypes, diskMappings, diskDisplayNames));
        request.getResult().onNext(getDiskTypesResult);
        LOGGER.info("Query platform disk types finished.");
    } catch (RuntimeException e) {
        request.getResult().onNext(new GetDiskTypesResult(e.getMessage(), e, request));
    }
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) PlatformDisks(com.sequenceiq.cloudbreak.cloud.model.PlatformDisks) DiskType(com.sequenceiq.cloudbreak.cloud.model.DiskType) GetDiskTypesRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetDiskTypesRequest) GetDiskTypesResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetDiskTypesResult) DiskTypes(com.sequenceiq.cloudbreak.cloud.model.DiskTypes) Collection(java.util.Collection) Map(java.util.Map)

Example 24 with Platform

use of com.sequenceiq.cloudbreak.cloud.model.Platform in project cloudbreak by hortonworks.

the class GetPlatformOrchestratorsHandler method accept.

@Override
public void accept(Event<GetPlatformOrchestratorsRequest> getPlatformOrchestratorsRequest) {
    LOGGER.info("Received event: {}", getPlatformOrchestratorsRequest);
    GetPlatformOrchestratorsRequest request = getPlatformOrchestratorsRequest.getData();
    try {
        Map<Platform, Collection<Orchestrator>> platformCollectionHashMap = Maps.newHashMap();
        Map<Platform, Orchestrator> defaults = Maps.newHashMap();
        for (Entry<Platform, Collection<Variant>> connector : cloudPlatformConnectors.getPlatformVariants().getPlatformToVariants().entrySet()) {
            PlatformOrchestrator platformOrchestrator = cloudPlatformConnectors.getDefault(connector.getKey()).parameters().orchestratorParams();
            platformCollectionHashMap.put(connector.getKey(), platformOrchestrator.types());
            defaults.put(connector.getKey(), platformOrchestrator.defaultType());
        }
        GetPlatformOrchestratorsResult getPlatformOrchestratorsResult = new GetPlatformOrchestratorsResult(request, new PlatformOrchestrators(platformCollectionHashMap, defaults));
        request.getResult().onNext(getPlatformOrchestratorsResult);
        LOGGER.info("Query platform orchestrators types finished.");
    } catch (RuntimeException e) {
        request.getResult().onNext(new GetPlatformOrchestratorsResult(e.getMessage(), e, request));
    }
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) PlatformOrchestrator(com.sequenceiq.cloudbreak.cloud.model.PlatformOrchestrator) Collection(java.util.Collection) PlatformOrchestrators(com.sequenceiq.cloudbreak.cloud.model.PlatformOrchestrators) GetPlatformOrchestratorsRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformOrchestratorsRequest) GetPlatformOrchestratorsResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformOrchestratorsResult) Orchestrator(com.sequenceiq.cloudbreak.cloud.model.Orchestrator) PlatformOrchestrator(com.sequenceiq.cloudbreak.cloud.model.PlatformOrchestrator)

Example 25 with Platform

use of com.sequenceiq.cloudbreak.cloud.model.Platform in project cloudbreak by hortonworks.

the class StackRequestToStackConverter method getRegion.

private String getRegion(StackRequest source) {
    boolean containerOrchestrator;
    try {
        containerOrchestrator = orchestratorTypeResolver.resolveType(source.getOrchestrator().getType()).containerOrchestrator();
    } catch (CloudbreakException ignored) {
        throw new BadRequestException("Orchestrator not supported.");
    }
    if (OrchestratorConstants.YARN.equals(source.getOrchestrator().getType())) {
        return OrchestratorConstants.YARN;
    }
    if (isEmpty(source.getRegion()) && !containerOrchestrator) {
        Map<Platform, Region> regions = Maps.newHashMap();
        if (isNoneEmpty(defaultRegions)) {
            for (String entry : defaultRegions.split(",")) {
                String[] keyValue = entry.split(":");
                regions.put(platform(keyValue[0]), Region.region(keyValue[1]));
            }
            Region platformRegion = regions.get(platform(source.getCloudPlatform()));
            if (platformRegion == null || isEmpty(platformRegion.value())) {
                throw new BadRequestException(String.format("No default region specified for: %s. Region cannot be empty.", source.getCloudPlatform()));
            }
            return platformRegion.value();
        } else {
            throw new BadRequestException("No default region is specified. Region cannot be empty.");
        }
    }
    return source.getRegion();
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) Region(com.sequenceiq.cloudbreak.cloud.model.Region)

Aggregations

Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)26 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)7 ResourceBuilderContext (com.sequenceiq.cloudbreak.cloud.template.context.ResourceBuilderContext)7 Map (java.util.Map)7 PlatformDisks (com.sequenceiq.cloudbreak.cloud.model.PlatformDisks)6 HashMap (java.util.HashMap)6 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)5 Collection (java.util.Collection)5 PlatformParameters (com.sequenceiq.cloudbreak.cloud.PlatformParameters)4 CloudResourceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus)4 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)4 Set (java.util.Set)4 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)3 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)2 SpecialParameters (com.sequenceiq.cloudbreak.api.model.SpecialParameters)2 SpecialParametersJson (com.sequenceiq.cloudbreak.api.model.SpecialParametersJson)2 DiskType (com.sequenceiq.cloudbreak.cloud.model.DiskType)2 DiskTypes (com.sequenceiq.cloudbreak.cloud.model.DiskTypes)2 PlatformOrchestrators (com.sequenceiq.cloudbreak.cloud.model.PlatformOrchestrators)2 Region (com.sequenceiq.cloudbreak.cloud.model.Region)2