Search in sources :

Example 1 with AmazonEfsClient

use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEfsClient in project cloudbreak by hortonworks.

the class AwsEfsResourceBuilder method checkResources.

@Override
protected List<CloudResourceStatus> checkResources(ResourceType type, AwsContext context, AuthenticatedContext auth, Iterable<CloudResource> resources) {
    AmazonEfsClient client = getAmazonEfsClient(auth);
    List<CloudResource> efsResources = StreamSupport.stream(resources.spliterator(), false).filter(r -> r.getType().equals(resourceType())).collect(Collectors.toList());
    List<String> efsIds = new ArrayList<>();
    List<CloudResourceStatus> cloudResourceStatusList = new ArrayList<>();
    for (CloudResource efsResource : efsResources) {
        CloudEfsAttributes efsAttributes = efsResource.getParameter(CloudResource.ATTRIBUTES, CloudEfsAttributes.class);
        String efsId = efsAttributes.getFileSystemId();
        efsIds.add(efsId);
        DescribeFileSystemsRequest request = new DescribeFileSystemsRequest().withFileSystemId(efsId);
        DescribeFileSystemsResult result = client.describeFileSystems(request);
        List<CloudResourceStatus> efsStatusList = getResourceStatus(efsResource, efsId, result);
        cloudResourceStatusList.addAll(efsStatusList);
    }
    LOGGER.debug("got EFS status for [{}]", String.join(",", efsIds));
    return cloudResourceStatusList;
}
Also used : AmazonEfsClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEfsClient) DescribeMountTargetsResult(com.amazonaws.services.elasticfilesystem.model.DescribeMountTargetsResult) AmazonElasticFileSystemException(com.amazonaws.services.elasticfilesystem.model.AmazonElasticFileSystemException) AsyncTaskExecutor(org.springframework.core.task.AsyncTaskExecutor) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) AmazonEfsClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEfsClient) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Future(java.util.concurrent.Future) AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) AwsContext(com.sequenceiq.cloudbreak.cloud.aws.common.context.AwsContext) Map(java.util.Map) Qualifier(org.springframework.beans.factory.annotation.Qualifier) StreamSupport(java.util.stream.StreamSupport) DescribeMountTargetsRequest(com.amazonaws.services.elasticfilesystem.model.DescribeMountTargetsRequest) CommonStatus(com.sequenceiq.common.api.type.CommonStatus) ResourceType(com.sequenceiq.common.api.type.ResourceType) Logger(org.slf4j.Logger) CreateFileSystemRequest(com.amazonaws.services.elasticfilesystem.model.CreateFileSystemRequest) DescribeFileSystemsResult(com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsResult) FileSystemDescription(com.amazonaws.services.elasticfilesystem.model.FileSystemDescription) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Collection(java.util.Collection) CloudResourceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus) DescribeFileSystemsRequest(com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsRequest) Tag(com.amazonaws.services.elasticfilesystem.model.Tag) Collectors(java.util.stream.Collectors) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) CreateFileSystemResult(com.amazonaws.services.elasticfilesystem.model.CreateFileSystemResult) List(java.util.List) Component(org.springframework.stereotype.Component) DeleteMountTargetRequest(com.amazonaws.services.elasticfilesystem.model.DeleteMountTargetRequest) LifeCycleState(com.sequenceiq.cloudbreak.cloud.model.filesystem.efs.LifeCycleState) MountTargetDescription(com.amazonaws.services.elasticfilesystem.model.MountTargetDescription) CloudEfsAttributes(com.sequenceiq.cloudbreak.cloud.model.CloudEfsAttributes) Group(com.sequenceiq.cloudbreak.cloud.model.Group) Optional(java.util.Optional) DeleteFileSystemRequest(com.amazonaws.services.elasticfilesystem.model.DeleteFileSystemRequest) CommonAwsClient(com.sequenceiq.cloudbreak.cloud.aws.common.CommonAwsClient) Collections(java.util.Collections) AwsTaggingService(com.sequenceiq.cloudbreak.cloud.aws.common.AwsTaggingService) StringUtils(org.springframework.util.StringUtils) CloudEfsAttributes(com.sequenceiq.cloudbreak.cloud.model.CloudEfsAttributes) CloudResourceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus) ArrayList(java.util.ArrayList) DescribeFileSystemsRequest(com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsRequest) DescribeFileSystemsResult(com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsResult) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource)

Example 2 with AmazonEfsClient

use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEfsClient in project cloudbreak by hortonworks.

the class AwsEfsResourceBuilder method build.

@Override
public List<CloudResource> build(AwsContext context, CloudInstance instance, long privateId, AuthenticatedContext auth, Group group, List<CloudResource> buildableResource, CloudStack cloudStack) throws Exception {
    LOGGER.debug("Create EFS on provider" + buildableResource.stream().map(CloudResource::getName).collect(Collectors.toList()));
    AmazonEfsClient client = getAmazonEfsClient(auth);
    Map<String, CloudEfsAttributes> efsSetMap = Collections.synchronizedMap(new HashMap<>());
    List<Future<?>> futures = new ArrayList<>();
    List<CloudResource> requestedResources = buildableResource.stream().filter(cloudResource -> CommonStatus.REQUESTED.equals(cloudResource.getStatus())).collect(Collectors.toList());
    LOGGER.debug("Start creating EFS for stack: '{}' group: '{}'", auth.getCloudContext().getName(), group.getName());
    futures.addAll(requestedResources.stream().map(requestedResource -> creatEfsRequest(requestedResource, cloudStack, efsSetMap)).map(request -> intermediateBuilderExecutor.submit(() -> {
        CreateFileSystemResult result = client.createFileSystem(request);
        CloudEfsAttributes resultAttributes = getResultEfsAttributes(request, result, efsSetMap);
        efsSetMap.put(resultAttributes.getName(), resultAttributes);
    })).collect(Collectors.toList()));
    LOGGER.debug("Waiting for EFS creation requests");
    for (Future<?> future : futures) {
        future.get();
    }
    LOGGER.debug("EFS creation requests sent");
    return buildableResource.stream().peek(resource -> {
        CloudEfsAttributes resultEfsAttributes = efsSetMap.getOrDefault(resource.getName(), null);
        if (resultEfsAttributes != null) {
            CloudEfsAttributes resourceEfsAttributes = resource.getParameter(CloudResource.ATTRIBUTES, CloudEfsAttributes.class);
            resourceEfsAttributes.setFileSystemId(resultEfsAttributes.getFileSystemId());
            resourceEfsAttributes.setFileState(resultEfsAttributes.getFileState());
        }
    }).map(copyResourceWithCreatedStatus()).collect(Collectors.toList());
}
Also used : AmazonEfsClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEfsClient) DescribeMountTargetsResult(com.amazonaws.services.elasticfilesystem.model.DescribeMountTargetsResult) AmazonElasticFileSystemException(com.amazonaws.services.elasticfilesystem.model.AmazonElasticFileSystemException) AsyncTaskExecutor(org.springframework.core.task.AsyncTaskExecutor) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) AmazonEfsClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEfsClient) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Future(java.util.concurrent.Future) AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) AwsContext(com.sequenceiq.cloudbreak.cloud.aws.common.context.AwsContext) Map(java.util.Map) Qualifier(org.springframework.beans.factory.annotation.Qualifier) StreamSupport(java.util.stream.StreamSupport) DescribeMountTargetsRequest(com.amazonaws.services.elasticfilesystem.model.DescribeMountTargetsRequest) CommonStatus(com.sequenceiq.common.api.type.CommonStatus) ResourceType(com.sequenceiq.common.api.type.ResourceType) Logger(org.slf4j.Logger) CreateFileSystemRequest(com.amazonaws.services.elasticfilesystem.model.CreateFileSystemRequest) DescribeFileSystemsResult(com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsResult) FileSystemDescription(com.amazonaws.services.elasticfilesystem.model.FileSystemDescription) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Collection(java.util.Collection) CloudResourceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus) DescribeFileSystemsRequest(com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsRequest) Tag(com.amazonaws.services.elasticfilesystem.model.Tag) Collectors(java.util.stream.Collectors) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) CreateFileSystemResult(com.amazonaws.services.elasticfilesystem.model.CreateFileSystemResult) List(java.util.List) Component(org.springframework.stereotype.Component) DeleteMountTargetRequest(com.amazonaws.services.elasticfilesystem.model.DeleteMountTargetRequest) LifeCycleState(com.sequenceiq.cloudbreak.cloud.model.filesystem.efs.LifeCycleState) MountTargetDescription(com.amazonaws.services.elasticfilesystem.model.MountTargetDescription) CloudEfsAttributes(com.sequenceiq.cloudbreak.cloud.model.CloudEfsAttributes) Group(com.sequenceiq.cloudbreak.cloud.model.Group) Optional(java.util.Optional) DeleteFileSystemRequest(com.amazonaws.services.elasticfilesystem.model.DeleteFileSystemRequest) CommonAwsClient(com.sequenceiq.cloudbreak.cloud.aws.common.CommonAwsClient) Collections(java.util.Collections) AwsTaggingService(com.sequenceiq.cloudbreak.cloud.aws.common.AwsTaggingService) StringUtils(org.springframework.util.StringUtils) CloudEfsAttributes(com.sequenceiq.cloudbreak.cloud.model.CloudEfsAttributes) ArrayList(java.util.ArrayList) CreateFileSystemResult(com.amazonaws.services.elasticfilesystem.model.CreateFileSystemResult) Future(java.util.concurrent.Future) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource)

Example 3 with AmazonEfsClient

use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEfsClient in project cloudbreak by hortonworks.

the class AwsEfsResourceBuilder method delete.

@Override
public CloudResource delete(AwsContext context, AuthenticatedContext auth, CloudResource resource) throws InterruptedException {
    // 
    // https://docs.aws.amazon.com/efs/latest/ug/wt1-clean-up.html
    // To delete an EFS instance, need the following steps
    // 1. Terminate the EC2 instances that mount on this EFS. The caller of this function has to make sure it is done before calling this function
    // 2. Delete the mount targets of this EFS.
    // 3. (Optional) Delete the security group of each mount target. AWS does not charge for security groups
    // 4. (Optional) Delete the security group of the EC2 instances at step 1. The mount target's security group has a rule that references
    // the EC2 security group. Therefore, we cannot first delete the EC2 instance's security group.
    // 5. Actually delete the EFS
    // 
    AmazonEfsClient client = getAmazonEfsClient(auth);
    CloudEfsAttributes efsAttributes = resource.getParameter(CloudResource.ATTRIBUTES, CloudEfsAttributes.class);
    String efsId = efsAttributes.getFileSystemId();
    DescribeFileSystemsRequest request = new DescribeFileSystemsRequest().withFileSystemId(efsId);
    DescribeFileSystemsResult result = client.describeFileSystems(request);
    List<FileSystemDescription> efsDescriptions = result.getFileSystems();
    for (FileSystemDescription efsDescription : efsDescriptions) {
        LifeCycleState efsLifeCycleState = LifeCycleState.fromValue(efsDescription.getLifeCycleState());
        if (LifeCycleState.DELETED.equals(efsLifeCycleState) || LifeCycleState.DELETING.equals(efsLifeCycleState)) {
            LOGGER.debug("The given AWS EFS's [name: {}] lifecycle state was [{}] hence we are going to skip any delete operation over this resource", efsDescription.getName(), efsLifeCycleState);
            continue;
        }
        if (efsDescription.getNumberOfMountTargets() > 0) {
            DescribeMountTargetsRequest mtRequest = new DescribeMountTargetsRequest().withFileSystemId(efsId);
            DescribeMountTargetsResult mtResult = client.describeMountTargets(mtRequest);
            List<MountTargetDescription> mountTargetDescriptionList = mtResult.getMountTargets();
            // Only delete the mount targets.
            for (MountTargetDescription mtDescription : mountTargetDescriptionList) {
                DeleteMountTargetRequest mtDelRequest = new DeleteMountTargetRequest().withMountTargetId(mtDescription.getMountTargetId());
                LOGGER.debug("About to delete AWS EFS mount target that has the following id: {}", mtDescription.getMountTargetId());
                client.deleteMountTarget(mtDelRequest);
            }
        // TODO: delete the security groups in the future
        }
        DeleteFileSystemRequest efsDelRequest = new DeleteFileSystemRequest().withFileSystemId(efsId);
        client.deleteFileSystem(efsDelRequest);
    }
    return null;
}
Also used : AmazonEfsClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEfsClient) CloudEfsAttributes(com.sequenceiq.cloudbreak.cloud.model.CloudEfsAttributes) DescribeMountTargetsResult(com.amazonaws.services.elasticfilesystem.model.DescribeMountTargetsResult) MountTargetDescription(com.amazonaws.services.elasticfilesystem.model.MountTargetDescription) DescribeMountTargetsRequest(com.amazonaws.services.elasticfilesystem.model.DescribeMountTargetsRequest) DescribeFileSystemsRequest(com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsRequest) DeleteFileSystemRequest(com.amazonaws.services.elasticfilesystem.model.DeleteFileSystemRequest) DeleteMountTargetRequest(com.amazonaws.services.elasticfilesystem.model.DeleteMountTargetRequest) LifeCycleState(com.sequenceiq.cloudbreak.cloud.model.filesystem.efs.LifeCycleState) DescribeFileSystemsResult(com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsResult) FileSystemDescription(com.amazonaws.services.elasticfilesystem.model.FileSystemDescription)

Example 4 with AmazonEfsClient

use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEfsClient in project cloudbreak by hortonworks.

the class AwsLaunchTest method launchStackWithEfs.

@Test
public void launchStackWithEfs() throws Exception {
    setup();
    setupRetryService();
    setupFreemarkerTemplateProcessing();
    setupDescribeStacksResponses();
    setupDescribeImagesResponse();
    setupDescribeStackResourceResponse();
    setupAutoscalingResponses();
    setupDescribeInstancesResponse();
    setupCreateVolumeResponse();
    setupDescribeVolumeResponse();
    setupDescribeSubnetResponse();
    setupDescribePrefixListsResponse();
    setupCreateFileSystem();
    setupDescribeFileSystems();
    setupDescribeMountTargets();
    setupDeleteMountTarget();
    setupDeleteFileSystem();
    InMemoryStateStore.putStack(1L, PollGroup.POLLABLE);
    AuthenticatedContext authenticatedContext = componentTestUtil.getAuthenticatedContext();
    authenticatedContext.putParameter(AmazonEc2Client.class, amazonEc2Client);
    authenticatedContext.putParameter(AmazonElasticFileSystemClient.class, amazonElasticFileSystemClient);
    authenticatedContext.putParameter(AmazonEfsClient.class, amazonEfsClient);
    awsResourceConnector.launch(authenticatedContext, componentTestUtil.getStackForLaunch(InstanceStatus.CREATE_REQUESTED, InstanceStatus.CREATE_REQUESTED), persistenceNotifier, new AdjustmentTypeWithThreshold(AdjustmentType.EXACT, Long.MAX_VALUE));
    // assert
    verify(persistenceNotifier).notifyAllocation(argThat(cloudResource -> ResourceType.AWS_VPC.equals(cloudResource.getType())), any());
    verify(persistenceNotifier, times(2)).notifyAllocation(argThat(cloudResource -> ResourceType.AWS_VOLUMESET.equals(cloudResource.getType())), any());
    verify(persistenceNotifier).notifyAllocation(argThat(cloudResource -> ResourceType.AWS_SUBNET.equals(cloudResource.getType())), any());
    verify(persistenceNotifier).notifyAllocation(argThat(cloudResource -> ResourceType.CLOUDFORMATION_STACK.equals(cloudResource.getType())), any());
    InOrder inOrder = inOrder(amazonElasticFileSystemClient, amazonEfsClient, amazonCloudFormationClient, amazonEc2Client);
    inOrder.verify(amazonEc2Client).describeImages(any());
    inOrder.verify(amazonCloudFormationClient).createStack(any());
    inOrder.verify(amazonEc2Client, times(2)).createVolume(any());
    inOrder.verify(amazonEc2Client, times(2)).attachVolume(any());
    inOrder.verify(amazonEc2Client, never()).describePrefixLists();
}
Also used : DescribeMountTargetsResult(com.amazonaws.services.elasticfilesystem.model.DescribeMountTargetsResult) Arrays(java.util.Arrays) DescribeSubnetsRequest(com.amazonaws.services.ec2.model.DescribeSubnetsRequest) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ActiveProfiles(org.springframework.test.context.ActiveProfiles) AmazonCloudWatchClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonCloudWatchClient) DescribeStacksResult(com.amazonaws.services.cloudformation.model.DescribeStacksResult) DescribeSubnetsResult(com.amazonaws.services.ec2.model.DescribeSubnetsResult) AmazonEC2Waiters(com.amazonaws.services.ec2.waiters.AmazonEC2Waiters) AmazonCloudFormationClient(com.sequenceiq.cloudbreak.cloud.aws.client.AmazonCloudFormationClient) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) DescribeInstancesRequest(com.amazonaws.services.ec2.model.DescribeInstancesRequest) DescribeScalingActivitiesRequest(com.amazonaws.services.autoscaling.model.DescribeScalingActivitiesRequest) SpringRunner(org.springframework.test.context.junit4.SpringRunner) AmazonAutoScalingWaiters(com.amazonaws.services.autoscaling.waiters.AmazonAutoScalingWaiters) Waiter(com.amazonaws.waiters.Waiter) MockBean(org.springframework.boot.test.mock.mockito.MockBean) Reservation(com.amazonaws.services.ec2.model.Reservation) LifeCycleState(com.amazonaws.services.elasticfilesystem.model.LifeCycleState) DescribeFileSystemsResult(com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsResult) AmazonServiceException(com.amazonaws.AmazonServiceException) AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) Output(com.amazonaws.services.cloudformation.model.Output) DescribeVolumesResult(com.amazonaws.services.ec2.model.DescribeVolumesResult) DescribeInstancesResult(com.amazonaws.services.ec2.model.DescribeInstancesResult) TestPropertySource(org.springframework.test.context.TestPropertySource) AmazonCloudFormationWaiters(com.amazonaws.services.cloudformation.waiters.AmazonCloudFormationWaiters) Retry(com.sequenceiq.cloudbreak.service.Retry) FreeMarkerTemplateUtils(com.sequenceiq.cloudbreak.util.FreeMarkerTemplateUtils) AwsResourceConnector(com.sequenceiq.cloudbreak.cloud.aws.connector.resource.AwsResourceConnector) CreateFileSystemResult(com.amazonaws.services.elasticfilesystem.model.CreateFileSystemResult) AdjustmentType(com.sequenceiq.common.api.type.AdjustmentType) AmazonAutoScalingClient(com.sequenceiq.cloudbreak.cloud.aws.client.AmazonAutoScalingClient) VolumeState(com.amazonaws.services.ec2.model.VolumeState) Mockito.inOrder(org.mockito.Mockito.inOrder) DeleteFileSystemResult(com.amazonaws.services.elasticfilesystem.model.DeleteFileSystemResult) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) LocationHelper(com.sequenceiq.cloudbreak.cloud.storage.LocationHelper) Mock(org.mockito.Mock) DescribeStacksRequest(com.amazonaws.services.cloudformation.model.DescribeStacksRequest) AVAILABILITY_ZONE(com.sequenceiq.cloudbreak.cloud.aws.component.ComponentTestUtil.AVAILABILITY_ZONE) RunWith(org.junit.runner.RunWith) AmazonEfsClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEfsClient) ResourceRetriever(com.sequenceiq.cloudbreak.cloud.service.ResourceRetriever) Supplier(java.util.function.Supplier) StackResourceDetail(com.amazonaws.services.cloudformation.model.StackResourceDetail) Inject(javax.inject.Inject) CreateVolumeResult(com.amazonaws.services.ec2.model.CreateVolumeResult) Answer(org.mockito.stubbing.Answer) AmazonEc2Client(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEc2Client) DescribeAutoScalingGroupsResult(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult) DescribeVolumesRequest(com.amazonaws.services.ec2.model.DescribeVolumesRequest) DeleteMountTargetResult(com.amazonaws.services.elasticfilesystem.model.DeleteMountTargetResult) DescribeImagesResult(com.amazonaws.services.ec2.model.DescribeImagesResult) ResourceType(com.sequenceiq.common.api.type.ResourceType) InOrder(org.mockito.InOrder) AmazonElasticFileSystemClient(com.amazonaws.services.elasticfilesystem.AmazonElasticFileSystemClient) FileSystemDescription(com.amazonaws.services.elasticfilesystem.model.FileSystemDescription) DescribeScalingActivitiesResult(com.amazonaws.services.autoscaling.model.DescribeScalingActivitiesResult) AwsCloudFormationClient(com.sequenceiq.cloudbreak.cloud.aws.AwsCloudFormationClient) AdjustmentTypeWithThreshold(com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold) DescribePrefixListsResult(com.amazonaws.services.ec2.model.DescribePrefixListsResult) InMemoryStateStore(com.sequenceiq.cloudbreak.cloud.store.InMemoryStateStore) Import(org.springframework.context.annotation.Import) Mockito.times(org.mockito.Mockito.times) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Stack(com.amazonaws.services.cloudformation.model.Stack) PersistenceNotifier(com.sequenceiq.cloudbreak.cloud.notification.PersistenceNotifier) LifecycleState(com.amazonaws.services.autoscaling.model.LifecycleState) Mockito.verify(org.mockito.Mockito.verify) DescribeAutoScalingGroupsRequest(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest) Mockito.never(org.mockito.Mockito.never) MountTargetDescription(com.amazonaws.services.elasticfilesystem.model.MountTargetDescription) CustomAmazonWaiterProvider(com.sequenceiq.cloudbreak.cloud.aws.scheduler.CustomAmazonWaiterProvider) InstanceStatus(com.sequenceiq.cloudbreak.cloud.model.InstanceStatus) Instance(com.amazonaws.services.autoscaling.model.Instance) DescribeStackResourceResult(com.amazonaws.services.cloudformation.model.DescribeStackResourceResult) CommonAwsClient(com.sequenceiq.cloudbreak.cloud.aws.common.CommonAwsClient) PollGroup(com.sequenceiq.cloudbreak.cloud.scheduler.PollGroup) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) InOrder(org.mockito.InOrder) AdjustmentTypeWithThreshold(com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) Test(org.junit.Test)

Example 5 with AmazonEfsClient

use of com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEfsClient in project cloudbreak by hortonworks.

the class CloudFormationStackUtil method getEfsByFileSystemId.

public FileSystemDescription getEfsByFileSystemId(AuthenticatedContext ac, String fileSystemId) {
    String region = ac.getCloudContext().getLocation().getRegion().value();
    AmazonEfsClient amazonEfsClient = awsClient.createElasticFileSystemClient(new AwsCredentialView(ac.getCloudCredential()), region);
    DescribeFileSystemsResult efsResult = amazonEfsClient.describeFileSystems(new DescribeFileSystemsRequest().withFileSystemId(fileSystemId));
    return efsResult.getFileSystems().get(0);
}
Also used : AmazonEfsClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEfsClient) AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) DescribeFileSystemsResult(com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsResult) DescribeFileSystemsRequest(com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsRequest)

Aggregations

DescribeFileSystemsResult (com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsResult)5 AmazonEfsClient (com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEfsClient)5 DescribeFileSystemsRequest (com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsRequest)4 DescribeMountTargetsResult (com.amazonaws.services.elasticfilesystem.model.DescribeMountTargetsResult)4 FileSystemDescription (com.amazonaws.services.elasticfilesystem.model.FileSystemDescription)4 MountTargetDescription (com.amazonaws.services.elasticfilesystem.model.MountTargetDescription)4 CreateFileSystemResult (com.amazonaws.services.elasticfilesystem.model.CreateFileSystemResult)3 DeleteFileSystemRequest (com.amazonaws.services.elasticfilesystem.model.DeleteFileSystemRequest)3 DeleteMountTargetRequest (com.amazonaws.services.elasticfilesystem.model.DeleteMountTargetRequest)3 DescribeMountTargetsRequest (com.amazonaws.services.elasticfilesystem.model.DescribeMountTargetsRequest)3 CommonAwsClient (com.sequenceiq.cloudbreak.cloud.aws.common.CommonAwsClient)3 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView)3 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)3 CloudEfsAttributes (com.sequenceiq.cloudbreak.cloud.model.CloudEfsAttributes)3 LifeCycleState (com.sequenceiq.cloudbreak.cloud.model.filesystem.efs.LifeCycleState)3 ResourceType (com.sequenceiq.common.api.type.ResourceType)3 Inject (javax.inject.Inject)3 AmazonServiceException (com.amazonaws.AmazonServiceException)1 AutoScalingGroup (com.amazonaws.services.autoscaling.model.AutoScalingGroup)1 DescribeAutoScalingGroupsRequest (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest)1