use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VolumeParameterConfigResponse in project cloudbreak by hortonworks.
the class VmTypeToVmTypeResponseConverter method convertVolumeConfig.
private void convertVolumeConfig(Collection<VolumeParameterConfigResponse> configs, VolumeParameterConfig source) {
if (source != null) {
VolumeParameterConfigResponse config = new VolumeParameterConfigResponse();
config.setMaximumNumber(source.maximumNumber());
config.setMaximumSize(source.maximumSize());
config.setMinimumNumber(source.minimumNumber());
config.setMinimumSize(source.minimumSize());
config.setVolumeParameterType(source.volumeParameterType().name());
configs.add(config);
}
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VolumeParameterConfigResponse 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;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.VolumeParameterConfigResponse 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));
}
Aggregations