Search in sources :

Example 1 with EPHEMERAL

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

the class AzurePlatformResources method collectInstanceStorageCount.

public InstanceStoreMetadata collectInstanceStorageCount(AuthenticatedContext ac, List<String> instanceTypes) {
    try {
        AzureClient client = azureClientService.getClient(ac.getCloudCredential());
        Set<VirtualMachineSize> vmTypes = client.getVmTypes(ac.getCloudContext().getLocation().getRegion().value());
        Map<String, VolumeParameterConfig> instanceTypeToInstanceStorageMap = vmTypes.stream().filter(vmType -> instanceTypes.contains(vmType.name())).filter(vmType -> vmType.resourceDiskSizeInMB() != NO_RESOURCE_DISK_ATTACHED_TO_INSTANCE).collect(Collectors.toMap(VirtualMachineSize::name, vmType -> new VolumeParameterConfig(EPHEMERAL, (int) (vmType.resourceDiskSizeInMB() / NO_MB_PER_GB), (int) (vmType.resourceDiskSizeInMB() / NO_MB_PER_GB), 1, 1)));
        return new InstanceStoreMetadata(instanceTypeToInstanceStorageMap);
    } catch (Exception e) {
        LOGGER.warn("Failed to get vm type data: {}", instanceTypes, e);
        throw new CloudConnectorException(e.getMessage(), e);
    }
}
Also used : CloudVmTypes(com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes) ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) MinimalHardwareFilter(com.sequenceiq.cloudbreak.filter.MinimalHardwareFilter) Cacheable(org.springframework.cache.annotation.Cacheable) LoggerFactory(org.slf4j.LoggerFactory) Identity(com.microsoft.azure.management.msi.Identity) AzureRegionProvider(com.sequenceiq.cloudbreak.cloud.azure.resource.AzureRegionProvider) StringUtils(org.apache.commons.lang3.StringUtils) PrivateZone(com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone) InvalidParameterException(java.security.InvalidParameterException) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) CloudAccessConfig(com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfig) CloudSshKeys(com.sequenceiq.cloudbreak.cloud.model.CloudSshKeys) Map(java.util.Map) BadRequestException(javax.ws.rs.BadRequestException) EPHEMERAL(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType.EPHEMERAL) InstanceStoreMetadata(com.sequenceiq.cloudbreak.cloud.model.InstanceStoreMetadata) CloudPrivateDnsZone(com.sequenceiq.cloudbreak.cloud.model.dns.CloudPrivateDnsZone) Predicate(java.util.function.Predicate) Collection(java.util.Collection) CloudEncryptionKeys(com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys) CloudResourceGroups(com.sequenceiq.cloudbreak.cloud.model.resourcegroup.CloudResourceGroups) Set(java.util.Set) Collectors(java.util.stream.Collectors) VmType(com.sequenceiq.cloudbreak.cloud.model.VmType) CloudNoSqlTables(com.sequenceiq.cloudbreak.cloud.model.nosql.CloudNoSqlTables) Objects(java.util.Objects) List(java.util.List) CloudPrivateDnsZones(com.sequenceiq.cloudbreak.cloud.model.dns.CloudPrivateDnsZones) VolumeParameterType(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType) Entry(java.util.Map.Entry) AzureClientService(com.sequenceiq.cloudbreak.cloud.azure.client.AzureClientService) MAGNETIC(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType.MAGNETIC) CloudSecurityGroup(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroup) AzureClient(com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient) CloudIpPools(com.sequenceiq.cloudbreak.cloud.model.CloudIpPools) Region(com.sequenceiq.cloudbreak.cloud.model.Region) Subnet(com.microsoft.azure.management.network.Subnet) HashMap(java.util.HashMap) CloudGateWays(com.sequenceiq.cloudbreak.cloud.model.CloudGateWays) CloudNetworks(com.sequenceiq.cloudbreak.cloud.model.CloudNetworks) CloudRegions(com.sequenceiq.cloudbreak.cloud.model.CloudRegions) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) Network(com.microsoft.azure.management.network.Network) PagedList(com.microsoft.azure.PagedList) Service(org.springframework.stereotype.Service) PlatformResourceSecurityGroupFilterView(com.sequenceiq.cloudbreak.cloud.model.view.PlatformResourceSecurityGroupFilterView) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Logger(org.slf4j.Logger) PlatformResources(com.sequenceiq.cloudbreak.cloud.PlatformResources) VmTypeMetaBuilder(com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta.VmTypeMetaBuilder) NetworkSecurityGroup(com.microsoft.azure.management.network.NetworkSecurityGroup) CloudAccessConfigs(com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs) SSD(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType.SSD) VirtualMachineSize(com.microsoft.azure.management.compute.VirtualMachineSize) CloudResourceGroup(com.sequenceiq.cloudbreak.cloud.model.resourcegroup.CloudResourceGroup) CloudSecurityGroups(com.sequenceiq.cloudbreak.cloud.model.CloudSecurityGroups) VolumeParameterConfig(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterConfig) CloudNetwork(com.sequenceiq.cloudbreak.cloud.model.CloudNetwork) PermanentlyFailedException(com.sequenceiq.cloudbreak.util.PermanentlyFailedException) AzureClient(com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient) VirtualMachineSize(com.microsoft.azure.management.compute.VirtualMachineSize) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) InstanceStoreMetadata(com.sequenceiq.cloudbreak.cloud.model.InstanceStoreMetadata) VolumeParameterConfig(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterConfig) InvalidParameterException(java.security.InvalidParameterException) BadRequestException(javax.ws.rs.BadRequestException) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) PermanentlyFailedException(com.sequenceiq.cloudbreak.util.PermanentlyFailedException)

Aggregations

PagedList (com.microsoft.azure.PagedList)1 VirtualMachineSize (com.microsoft.azure.management.compute.VirtualMachineSize)1 Identity (com.microsoft.azure.management.msi.Identity)1 Network (com.microsoft.azure.management.network.Network)1 NetworkSecurityGroup (com.microsoft.azure.management.network.NetworkSecurityGroup)1 Subnet (com.microsoft.azure.management.network.Subnet)1 PrivateZone (com.microsoft.azure.management.privatedns.v2018_09_01.PrivateZone)1 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)1 PlatformResources (com.sequenceiq.cloudbreak.cloud.PlatformResources)1 AzureClient (com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient)1 AzureClientService (com.sequenceiq.cloudbreak.cloud.azure.client.AzureClientService)1 AzureRegionProvider (com.sequenceiq.cloudbreak.cloud.azure.resource.AzureRegionProvider)1 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)1 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)1 CloudAccessConfig (com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfig)1 CloudAccessConfigs (com.sequenceiq.cloudbreak.cloud.model.CloudAccessConfigs)1 CloudEncryptionKeys (com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys)1 CloudGateWays (com.sequenceiq.cloudbreak.cloud.model.CloudGateWays)1 CloudIpPools (com.sequenceiq.cloudbreak.cloud.model.CloudIpPools)1 CloudNetwork (com.sequenceiq.cloudbreak.cloud.model.CloudNetwork)1