Search in sources :

Example 1 with AzureStackV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters in project cloudbreak by hortonworks.

the class DistroXParameterConverter method convert.

public AzureStackV4Parameters convert(AzureDistroXV1Parameters source) {
    AzureStackV4Parameters response = new AzureStackV4Parameters();
    response.setEncryptStorage(source.isEncryptStorage());
    response.setResourceGroupName(source.getResourceGroupName());
    response.setLoadBalancerSku(source.getLoadBalancerSku());
    return response;
}
Also used : AzureStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters)

Example 2 with AzureStackV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters in project cloudbreak by hortonworks.

the class LoadBalancerConfigServiceTest method testCreateAzureLoadBalancerWithSkuSetToStandard.

@Test
public void testCreateAzureLoadBalancerWithSkuSetToStandard() {
    Stack stack = createAzureStack(StackType.DATALAKE, PRIVATE_ID_1, true);
    CloudSubnet subnet = getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1);
    DetailedEnvironmentResponse environment = createEnvironment(subnet, false, "AZURE");
    AzureStackV4Parameters azureParameters = new AzureStackV4Parameters();
    azureParameters.setLoadBalancerSku(LoadBalancerSku.STANDARD);
    StackV4Request request = new StackV4Request();
    request.setEnableLoadBalancer(false);
    request.setAzure(azureParameters);
    when(entitlementService.azureDatalakeLoadBalancerEnabled(anyString())).thenReturn(true);
    when(blueprint.getBlueprintText()).thenReturn(getBlueprintText("input/clouderamanager-knox.bp"));
    when(subnetSelector.findSubnetById(any(), anyString())).thenReturn(Optional.of(subnet));
    when(availabilitySetNameService.generateName(any(), any())).thenReturn("");
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
        Set<LoadBalancer> loadBalancers = underTest.createLoadBalancers(stack, environment, request);
        assertEquals(2, loadBalancers.size());
        assert loadBalancers.stream().anyMatch(l -> LoadBalancerType.PRIVATE.equals(l.getType()));
        assert loadBalancers.stream().anyMatch(l -> LoadBalancerType.OUTBOUND.equals(l.getType()));
        InstanceGroup masterInstanceGroup = stack.getInstanceGroups().stream().filter(ig -> "master".equals(ig.getGroupName())).findFirst().get();
        assertEquals(1, masterInstanceGroup.getTargetGroups().size());
        assertTrue(loadBalancers.stream().allMatch(l -> LoadBalancerSku.STANDARD.equals(l.getSku())));
        checkAvailabilitySetAttributes(loadBalancers);
    });
}
Also used : AzureStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) AZURE(com.sequenceiq.cloudbreak.common.type.CloudConstants.AZURE) AWS(com.sequenceiq.cloudbreak.common.type.CloudConstants.AWS) StringUtils(org.apache.commons.lang3.StringUtils) GCP(com.sequenceiq.cloudbreak.common.type.CloudConstants.GCP) MockitoAnnotations(org.mockito.MockitoAnnotations) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) ProviderParameterCalculator(com.sequenceiq.cloudbreak.common.mappable.ProviderParameterCalculator) PublicEndpointAccessGateway(com.sequenceiq.common.api.type.PublicEndpointAccessGateway) Map(java.util.Map) Spy(org.mockito.Spy) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) Assert.fail(org.junit.Assert.fail) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Collectors.toSet(java.util.stream.Collectors.toSet) SubnetSelector(com.sequenceiq.cloudbreak.converter.v4.environment.network.SubnetSelector) AzureStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters) LoadBalancerPersistenceService(com.sequenceiq.cloudbreak.service.stack.LoadBalancerPersistenceService) Set(java.util.Set) UUID(java.util.UUID) LoadBalancerSku(com.sequenceiq.common.api.type.LoadBalancerSku) Json(com.sequenceiq.cloudbreak.common.json.Json) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Mock(org.mockito.Mock) Network(com.sequenceiq.cloudbreak.domain.Network) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Assert.assertThrows(org.junit.Assert.assertThrows) HashMap(java.util.HashMap) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) HashSet(java.util.HashSet) FileReaderUtils(com.sequenceiq.cloudbreak.util.FileReaderUtils) AzureInstanceGroupParameters(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceGroupParameters) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) LoadBalancerCreation(com.sequenceiq.common.api.type.LoadBalancerCreation) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) AvailabilitySetNameService(com.sequenceiq.cloudbreak.cloud.model.instance.AvailabilitySetNameService) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Field(java.lang.reflect.Field) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) Assert.assertNull(org.junit.Assert.assertNull) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) YARN(com.sequenceiq.cloudbreak.common.type.CloudConstants.YARN) ReflectionUtils(org.springframework.util.ReflectionUtils) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) Assert.assertEquals(org.junit.Assert.assertEquals) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest) Test(org.junit.Test)

Example 3 with AzureStackV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters in project cloudbreak by hortonworks.

the class LoadBalancerConfigServiceTest method testAzureLoadBalancerDisabledWithOozieHA.

@Test
public void testAzureLoadBalancerDisabledWithOozieHA() {
    Stack stack = createAzureStack(StackType.DATALAKE, PRIVATE_ID_1, true);
    CloudSubnet subnet = getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1);
    DetailedEnvironmentResponse environment = createEnvironment(subnet, false, "AZURE");
    AzureStackV4Parameters azureParameters = new AzureStackV4Parameters();
    azureParameters.setLoadBalancerSku(LoadBalancerSku.NONE);
    StackV4Request request = new StackV4Request();
    request.setEnableLoadBalancer(false);
    request.setAzure(azureParameters);
    when(entitlementService.azureDatalakeLoadBalancerEnabled(anyString())).thenReturn(false);
    when(blueprint.getBlueprintText()).thenReturn(getBlueprintText("input/de-ha.bp"));
    when(subnetSelector.findSubnetById(any(), anyString())).thenReturn(Optional.of(subnet));
    when(availabilitySetNameService.generateName(any(), any())).thenReturn("");
    assertThrows(CloudbreakServiceException.class, () -> underTest.createLoadBalancers(stack, environment, request));
}
Also used : AzureStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest) Test(org.junit.Test)

Example 4 with AzureStackV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters in project cloudbreak by hortonworks.

the class DistroXParameterConverterTest method testAzureDistroXV1ParametersToAzureStackV4Parameters.

@Test
void testAzureDistroXV1ParametersToAzureStackV4Parameters() {
    AzureDistroXV1Parameters input = new AzureDistroXV1Parameters();
    input.setEncryptStorage(true);
    input.setResourceGroupName("resourceGroupName");
    input.setLoadBalancerSku(LoadBalancerSku.STANDARD);
    AzureStackV4Parameters result = underTest.convert(input);
    assertNotNull(result);
    assertEquals(input.isEncryptStorage(), result.isEncryptStorage());
    assertEquals(input.getResourceGroupName(), result.getResourceGroupName());
    assertEquals(input.getLoadBalancerSku(), result.getLoadBalancerSku());
}
Also used : AzureStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters) AzureDistroXV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.AzureDistroXV1Parameters) Test(org.junit.jupiter.api.Test)

Example 5 with AzureStackV4Parameters

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters in project cloudbreak by hortonworks.

the class SdxService method updateAzureLoadBalancerSkuIfPresent.

private void updateAzureLoadBalancerSkuIfPresent(StackV4Request stackRequest, SdxClusterRequest sdxClusterRequest) {
    Optional.ofNullable(sdxClusterRequest.getAzure()).map(SdxAzureBase::getLoadBalancerSku).ifPresent(sku -> {
        AzureStackV4Parameters azureParameters = stackRequest.createAzure();
        azureParameters.setLoadBalancerSku(sku);
        stackRequest.setAzure(azureParameters);
    });
}
Also used : AzureStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters)

Aggregations

AzureStackV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters)9 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)5 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)5 SubnetTest (com.sequenceiq.cloudbreak.core.network.SubnetTest)5 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)5 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)5 Test (org.junit.Test)5 LoadBalancer (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer)4 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)3 StackType (com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType)2 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)2 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)2 AvailabilitySetNameService (com.sequenceiq.cloudbreak.cloud.model.instance.AvailabilitySetNameService)2 AzureInstanceGroupParameters (com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceGroupParameters)2 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)2 Json (com.sequenceiq.cloudbreak.common.json.Json)2 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)2 ProviderParameterCalculator (com.sequenceiq.cloudbreak.common.mappable.ProviderParameterCalculator)2 AWS (com.sequenceiq.cloudbreak.common.type.CloudConstants.AWS)2 AZURE (com.sequenceiq.cloudbreak.common.type.CloudConstants.AZURE)2