Search in sources :

Example 1 with VmTypeMetaJson

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VmTypeMetaJson in project cloudbreak by hortonworks.

the class VmTypeToVmTypeResponseConverter method convert.

public VmTypeResponse convert(VmType source) {
    VmTypeResponse vmTypeResponse = new VmTypeResponse();
    List<VolumeParameterConfigResponse> configs = new ArrayList<>();
    convertVolumeConfig(configs, source.getMetaData().getAutoAttachedConfig());
    convertVolumeConfig(configs, source.getMetaData().getEphemeralConfig());
    convertVolumeConfig(configs, source.getMetaData().getMagneticConfig());
    convertVolumeConfig(configs, source.getMetaData().getSsdConfig());
    convertVolumeConfig(configs, source.getMetaData().getSt1Config());
    VmTypeMetaJson vmTypeMetaJson = new VmTypeMetaJson();
    vmTypeMetaJson.setProperties(source.getMetaData().getProperties());
    vmTypeMetaJson.setConfigs(configs);
    vmTypeResponse.setVmTypeMetaJson(vmTypeMetaJson);
    vmTypeResponse.setValue(source.value());
    return vmTypeResponse;
}
Also used : VmTypeResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VmTypeResponse) VolumeParameterConfigResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VolumeParameterConfigResponse) VmTypeMetaJson(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VmTypeMetaJson) ArrayList(java.util.ArrayList)

Example 2 with VmTypeMetaJson

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VmTypeMetaJson in project cloudbreak by hortonworks.

the class VmTypeToVmTypeResponseConverterTest method testConvert.

@Test
public void testConvert() {
    VmTypeMeta vmTypeMeta = VmTypeMeta.VmTypeMetaBuilder.builder().withAutoAttachedConfig(1, 2, 3, 4).withEphemeralConfig(2, 3, 4, 5).withMagneticConfig(3, 4, 5, 6).withSsdConfig(4, 5, 6, 7).withSt1Config(5, 6, 7, 8).withCpuAndMemory(100, 32).withPrice(100.0).withMaximumPersistentDisksSizeGb(5000L).withVolumeEncryptionSupport(false).withProperty("custom", "value").create();
    VmType vmType = VmType.vmTypeWithMeta("large", vmTypeMeta, false);
    VmTypeResponse vmTypeResponse = underTest.convert(vmType);
    assertEquals("large", vmTypeResponse.getValue());
    VmTypeMetaJson vmTypeMetaJson = vmTypeResponse.getVmTypeMetaJson();
    Map<String, Object> properties = vmTypeMetaJson.getProperties();
    assertThat(properties.entrySet()).extracting(Map.Entry::getKey, Map.Entry::getValue).containsOnly(tuple("Cpu", 100), tuple("Memory", 32), tuple("Price", "100.0"), tuple("maximumPersistentDisksSizeGb", 5000L), tuple("EncryptionSupported", false), tuple("custom", "value"));
    List<VolumeParameterConfigResponse> configs = vmTypeMetaJson.getConfigs();
    assertThat(configs).hasSize(5);
    assertThat(configs).extracting(VolumeParameterConfigResponse::getVolumeParameterType, VolumeParameterConfigResponse::getMinimumSize, VolumeParameterConfigResponse::getMaximumSize, VolumeParameterConfigResponse::getMinimumNumber, VolumeParameterConfigResponse::getMaximumNumber).containsOnly(tuple("AUTO_ATTACHED", 1, 2, 3, 4), tuple("EPHEMERAL", 2, 3, 4, 5), tuple("MAGNETIC", 3, 4, 5, 6), tuple("SSD", 4, 5, 6, 7), tuple("ST1", 5, 6, 7, 8));
}
Also used : VmTypeMeta(com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta) VmTypeResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VmTypeResponse) VolumeParameterConfigResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VolumeParameterConfigResponse) VmTypeMetaJson(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VmTypeMetaJson) VmType(com.sequenceiq.cloudbreak.cloud.model.VmType) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Aggregations

VmTypeMetaJson (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VmTypeMetaJson)2 VmTypeResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VmTypeResponse)2 VolumeParameterConfigResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VolumeParameterConfigResponse)2 VmType (com.sequenceiq.cloudbreak.cloud.model.VmType)1 VmTypeMeta (com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Test (org.junit.jupiter.api.Test)1