Search in sources :

Example 1 with InstanceGroupParameterResponse

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

the class AzurePlatformParameters method collectInstanceGroupParameters.

@Override
public Map<String, InstanceGroupParameterResponse> collectInstanceGroupParameters(Set<InstanceGroupParameterRequest> instanceGroupParameterRequests) {
    Map<String, InstanceGroupParameterResponse> result = new HashMap<>();
    for (InstanceGroupParameterRequest groupParameterRequest : instanceGroupParameterRequests) {
        InstanceGroupParameterResponse instanceGroupParameterResponse = new InstanceGroupParameterResponse();
        if (groupParameterRequest.getParameters().keySet().contains("availabilitySet")) {
            instanceGroupParameterResponse.setGroupName(groupParameterRequest.getGroupName());
            instanceGroupParameterResponse.setParameters(groupParameterRequest.getParameters());
        } else if (groupParameterRequest.getNodeCount() > 1) {
            Map<String, Object> parameters = groupParameterRequest.getParameters();
            Map<String, Object> availabilitySet = new HashMap<>();
            availabilitySet.put("name", String.format("%s-%s-as", groupParameterRequest.getGroupName(), groupParameterRequest.getStackName()));
            availabilitySet.put("faultDomainCount", DEFAULT_FAULT_DOMAIN_COUNTER);
            availabilitySet.put("updateDomainCount", DEFAULT_UPDATE_DOMAIN_COUNTER);
            parameters.put("availabilitySet", availabilitySet);
            instanceGroupParameterResponse.setGroupName(groupParameterRequest.getGroupName());
            instanceGroupParameterResponse.setParameters(parameters);
        }
        result.put(instanceGroupParameterResponse.getGroupName(), instanceGroupParameterResponse);
    }
    return result;
}
Also used : HashMap(java.util.HashMap) InstanceGroupParameterRequest(com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterRequest) InstanceGroupParameterResponse(com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterResponse) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with InstanceGroupParameterResponse

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

the class GetPlatformInstanceGroupParametersHandler method accept.

@Override
public void accept(Event<GetPlatformInstanceGroupParameterRequest> getPlatformInstanceGroupParameterRequestEvent) {
    LOGGER.info("Received event: {}", getPlatformInstanceGroupParameterRequestEvent);
    GetPlatformInstanceGroupParameterRequest request = getPlatformInstanceGroupParameterRequestEvent.getData();
    try {
        CloudPlatformVariant variant = new CloudPlatformVariant(platform(request.getExtendedCloudCredential().getCloudPlatform()), variant(request.getVariant()));
        Map<String, InstanceGroupParameterResponse> instanceGroupParameterResponses = cloudPlatformConnectors.get(variant).parameters().collectInstanceGroupParameters(request.getInstanceGroupParameterRequest());
        GetPlatformInstanceGroupParameterResult getPlatformInstanceGroupParameterResult = new GetPlatformInstanceGroupParameterResult(request, instanceGroupParameterResponses);
        request.getResult().onNext(getPlatformInstanceGroupParameterResult);
        LOGGER.info("Query platform instance group parameters finished.");
    } catch (Exception e) {
        request.getResult().onNext(new GetPlatformInstanceGroupParameterResult(e.getMessage(), e, request));
    }
}
Also used : GetPlatformInstanceGroupParameterRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformInstanceGroupParameterRequest) GetPlatformInstanceGroupParameterResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformInstanceGroupParameterResult) InstanceGroupParameterResponse(com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterResponse) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)

Example 3 with InstanceGroupParameterResponse

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

the class StackDecorator method updateInstanceGroupParameters.

private void updateInstanceGroupParameters(Map<String, InstanceGroupParameterResponse> instanceGroupParameterResponses, InstanceGroup instanceGroup) {
    InstanceGroupParameterResponse instanceGroupParameterResponse = instanceGroupParameterResponses.get(instanceGroup.getGroupName());
    if (instanceGroupParameterResponse != null) {
        try {
            Json jsonProperties = new Json(instanceGroupParameterResponse.getParameters());
            instanceGroup.setAttributes(jsonProperties);
        } catch (JsonProcessingException e) {
            LOGGER.error("Could not update '{}' instancegroup parameters with defaults.", instanceGroupParameterResponse.getGroupName());
        }
    }
}
Also used : InstanceGroupParameterResponse(com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterResponse) Json(com.sequenceiq.cloudbreak.domain.json.Json) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 4 with InstanceGroupParameterResponse

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

the class StackDecorator method prepareInstanceGroups.

private void prepareInstanceGroups(Stack subject, StackRequest request, Credential credential, IdentityUser user) {
    Map<String, InstanceGroupParameterResponse> instanceGroupParameterResponse = cloudParameterService.getInstanceGroupParameters(credential, getInstanceGroupParameterRequests(subject));
    for (InstanceGroup instanceGroup : subject.getInstanceGroups()) {
        updateInstanceGroupParameters(instanceGroupParameterResponse, instanceGroup);
        if (instanceGroup.getTemplate() != null) {
            Template template = instanceGroup.getTemplate();
            if (template.getId() == null) {
                template.setPublicInAccount(subject.isPublicInAccount());
                template.setCloudPlatform(getCloudPlatform(subject, request, template.cloudPlatform()));
                templateValidator.validateTemplateRequest(credential, instanceGroup.getTemplate(), request.getRegion(), request.getAvailabilityZone(), request.getPlatformVariant());
                template = templateDecorator.decorate(credential, template, request.getRegion(), request.getAvailabilityZone(), request.getPlatformVariant());
                template = templateService.create(user, template);
            }
            instanceGroup.setTemplate(template);
        }
        if (instanceGroup.getSecurityGroup() != null) {
            SecurityGroup securityGroup = instanceGroup.getSecurityGroup();
            if (securityGroup.getId() == null) {
                securityGroup.setPublicInAccount(subject.isPublicInAccount());
                securityGroup.setCloudPlatform(getCloudPlatform(subject, request, securityGroup.getCloudPlatform()));
                securityGroup = securityGroupService.create(user, securityGroup);
                instanceGroup.setSecurityGroup(securityGroup);
            }
        }
    }
}
Also used : InstanceGroupParameterResponse(com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterResponse) SecurityGroup(com.sequenceiq.cloudbreak.domain.SecurityGroup) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Template(com.sequenceiq.cloudbreak.domain.Template)

Aggregations

InstanceGroupParameterResponse (com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterResponse)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 GetPlatformInstanceGroupParameterRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformInstanceGroupParameterRequest)1 GetPlatformInstanceGroupParameterResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformInstanceGroupParameterResult)1 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 InstanceGroupParameterRequest (com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterRequest)1 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)1 SecurityGroup (com.sequenceiq.cloudbreak.domain.SecurityGroup)1 Template (com.sequenceiq.cloudbreak.domain.Template)1 Json (com.sequenceiq.cloudbreak.domain.json.Json)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1