use of com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta.VmTypeMetaBuilder in project cloudbreak by hortonworks.
the class AzurePlatformResources method virtualMachines.
@Override
@Cacheable(cacheNames = "cloudResourceVmTypeCache", key = "#cloudCredential?.id + #region.getRegionName()")
public CloudVmTypes virtualMachines(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
AzureClient client = azureClientService.getClient(cloudCredential);
Set<VirtualMachineSize> vmTypes = client.getVmTypes(region.value());
Map<String, Set<VmType>> cloudVmResponses = new HashMap<>();
Map<String, VmType> defaultCloudVmResponses = new HashMap<>();
Set<VmType> types = new HashSet<>();
VmType defaultVmType = null;
for (VirtualMachineSize virtualMachineSize : vmTypes) {
float memoryInGB = virtualMachineSize.memoryInMB() / NO_MB_PER_GB;
VmTypeMetaBuilder builder = VmTypeMetaBuilder.builder().withCpuAndMemory(virtualMachineSize.numberOfCores(), memoryInGB);
for (VolumeParameterType volumeParameterType : values()) {
switch(volumeParameterType) {
case MAGNETIC:
builder.withMagneticConfig(volumeParameterConfig(MAGNETIC, virtualMachineSize));
break;
default:
break;
}
}
VmType vmType = VmType.vmTypeWithMeta(virtualMachineSize.name(), builder.create(), true);
types.add(vmType);
if (virtualMachineSize.name().equals(armVmDefault)) {
defaultVmType = vmType;
}
}
cloudVmResponses.put(region.value(), types);
defaultCloudVmResponses.put(region.value(), defaultVmType);
return new CloudVmTypes(cloudVmResponses, defaultCloudVmResponses);
}
use of com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta.VmTypeMetaBuilder in project cloudbreak by hortonworks.
the class AwsPlatformResources method readVmTypes.
private void readVmTypes() {
Map<String, VmType> vmTypeMap = new TreeMap<>();
String vm = getDefinition(awsVmParameterDefinitionPath, "vm");
String zoneVms = getDefinition(awsVmParameterDefinitionPath, "zone-vm");
try {
VmsSpecification oVms = JsonUtil.readValue(vm, VmsSpecification.class);
for (VmSpecification vmSpecification : oVms.getItems()) {
VmTypeMetaBuilder builder = VmTypeMetaBuilder.builder().withCpuAndMemory(vmSpecification.getMetaSpecification().getProperties().getCpu(), vmSpecification.getMetaSpecification().getProperties().getMemory()).withPrice(vmSpecification.getMetaSpecification().getProperties().getPrice());
for (ConfigSpecification configSpecification : vmSpecification.getMetaSpecification().getConfigSpecification()) {
addConfig(builder, configSpecification);
}
VmTypeMeta vmTypeMeta = builder.create();
vmTypeMap.put(vmSpecification.getValue(), VmType.vmTypeWithMeta(vmSpecification.getValue(), vmTypeMeta, vmSpecification.getExtended()));
}
ZoneVmSpecifications zoneVmSpecifications = JsonUtil.readValue(zoneVms, ZoneVmSpecifications.class);
for (ZoneVmSpecification zvs : zoneVmSpecifications.getItems()) {
Set<VmType> regionVmTypes = new HashSet<>();
for (String vmTypeString : zvs.getVmTypes()) {
VmType vmType = vmTypeMap.get(vmTypeString);
if (vmType != null) {
regionVmTypes.add(vmType);
}
}
vmTypes.put(region(zvs.getZone()), regionVmTypes);
VmType vmType = vmTypeMap.get(zvs.getDefaultVmType());
if (vmType != null) {
defaultVmTypes.put(region(zvs.getZone()), vmType);
}
}
} catch (IOException e) {
LOGGER.error("Cannot initialize platform parameters for aws", e);
}
}
use of com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta.VmTypeMetaBuilder in project cloudbreak by hortonworks.
the class OpenStackPlatformResources method collectVmTypes.
private Set<VmType> collectVmTypes(OSClient<?> osClient) {
Set<VmType> types = new HashSet<>();
for (Flavor flavor : openStackClient.getFlavors(osClient)) {
VmTypeMetaBuilder builder = VmTypeMetaBuilder.builder().withCpuAndMemory(flavor.getVcpus(), flavor.getRam());
for (VolumeParameterType volumeParameterType : values()) {
switch(volumeParameterType) {
case MAGNETIC:
builder.withMagneticConfig(volumeParameterConfig(MAGNETIC));
break;
case SSD:
builder.withSsdConfig(null);
break;
case EPHEMERAL:
builder.withEphemeralConfig(null);
break;
case ST1:
builder.withSt1Config(null);
break;
case AUTO_ATTACHED:
builder.withAutoAttachedConfig(null);
break;
default:
break;
}
}
VmType vmType = VmType.vmTypeWithMeta(flavor.getName(), builder.create(), true);
types.add(vmType);
}
LOGGER.info("openstack collect vm types result: {}", types);
return types;
}
Aggregations