Search in sources :

Example 1 with InstanceTemplateV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.template.InstanceTemplateV4Response in project cloudbreak by hortonworks.

the class MockStackResponseGenerator method awsTemplate.

public static InstanceTemplateV4Response awsTemplate() {
    InstanceTemplateV4Response awsTemplate = new InstanceTemplateV4Response();
    awsTemplate.setCloudPlatform(CloudPlatform.AWS);
    return awsTemplate;
}
Also used : InstanceTemplateV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.template.InstanceTemplateV4Response)

Example 2 with InstanceTemplateV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.template.InstanceTemplateV4Response in project cloudbreak by hortonworks.

the class TemplateToInstanceTemplateV4ResponseConverterTest method testAwsEncryptionConvert.

@Test
public void testAwsEncryptionConvert() {
    String encyptionKey = "aKey";
    Template template = new Template();
    Map<String, String> attributes = Maps.newHashMap();
    attributes.put(InstanceTemplate.VOLUME_ENCRYPTION_KEY_ID, encyptionKey);
    attributes.put(InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE, "CUSTOM");
    attributes.put("cloudPlatform", "AWS");
    template.setAttributes(new Json(attributes));
    template.setVolumeTemplates(Sets.newHashSet());
    template.setCloudPlatform("AWS");
    InstanceTemplateV4Response response = underTest.convert(template);
    assertEquals(response.getAws().getEncryption().getType(), EncryptionType.CUSTOM);
    assertEquals(response.getAws().getEncryption().getKey(), encyptionKey);
}
Also used : InstanceTemplateV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.template.InstanceTemplateV4Response) Json(com.sequenceiq.cloudbreak.common.json.Json) Template(com.sequenceiq.cloudbreak.domain.Template) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) Test(org.junit.jupiter.api.Test)

Example 3 with InstanceTemplateV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.template.InstanceTemplateV4Response in project cloudbreak by hortonworks.

the class TemplateToInstanceTemplateV4ResponseConverter method convert.

public InstanceTemplateV4Response convert(Template source) {
    InstanceTemplateV4Response response = new InstanceTemplateV4Response();
    response.setId(source.getId());
    response.setRootVolume(rootVolume(source));
    response.setAttachedVolumes(source.getVolumeTemplates().stream().filter(volume -> volume.getUsageType() == VolumeUsageType.GENERAL).map(volume -> templateToVolumeV4ResponseConverter.convert(volume)).collect(Collectors.toSet()));
    response.setDatabaseVolume(databaseVolume(source));
    response.setInstanceType(source.getInstanceType());
    Json attributes = source.getAttributes();
    if (attributes != null) {
        Map<String, Object> parameters = attributes.getMap();
        ofNullable(source.getSecretAttributes()).ifPresent(attr -> parameters.putAll(new Json(attr).getMap()));
        providerParameterCalculator.parse(parameters, response);
    }
    response.setCloudPlatform(CloudPlatform.valueOf(source.cloudPlatform()));
    return response;
}
Also used : RootVolumeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.template.volume.RootVolumeV4Response) Optional.ofNullable(java.util.Optional.ofNullable) Collectors(java.util.stream.Collectors) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) Template(com.sequenceiq.cloudbreak.domain.Template) Inject(javax.inject.Inject) DatabaseVolumeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.template.volume.DatabaseVolumeV4Response) Json(com.sequenceiq.cloudbreak.common.json.Json) VolumeTemplate(com.sequenceiq.cloudbreak.domain.VolumeTemplate) Component(org.springframework.stereotype.Component) ProviderParameterCalculator(com.sequenceiq.cloudbreak.common.mappable.ProviderParameterCalculator) Map(java.util.Map) Optional(java.util.Optional) InstanceTemplateV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.template.InstanceTemplateV4Response) VolumeUsageType(com.sequenceiq.cloudbreak.domain.VolumeUsageType) InstanceTemplateV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.template.InstanceTemplateV4Response) Json(com.sequenceiq.cloudbreak.common.json.Json)

Example 4 with InstanceTemplateV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.template.InstanceTemplateV4Response in project cloudbreak by hortonworks.

the class MockStackResponseGenerator method instanceGroup.

public static InstanceGroupV4Response instanceGroup(String hostGroupName, InstanceTemplateV4Response template, Set<InstanceMetaDataV4Response> instanceMetaDataV4Responses) {
    InstanceGroupV4Response instanceGroup = new InstanceGroupV4Response();
    instanceGroup.setTemplate(template);
    instanceGroup.setName(hostGroupName);
    instanceGroup.setMetadata(instanceMetaDataV4Responses);
    return instanceGroup;
}
Also used : InstanceGroupV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response)

Aggregations

InstanceTemplateV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.template.InstanceTemplateV4Response)3 Json (com.sequenceiq.cloudbreak.common.json.Json)2 Template (com.sequenceiq.cloudbreak.domain.Template)2 InstanceGroupV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response)1 DatabaseVolumeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.template.volume.DatabaseVolumeV4Response)1 RootVolumeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.template.volume.RootVolumeV4Response)1 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)1 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 ProviderParameterCalculator (com.sequenceiq.cloudbreak.common.mappable.ProviderParameterCalculator)1 VolumeTemplate (com.sequenceiq.cloudbreak.domain.VolumeTemplate)1 VolumeUsageType (com.sequenceiq.cloudbreak.domain.VolumeUsageType)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Optional.ofNullable (java.util.Optional.ofNullable)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Test (org.junit.jupiter.api.Test)1 Component (org.springframework.stereotype.Component)1