Search in sources :

Example 11 with ResourceType

use of com.sequenceiq.common.api.type.ResourceType in project cloudbreak by hortonworks.

the class InstanceMetaDataService method getAzFromDiskOrNullIfRepair.

@VisibleForTesting
String getAzFromDiskOrNullIfRepair(Stack stack, boolean repair, String instanceGroup, String hostname) {
    String availabilityZone = null;
    if (repair) {
        ResourceType resourceType = getSupportedReattachableDiskType(stack);
        if (resourceType != null) {
            List<CloudResource> reattachableDiskResources = resourceRetriever.findAllByStatusAndTypeAndStackAndInstanceGroup(CommonStatus.DETACHED, resourceType, stack.getId(), instanceGroup);
            Optional<CloudResource> reattachableDiskResource = reattachableDiskResources.stream().filter(d -> d.getParameter(ATTRIBUTES, VolumeSetAttributes.class).getDiscoveryFQDN().equals(hostname)).findFirst();
            if (reattachableDiskResource.isPresent()) {
                VolumeSetAttributes volumeSetAttributes = reattachableDiskResource.get().getParameter(ATTRIBUTES, VolumeSetAttributes.class);
                availabilityZone = volumeSetAttributes.getAvailabilityZone();
                LOGGER.debug("Found AZ for the {}: {}", resourceType, availabilityZone);
            } else {
                LOGGER.debug("Cannot find {} for {} in instanceGroup of {}", resourceType, hostname, instanceGroup);
            }
        }
    }
    return availabilityZone;
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ATTRIBUTES(com.sequenceiq.cloudbreak.cloud.model.CloudResource.ATTRIBUTES) InstanceMetaDataRepository(com.sequenceiq.cloudbreak.repository.InstanceMetaDataRepository) Network(com.sequenceiq.cloudbreak.domain.Network) LoggerFactory(org.slf4j.LoggerFactory) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) ResourceRetriever(com.sequenceiq.cloudbreak.cloud.service.ResourceRetriever) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) Service(org.springframework.stereotype.Service) Map(java.util.Map) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) CommonStatus(com.sequenceiq.common.api.type.CommonStatus) ResourceType(com.sequenceiq.common.api.type.ResourceType) NetworkScaleDetails(com.sequenceiq.cloudbreak.core.flow2.dto.NetworkScaleDetails) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Benchmark.measure(com.sequenceiq.cloudbreak.util.Benchmark.measure) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Collection(java.util.Collection) Set(java.util.Set) PageRequest(org.springframework.data.domain.PageRequest) EnvironmentClientService(com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService) AccessDeniedException(org.springframework.security.access.AccessDeniedException) Page(org.springframework.data.domain.Page) VolumeSetAttributes(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes) Collectors(java.util.stream.Collectors) RegionAwareInternalCrnGeneratorFactory(com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory) Objects(java.util.Objects) Json(com.sequenceiq.cloudbreak.common.json.Json) List(java.util.List) MultiAzCalculatorService(com.sequenceiq.cloudbreak.service.multiaz.MultiAzCalculatorService) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Group(com.sequenceiq.cloudbreak.cloud.model.Group) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Optional(java.util.Optional) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) VisibleForTesting(com.google.common.annotations.VisibleForTesting) StackInstanceCount(com.sequenceiq.cloudbreak.domain.projection.StackInstanceCount) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Collections(java.util.Collections) ResourceType(com.sequenceiq.common.api.type.ResourceType) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) VolumeSetAttributes(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 12 with ResourceType

use of com.sequenceiq.common.api.type.ResourceType in project cloudbreak by hortonworks.

the class AzureResourceDeploymentHelperService method pollForCreation.

public void pollForCreation(AuthenticatedContext authenticatedContext, AzureDnsZoneCreationCheckerContext checkerContext) {
    try {
        azureDnsZoneCreationPoller.startPolling(authenticatedContext, checkerContext);
    } catch (CloudConnectorException e) {
        LOGGER.warn("Exception during polling: {}", e.getMessage());
    } finally {
        AzureClient azureClient = checkerContext.getAzureClient();
        CommonStatus deploymentStatus = azureClient.getTemplateDeploymentCommonStatus(checkerContext.getResourceGroupName(), checkerContext.getDeploymentName());
        ResourceType resourceType = StringUtils.isEmpty(checkerContext.getNetworkId()) ? AZURE_PRIVATE_DNS_ZONE : AZURE_VIRTUAL_NETWORK_LINK;
        azureResourcePersistenceHelperService.updateCloudResource(authenticatedContext, checkerContext.getDeploymentName(), checkerContext.getDeploymentId(), deploymentStatus, resourceType);
    }
}
Also used : AzureClient(com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) ResourceType(com.sequenceiq.common.api.type.ResourceType) CommonStatus(com.sequenceiq.common.api.type.CommonStatus)

Aggregations

ResourceType (com.sequenceiq.common.api.type.ResourceType)12 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)9 CloudResourceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus)9 CommonStatus (com.sequenceiq.common.api.type.CommonStatus)7 ArrayList (java.util.ArrayList)7 Collections (java.util.Collections)7 List (java.util.List)7 Map (java.util.Map)7 Optional (java.util.Optional)7 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)6 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)6 Group (com.sequenceiq.cloudbreak.cloud.model.Group)6 Collectors (java.util.stream.Collectors)6 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)5 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)5 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)5 Image (com.sequenceiq.cloudbreak.cloud.model.Image)5 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)5 ResourceStatus (com.sequenceiq.cloudbreak.cloud.model.ResourceStatus)5 VolumeSetAttributes (com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes)5