Search in sources :

Example 1 with DescribeStackResourceResult

use of com.amazonaws.services.cloudformation.model.DescribeStackResourceResult in project cloudbreak by hortonworks.

the class CloudFormationStackUtil method getAutoscalingGroupName.

public String getAutoscalingGroupName(AuthenticatedContext ac, AmazonCloudFormation amazonCFClient, String instanceGroup) {
    String cFStackName = getCfStackName(ac);
    DescribeStackResourceResult asGroupResource = amazonCFClient.describeStackResource(new DescribeStackResourceRequest().withStackName(cFStackName).withLogicalResourceId(String.format("AmbariNodes%s", instanceGroup.replaceAll("_", ""))));
    return asGroupResource.getStackResourceDetail().getPhysicalResourceId();
}
Also used : DescribeStackResourceRequest(com.amazonaws.services.cloudformation.model.DescribeStackResourceRequest) DescribeStackResourceResult(com.amazonaws.services.cloudformation.model.DescribeStackResourceResult)

Example 2 with DescribeStackResourceResult

use of com.amazonaws.services.cloudformation.model.DescribeStackResourceResult in project cloudbreak by hortonworks.

the class AwsRepairTest method downscaleStack.

private void downscaleStack() throws IOException {
    when(amazonEC2Client.describeVolumes(any())).thenReturn(new DescribeVolumesResult().withVolumes(new com.amazonaws.services.ec2.model.Volume().withVolumeId(VOLUME_ID_1).withState(VolumeState.InUse), new com.amazonaws.services.ec2.model.Volume().withVolumeId(VOLUME_ID_2).withState(VolumeState.InUse)));
    when(amazonCloudFormationClient.describeStackResource(any())).thenReturn(new DescribeStackResourceResult().withStackResourceDetail(new StackResourceDetail().withPhysicalResourceId(AUTOSCALING_GROUP_NAME)));
    when(amazonEC2Client.describeInstances(any(DescribeInstancesRequest.class))).thenAnswer(a -> {
        DescribeInstancesRequest request = a.getArgument(0, DescribeInstancesRequest.class);
        List<com.amazonaws.services.ec2.model.Instance> instances = request.getInstanceIds().stream().map(i -> new com.amazonaws.services.ec2.model.Instance().withInstanceId(i)).collect(Collectors.toList());
        return new DescribeInstancesResult().withReservations(new Reservation().withInstances(instances));
    });
    AmazonEC2Waiters mockWaiter = mock(AmazonEC2Waiters.class);
    when(amazonEC2Client.waiters()).thenReturn(mockWaiter);
    when(mockWaiter.instanceTerminated()).thenReturn(mock(Waiter.class));
    DescribeAutoScalingGroupsResult describeAutoScalingGroupsResult = new DescribeAutoScalingGroupsResult();
    AutoScalingGroup autoScalingGroup = new AutoScalingGroup();
    autoScalingGroup.setInstances(List.of(new Instance().withInstanceId(INSTANCE_ID_1), new Instance().withInstanceId(INSTANCE_ID_2), new Instance().withInstanceId(INSTANCE_ID_3)));
    describeAutoScalingGroupsResult.setAutoScalingGroups(List.of(autoScalingGroup));
    when(amazonAutoScalingClient.describeAutoScalingGroups(any())).thenReturn(describeAutoScalingGroupsResult);
    List<Volume> volumes = List.of();
    InstanceTemplate instanceTemplate = new InstanceTemplate("", WORKER_GROUP, 0L, volumes, InstanceStatus.STARTED, Map.of(), 0L, IMAGE_ID, TemporaryStorage.ATTACHED_VOLUMES, 0L);
    InstanceAuthentication authentication = new InstanceAuthentication("publicKey", "publicKeyId", "cloudbreak");
    CloudInstance firstCloudInstance = new CloudInstance(INSTANCE_ID_1, instanceTemplate, authentication, "subnet-1", "az1");
    CloudInstance secondCloudInstance = new CloudInstance(INSTANCE_ID_2, instanceTemplate, authentication, "subnet-1", "az1");
    List<CloudInstance> cloudInstancesToRemove = List.of(firstCloudInstance, secondCloudInstance);
    CloudResource instance1VolumeResource = createVolumeResource(VOLUME_ID_1, INSTANCE_ID_1, SIZE_DISK_1, FSTAB_1, CommonStatus.CREATED);
    CloudResource instance2VolumeResource = createVolumeResource(VOLUME_ID_2, INSTANCE_ID_2, SIZE_DISK_2, FSTAB_2, CommonStatus.CREATED);
    List<CloudResource> resources = List.of(instance1VolumeResource, instance2VolumeResource);
    AuthenticatedContext authenticatedContext = componentTestUtil.getAuthenticatedContext();
    CloudStack cloudStack = componentTestUtil.getStack(InstanceStatus.DELETE_REQUESTED, InstanceStatus.CREATE_REQUESTED);
    underTest.downscale(authenticatedContext, cloudStack, resources, cloudInstancesToRemove, null);
    verify(persistenceNotifier).notifyUpdate(argThat(cloudResource -> ResourceType.AWS_VOLUMESET.equals(cloudResource.getType()) && VOLUME_ID_1.equals(cloudResource.getName()) && INSTANCE_ID_1.equals(cloudResource.getInstanceId()) && CommonStatus.DETACHED.equals(cloudResource.getStatus()) && cloudResource.getParameter(CloudResource.ATTRIBUTES, VolumeSetAttributes.class).getDeleteOnTermination()), eq(authenticatedContext.getCloudContext()));
    verify(persistenceNotifier).notifyUpdate(argThat(cloudResource -> ResourceType.AWS_VOLUMESET.equals(cloudResource.getType()) && VOLUME_ID_2.equals(cloudResource.getName()) && INSTANCE_ID_2.equals(cloudResource.getInstanceId()) && CommonStatus.DETACHED.equals(cloudResource.getStatus()) && cloudResource.getParameter(CloudResource.ATTRIBUTES, VolumeSetAttributes.class).getDeleteOnTermination()), eq(authenticatedContext.getCloudContext()));
    verify(amazonAutoScalingClient).detachInstances(argThat(argument -> argument.getAutoScalingGroupName().equals(AUTOSCALING_GROUP_NAME) && argument.getShouldDecrementDesiredCapacity() && argument.getInstanceIds().size() == 2 && argument.getInstanceIds().contains(INSTANCE_ID_1) && argument.getInstanceIds().contains(INSTANCE_ID_2)));
    verify(amazonEC2Client).terminateInstances(argThat(argument -> argument.getInstanceIds().size() == 2 && argument.getInstanceIds().contains(INSTANCE_ID_1) && argument.getInstanceIds().contains(INSTANCE_ID_2)));
    verify(amazonAutoScalingClient).updateAutoScalingGroup(argThat(argument -> argument.getAutoScalingGroupName().equals(AUTOSCALING_GROUP_NAME) && argument.getMaxSize().equals(1)));
}
Also used : Arrays(java.util.Arrays) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) AmazonCloudWatchClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonCloudWatchClient) AmazonEC2Waiters(com.amazonaws.services.ec2.waiters.AmazonEC2Waiters) Arrays.asList(java.util.Arrays.asList) DescribeInstancesRequest(com.amazonaws.services.ec2.model.DescribeInstancesRequest) Map(java.util.Map) MockBean(org.springframework.boot.test.mock.mockito.MockBean) CommonStatus(com.sequenceiq.common.api.type.CommonStatus) LifeCycleState(com.amazonaws.services.elasticfilesystem.model.LifeCycleState) CloudVolumeUsageType(com.sequenceiq.cloudbreak.cloud.model.CloudVolumeUsageType) DescribeFileSystemsResult(com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsResult) AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) TestPropertySource(org.springframework.test.context.TestPropertySource) VolumeSetAttributes(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes) Retry(com.sequenceiq.cloudbreak.service.Retry) 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) SIZE_DISK_1(com.sequenceiq.cloudbreak.cloud.aws.component.ComponentTestUtil.SIZE_DISK_1) SIZE_DISK_2(com.sequenceiq.cloudbreak.cloud.aws.component.ComponentTestUtil.SIZE_DISK_2) Mockito.mock(org.mockito.Mockito.mock) 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) Supplier(java.util.function.Supplier) StackResourceDetail(com.amazonaws.services.cloudformation.model.StackResourceDetail) ResourceNotifier(com.sequenceiq.cloudbreak.cloud.notification.ResourceNotifier) AmazonEc2Client(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEc2Client) DeleteMountTargetResult(com.amazonaws.services.elasticfilesystem.model.DeleteMountTargetResult) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) DescribeScalingActivitiesResult(com.amazonaws.services.autoscaling.model.DescribeScalingActivitiesResult) AwsCloudFormationClient(com.sequenceiq.cloudbreak.cloud.aws.AwsCloudFormationClient) InMemoryStateStore(com.sequenceiq.cloudbreak.cloud.store.InMemoryStateStore) Assert.assertTrue(org.junit.Assert.assertTrue) Import(org.springframework.context.annotation.Import) Mockito.times(org.mockito.Mockito.times) IOException(java.io.IOException) Test(org.junit.Test) PersistenceNotifier(com.sequenceiq.cloudbreak.cloud.notification.PersistenceNotifier) LifecycleState(com.amazonaws.services.autoscaling.model.LifecycleState) INSTANCE_ID_1(com.sequenceiq.cloudbreak.cloud.aws.component.ComponentTestUtil.INSTANCE_ID_1) InstanceStatus(com.sequenceiq.cloudbreak.cloud.model.InstanceStatus) INSTANCE_ID_2(com.sequenceiq.cloudbreak.cloud.aws.component.ComponentTestUtil.INSTANCE_ID_2) INSTANCE_ID_3(com.sequenceiq.cloudbreak.cloud.aws.component.ComponentTestUtil.INSTANCE_ID_3) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) DescribeStackResourceResult(com.amazonaws.services.cloudformation.model.DescribeStackResourceResult) PollGroup(com.sequenceiq.cloudbreak.cloud.scheduler.PollGroup) Assert.assertEquals(org.junit.Assert.assertEquals) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DescribeMountTargetsResult(com.amazonaws.services.elasticfilesystem.model.DescribeMountTargetsResult) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ActiveProfiles(org.springframework.test.context.ActiveProfiles) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) AmazonCloudFormationClient(com.sequenceiq.cloudbreak.cloud.aws.client.AmazonCloudFormationClient) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) DescribeScalingActivitiesRequest(com.amazonaws.services.autoscaling.model.DescribeScalingActivitiesRequest) Assert.fail(org.junit.Assert.fail) SpringRunner(org.springframework.test.context.junit4.SpringRunner) AmazonAutoScalingWaiters(com.amazonaws.services.autoscaling.waiters.AmazonAutoScalingWaiters) Waiter(com.amazonaws.waiters.Waiter) Reservation(com.amazonaws.services.ec2.model.Reservation) DescribeVolumesResult(com.amazonaws.services.ec2.model.DescribeVolumesResult) DescribeInstancesResult(com.amazonaws.services.ec2.model.DescribeInstancesResult) AmazonCloudFormationWaiters(com.amazonaws.services.cloudformation.waiters.AmazonCloudFormationWaiters) Collectors(java.util.stream.Collectors) TemporaryStorage(com.sequenceiq.cloudbreak.common.type.TemporaryStorage) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) List(java.util.List) Group(com.sequenceiq.cloudbreak.cloud.model.Group) DeleteFileSystemResult(com.amazonaws.services.elasticfilesystem.model.DeleteFileSystemResult) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) HashMap(java.util.HashMap) AwsMetadataCollector(com.sequenceiq.cloudbreak.cloud.aws.AwsMetadataCollector) ResourceRetriever(com.sequenceiq.cloudbreak.cloud.service.ResourceRetriever) Inject(javax.inject.Inject) ArgumentCaptor(org.mockito.ArgumentCaptor) DescribeAutoScalingGroupsResult(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult) ResourceType(com.sequenceiq.common.api.type.ResourceType) FileSystemDescription(com.amazonaws.services.elasticfilesystem.model.FileSystemDescription) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) AdjustmentTypeWithThreshold(com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) DescribeAutoScalingGroupsRequest(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest) Mockito(org.mockito.Mockito) MountTargetDescription(com.amazonaws.services.elasticfilesystem.model.MountTargetDescription) CustomAmazonWaiterProvider(com.sequenceiq.cloudbreak.cloud.aws.scheduler.CustomAmazonWaiterProvider) DescribeAlarmsResult(com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult) Instance(com.amazonaws.services.autoscaling.model.Instance) Volume(com.sequenceiq.cloudbreak.cloud.model.Volume) CommonAwsClient(com.sequenceiq.cloudbreak.cloud.aws.common.CommonAwsClient) Collections(java.util.Collections) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Instance(com.amazonaws.services.autoscaling.model.Instance) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) StackResourceDetail(com.amazonaws.services.cloudformation.model.StackResourceDetail) Reservation(com.amazonaws.services.ec2.model.Reservation) DescribeStackResourceResult(com.amazonaws.services.cloudformation.model.DescribeStackResourceResult) AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) DescribeInstancesRequest(com.amazonaws.services.ec2.model.DescribeInstancesRequest) AmazonEC2Waiters(com.amazonaws.services.ec2.waiters.AmazonEC2Waiters) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) DescribeInstancesResult(com.amazonaws.services.ec2.model.DescribeInstancesResult) Volume(com.sequenceiq.cloudbreak.cloud.model.Volume) DescribeAutoScalingGroupsResult(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) DescribeVolumesResult(com.amazonaws.services.ec2.model.DescribeVolumesResult) Waiter(com.amazonaws.waiters.Waiter) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)

Example 3 with DescribeStackResourceResult

use of com.amazonaws.services.cloudformation.model.DescribeStackResourceResult in project cloudbreak by hortonworks.

the class AwsLaunchTest method setupDescribeStackResourceResponse.

private void setupDescribeStackResourceResponse() {
    StackResourceDetail stackResourceDetail = new StackResourceDetail().withPhysicalResourceId(AUTOSCALING_GROUP_NAME);
    DescribeStackResourceResult describeStackResourceResult = new DescribeStackResourceResult().withStackResourceDetail(stackResourceDetail);
    when(amazonCloudFormationClient.describeStackResource(any())).thenReturn(describeStackResourceResult);
}
Also used : StackResourceDetail(com.amazonaws.services.cloudformation.model.StackResourceDetail) DescribeStackResourceResult(com.amazonaws.services.cloudformation.model.DescribeStackResourceResult)

Example 4 with DescribeStackResourceResult

use of com.amazonaws.services.cloudformation.model.DescribeStackResourceResult in project cloudbreak by hortonworks.

the class AwsRepairTest method upscaleStack.

private void upscaleStack() throws Exception {
    AuthenticatedContext authenticatedContext = componentTestUtil.getAuthenticatedContext();
    CloudStack stack = componentTestUtil.getStack(InstanceStatus.CREATE_REQUESTED, InstanceStatus.STARTED);
    List<CloudResource> cloudResources = List.of(CloudResource.builder().name(AWS_SUBNET_ID).type(ResourceType.AWS_SUBNET).build(), createVolumeResource(VOLUME_ID_1, INSTANCE_ID_1, SIZE_DISK_1, FSTAB_1, CommonStatus.DETACHED), createVolumeResource(VOLUME_ID_2, INSTANCE_ID_2, SIZE_DISK_2, FSTAB_2, CommonStatus.DETACHED), createVolumeResource(VOLUME_ID_3, INSTANCE_ID_3, SIZE_DISK_2, FSTAB_2, CommonStatus.CREATED));
    InMemoryStateStore.putStack(1L, PollGroup.POLLABLE);
    when(amazonCloudFormationClient.describeStackResource(any())).thenReturn(new DescribeStackResourceResult().withStackResourceDetail(new StackResourceDetail().withPhysicalResourceId(AUTOSCALING_GROUP_NAME)));
    when(amazonAutoScalingClient.describeAutoScalingGroups(any())).thenReturn(new DescribeAutoScalingGroupsResult().withAutoScalingGroups(new AutoScalingGroup().withAutoScalingGroupName(AUTOSCALING_GROUP_NAME).withInstances(List.of(new Instance().withInstanceId(INSTANCE_ID_1).withLifecycleState(LifecycleState.InService), new Instance().withInstanceId(INSTANCE_ID_2).withLifecycleState(LifecycleState.InService)))));
    when(amazonEC2Client.describeVolumes(any())).thenReturn(new DescribeVolumesResult().withVolumes(new com.amazonaws.services.ec2.model.Volume().withVolumeId(VOLUME_ID_1).withState(VolumeState.Available), new com.amazonaws.services.ec2.model.Volume().withVolumeId(VOLUME_ID_2).withState(VolumeState.Available), new com.amazonaws.services.ec2.model.Volume().withVolumeId(VOLUME_ID_3).withState(VolumeState.InUse)));
    when(amazonEC2Client.describeInstances(any())).thenReturn(new DescribeInstancesResult().withReservations(new Reservation().withInstances(new com.amazonaws.services.ec2.model.Instance().withInstanceId("i-instance"))));
    DescribeScalingActivitiesResult result = new DescribeScalingActivitiesResult();
    result.setActivities(List.of());
    when(amazonAutoScalingClient.describeScalingActivities(any(DescribeScalingActivitiesRequest.class))).thenReturn(result);
    AmazonEC2Waiters waiters = mock(AmazonEC2Waiters.class);
    when(amazonEC2Client.waiters()).thenReturn(waiters);
    Waiter<DescribeInstancesRequest> instanceWaiter = mock(Waiter.class);
    when(waiters.instanceRunning()).thenReturn(instanceWaiter);
    when(amazonAutoScalingClient.waiters()).thenReturn(asWaiters);
    when(asWaiters.groupInService()).thenReturn(describeAutoScalingGroupsRequestWaiter);
    underTest.upscale(authenticatedContext, stack, cloudResources, new AdjustmentTypeWithThreshold(AdjustmentType.EXACT, 0L));
    verify(amazonAutoScalingClient).resumeProcesses(argThat(argument -> AUTOSCALING_GROUP_NAME.equals(argument.getAutoScalingGroupName()) && argument.getScalingProcesses().contains("Launch")));
    verify(amazonAutoScalingClient).updateAutoScalingGroup(argThat(argument -> {
        Group workerGroup = stack.getGroups().get(1);
        return AUTOSCALING_GROUP_NAME.equals(argument.getAutoScalingGroupName()) && workerGroup.getInstancesSize().equals(argument.getMaxSize()) && workerGroup.getInstancesSize().equals(argument.getDesiredCapacity());
    }));
    verify(amazonAutoScalingClient, times(stack.getGroups().size())).suspendProcesses(argThat(argument -> AUTOSCALING_GROUP_NAME.equals(argument.getAutoScalingGroupName()) && SUSPENDED_PROCESSES.equals(argument.getScalingProcesses())));
    ArgumentCaptor<CloudResource> updatedCloudResourceArgumentCaptor = ArgumentCaptor.forClass(CloudResource.class);
    verify(resourceNotifier, times(2)).notifyUpdate(updatedCloudResourceArgumentCaptor.capture(), any());
    assertVolumeResource(updatedCloudResourceArgumentCaptor.getAllValues(), INSTANCE_ID_1, SIZE_DISK_1, FSTAB_1);
    assertVolumeResource(updatedCloudResourceArgumentCaptor.getAllValues(), INSTANCE_ID_2, SIZE_DISK_2, FSTAB_2);
}
Also used : Arrays(java.util.Arrays) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) AmazonCloudWatchClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonCloudWatchClient) AmazonEC2Waiters(com.amazonaws.services.ec2.waiters.AmazonEC2Waiters) Arrays.asList(java.util.Arrays.asList) DescribeInstancesRequest(com.amazonaws.services.ec2.model.DescribeInstancesRequest) Map(java.util.Map) MockBean(org.springframework.boot.test.mock.mockito.MockBean) CommonStatus(com.sequenceiq.common.api.type.CommonStatus) LifeCycleState(com.amazonaws.services.elasticfilesystem.model.LifeCycleState) CloudVolumeUsageType(com.sequenceiq.cloudbreak.cloud.model.CloudVolumeUsageType) DescribeFileSystemsResult(com.amazonaws.services.elasticfilesystem.model.DescribeFileSystemsResult) AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) TestPropertySource(org.springframework.test.context.TestPropertySource) VolumeSetAttributes(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes) Retry(com.sequenceiq.cloudbreak.service.Retry) 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) SIZE_DISK_1(com.sequenceiq.cloudbreak.cloud.aws.component.ComponentTestUtil.SIZE_DISK_1) SIZE_DISK_2(com.sequenceiq.cloudbreak.cloud.aws.component.ComponentTestUtil.SIZE_DISK_2) Mockito.mock(org.mockito.Mockito.mock) 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) Supplier(java.util.function.Supplier) StackResourceDetail(com.amazonaws.services.cloudformation.model.StackResourceDetail) ResourceNotifier(com.sequenceiq.cloudbreak.cloud.notification.ResourceNotifier) AmazonEc2Client(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonEc2Client) DeleteMountTargetResult(com.amazonaws.services.elasticfilesystem.model.DeleteMountTargetResult) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) DescribeScalingActivitiesResult(com.amazonaws.services.autoscaling.model.DescribeScalingActivitiesResult) AwsCloudFormationClient(com.sequenceiq.cloudbreak.cloud.aws.AwsCloudFormationClient) InMemoryStateStore(com.sequenceiq.cloudbreak.cloud.store.InMemoryStateStore) Assert.assertTrue(org.junit.Assert.assertTrue) Import(org.springframework.context.annotation.Import) Mockito.times(org.mockito.Mockito.times) IOException(java.io.IOException) Test(org.junit.Test) PersistenceNotifier(com.sequenceiq.cloudbreak.cloud.notification.PersistenceNotifier) LifecycleState(com.amazonaws.services.autoscaling.model.LifecycleState) INSTANCE_ID_1(com.sequenceiq.cloudbreak.cloud.aws.component.ComponentTestUtil.INSTANCE_ID_1) InstanceStatus(com.sequenceiq.cloudbreak.cloud.model.InstanceStatus) INSTANCE_ID_2(com.sequenceiq.cloudbreak.cloud.aws.component.ComponentTestUtil.INSTANCE_ID_2) INSTANCE_ID_3(com.sequenceiq.cloudbreak.cloud.aws.component.ComponentTestUtil.INSTANCE_ID_3) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) DescribeStackResourceResult(com.amazonaws.services.cloudformation.model.DescribeStackResourceResult) PollGroup(com.sequenceiq.cloudbreak.cloud.scheduler.PollGroup) Assert.assertEquals(org.junit.Assert.assertEquals) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DescribeMountTargetsResult(com.amazonaws.services.elasticfilesystem.model.DescribeMountTargetsResult) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ActiveProfiles(org.springframework.test.context.ActiveProfiles) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) AmazonCloudFormationClient(com.sequenceiq.cloudbreak.cloud.aws.client.AmazonCloudFormationClient) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) DescribeScalingActivitiesRequest(com.amazonaws.services.autoscaling.model.DescribeScalingActivitiesRequest) Assert.fail(org.junit.Assert.fail) SpringRunner(org.springframework.test.context.junit4.SpringRunner) AmazonAutoScalingWaiters(com.amazonaws.services.autoscaling.waiters.AmazonAutoScalingWaiters) Waiter(com.amazonaws.waiters.Waiter) Reservation(com.amazonaws.services.ec2.model.Reservation) DescribeVolumesResult(com.amazonaws.services.ec2.model.DescribeVolumesResult) DescribeInstancesResult(com.amazonaws.services.ec2.model.DescribeInstancesResult) AmazonCloudFormationWaiters(com.amazonaws.services.cloudformation.waiters.AmazonCloudFormationWaiters) Collectors(java.util.stream.Collectors) TemporaryStorage(com.sequenceiq.cloudbreak.common.type.TemporaryStorage) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) List(java.util.List) Group(com.sequenceiq.cloudbreak.cloud.model.Group) DeleteFileSystemResult(com.amazonaws.services.elasticfilesystem.model.DeleteFileSystemResult) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) HashMap(java.util.HashMap) AwsMetadataCollector(com.sequenceiq.cloudbreak.cloud.aws.AwsMetadataCollector) ResourceRetriever(com.sequenceiq.cloudbreak.cloud.service.ResourceRetriever) Inject(javax.inject.Inject) ArgumentCaptor(org.mockito.ArgumentCaptor) DescribeAutoScalingGroupsResult(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult) ResourceType(com.sequenceiq.common.api.type.ResourceType) FileSystemDescription(com.amazonaws.services.elasticfilesystem.model.FileSystemDescription) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) AdjustmentTypeWithThreshold(com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) DescribeAutoScalingGroupsRequest(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest) Mockito(org.mockito.Mockito) MountTargetDescription(com.amazonaws.services.elasticfilesystem.model.MountTargetDescription) CustomAmazonWaiterProvider(com.sequenceiq.cloudbreak.cloud.aws.scheduler.CustomAmazonWaiterProvider) DescribeAlarmsResult(com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult) Instance(com.amazonaws.services.autoscaling.model.Instance) Volume(com.sequenceiq.cloudbreak.cloud.model.Volume) CommonAwsClient(com.sequenceiq.cloudbreak.cloud.aws.common.CommonAwsClient) Collections(java.util.Collections) AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) AutoScalingGroup(com.amazonaws.services.autoscaling.model.AutoScalingGroup) PollGroup(com.sequenceiq.cloudbreak.cloud.scheduler.PollGroup) Group(com.sequenceiq.cloudbreak.cloud.model.Group) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Instance(com.amazonaws.services.autoscaling.model.Instance) AdjustmentTypeWithThreshold(com.sequenceiq.common.api.adjustment.AdjustmentTypeWithThreshold) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) AmazonEC2Waiters(com.amazonaws.services.ec2.waiters.AmazonEC2Waiters) DescribeInstancesRequest(com.amazonaws.services.ec2.model.DescribeInstancesRequest) StackResourceDetail(com.amazonaws.services.cloudformation.model.StackResourceDetail) DescribeInstancesResult(com.amazonaws.services.ec2.model.DescribeInstancesResult) Reservation(com.amazonaws.services.ec2.model.Reservation) DescribeScalingActivitiesResult(com.amazonaws.services.autoscaling.model.DescribeScalingActivitiesResult) Volume(com.sequenceiq.cloudbreak.cloud.model.Volume) DescribeScalingActivitiesRequest(com.amazonaws.services.autoscaling.model.DescribeScalingActivitiesRequest) DescribeAutoScalingGroupsResult(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) DescribeVolumesResult(com.amazonaws.services.ec2.model.DescribeVolumesResult) DescribeStackResourceResult(com.amazonaws.services.cloudformation.model.DescribeStackResourceResult)

Example 5 with DescribeStackResourceResult

use of com.amazonaws.services.cloudformation.model.DescribeStackResourceResult in project cloudbreak by hortonworks.

the class CloudFormationStackUtil method getResourceArnByLogicalId.

public String getResourceArnByLogicalId(AuthenticatedContext ac, String logicalId, String region) {
    String cFStackName = getCfStackName(ac);
    AmazonCloudFormationClient amazonCfClient = awsClient.createCloudFormationClient(new AwsCredentialView(ac.getCloudCredential()), region);
    DescribeStackResourceResult result = amazonCfClient.describeStackResource(new DescribeStackResourceRequest().withStackName(cFStackName).withLogicalResourceId(logicalId));
    return result.getStackResourceDetail().getPhysicalResourceId();
}
Also used : AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) AmazonCloudFormationClient(com.sequenceiq.cloudbreak.cloud.aws.client.AmazonCloudFormationClient) DescribeStackResourceRequest(com.amazonaws.services.cloudformation.model.DescribeStackResourceRequest) DescribeStackResourceResult(com.amazonaws.services.cloudformation.model.DescribeStackResourceResult)

Aggregations

DescribeStackResourceResult (com.amazonaws.services.cloudformation.model.DescribeStackResourceResult)6 DescribeStackResourceRequest (com.amazonaws.services.cloudformation.model.DescribeStackResourceRequest)3 StackResourceDetail (com.amazonaws.services.cloudformation.model.StackResourceDetail)3 AmazonCloudFormationClient (com.sequenceiq.cloudbreak.cloud.aws.client.AmazonCloudFormationClient)3 AutoScalingGroup (com.amazonaws.services.autoscaling.model.AutoScalingGroup)2 DescribeAutoScalingGroupsRequest (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest)2 DescribeAutoScalingGroupsResult (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult)2 DescribeScalingActivitiesRequest (com.amazonaws.services.autoscaling.model.DescribeScalingActivitiesRequest)2 DescribeScalingActivitiesResult (com.amazonaws.services.autoscaling.model.DescribeScalingActivitiesResult)2 Instance (com.amazonaws.services.autoscaling.model.Instance)2 LifecycleState (com.amazonaws.services.autoscaling.model.LifecycleState)2 AmazonAutoScalingWaiters (com.amazonaws.services.autoscaling.waiters.AmazonAutoScalingWaiters)2 DescribeStacksRequest (com.amazonaws.services.cloudformation.model.DescribeStacksRequest)2 AmazonCloudFormationWaiters (com.amazonaws.services.cloudformation.waiters.AmazonCloudFormationWaiters)2 DescribeAlarmsResult (com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult)2 DescribeInstancesRequest (com.amazonaws.services.ec2.model.DescribeInstancesRequest)2 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)2 DescribeVolumesResult (com.amazonaws.services.ec2.model.DescribeVolumesResult)2 Reservation (com.amazonaws.services.ec2.model.Reservation)2 VolumeState (com.amazonaws.services.ec2.model.VolumeState)2