Search in sources :

Example 11 with InstanceGroupType

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

the class SecurityAccessManifesterTest method overrideSecurityAccessWhenMultipleCidrRangeProvidedThenShouldUpdateTheCidrRanges.

@Test
void overrideSecurityAccessWhenMultipleCidrRangeProvidedThenShouldUpdateTheCidrRanges() {
    InstanceGroupType gateway = GATEWAY;
    List<InstanceGroupV4Request> instanceGroups = getInstanceGroups();
    String theWholeWorldAndASimpleCidr = "0.0.0.0/0,172.16.0.0/16";
    securityAccessManifester.overrideSecurityAccess(gateway, instanceGroups, null, theWholeWorldAndASimpleCidr);
    assertEquals(2, instanceGroups.get(0).getSecurityGroup().getSecurityRules().size());
    assertEquals(List.of(theWholeWorldAndASimpleCidr.split(",")), collectSubnets(instanceGroups));
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) Test(org.junit.jupiter.api.Test)

Example 12 with InstanceGroupType

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

the class LoadBalancerResourceServiceTest method setup.

@BeforeEach
public void setup() {
    privateId = 0L;
    privateCrn = "crn";
    Location location = Location.location(Region.region("region"), AvailabilityZone.availabilityZone("az"));
    Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, "CORE", InstanceGroupType.GATEWAY, "GATEWAY");
    image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
    CloudContext cloudContext = CloudContext.Builder.builder().withId(privateId).withName("testname").withCrn("crn").withPlatform("GCP").withWorkspaceId(WORKSPACE_ID).build();
    CloudCredential cloudCredential = new CloudCredential(privateCrn, "credentialname", "account");
    cloudCredential.putParameter("projectId", "projectId");
    String projectId = "projectId";
    String serviceAccountId = "serviceAccountId";
    authenticatedContext = new AuthenticatedContext(cloudContext, cloudCredential);
    context = new ResourceBuilderContext(cloudContext.getName(), location, 30, false);
    List<CloudResource> networkResources = Collections.singletonList(new CloudResource.Builder().type(ResourceType.GCP_NETWORK).name("network-test").build());
    context.addNetworkResources(networkResources);
    Network network = new Network(null);
    cloudStack = new CloudStack(Collections.emptyList(), network, image, emptyMap(), emptyMap(), null, null, null, null, null);
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) AuthenticatedContext(com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext) Image(com.sequenceiq.cloudbreak.cloud.model.Image) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Network(com.sequenceiq.cloudbreak.cloud.model.Network) ResourceBuilderContext(com.sequenceiq.cloudbreak.cloud.template.context.ResourceBuilderContext) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Location(com.sequenceiq.cloudbreak.cloud.model.Location) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 13 with InstanceGroupType

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

the class YarnResourceConnectorTest method createGroup.

private Group createGroup(Integer groupNum) {
    String name = "group_" + groupNum;
    InstanceGroupType type = InstanceGroupType.CORE;
    Collection<CloudInstance> instances = Lists.newArrayList(cloudInstanceMock, cloudInstanceMock);
    return new Group(name, type, instances, null, null, null, null, null, 50, Optional.empty(), createGroupNetwork(), emptyMap());
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance)

Example 14 with InstanceGroupType

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

the class CloudFormationTemplateBuilderTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
    factoryBean.setPreferFileSystemAccess(false);
    factoryBean.setTemplateLoaderPath("classpath:/");
    factoryBean.afterPropertiesSet();
    Configuration configuration = factoryBean.getObject();
    ReflectionTestUtils.setField(cloudFormationTemplateBuilder, "freemarkerConfiguration", configuration);
    when(freeMarkerTemplateUtils.processTemplateIntoString(any(), any())).thenCallRealMethod();
    awsCloudFormationTemplate = configuration.getTemplate(LATEST_AWS_CLOUD_FORMATION_TEMPLATE_PATH, "UTF-8").toString();
    authenticatedContext = authenticatedContext();
    existingSubnetCidr = "testSubnet";
    InstanceTemplate instanceTemplate = createDefaultInstanceTemplate();
    instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
    instance = new CloudInstance("SOME_ID", instanceTemplate, instanceAuthentication, "subnet-1", "az1");
    Security security = getDefaultCloudStackSecurity();
    Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, "CORE", InstanceGroupType.GATEWAY, "GATEWAY");
    image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
    List<Group> groups = List.of(createDefaultGroup("master", InstanceGroupType.CORE, ROOT_VOLUME_SIZE, security, Optional.empty()), createDefaultGroup("gateway", InstanceGroupType.GATEWAY, ROOT_VOLUME_SIZE, security, Optional.empty()));
    cloudStack = createDefaultCloudStack(groups, getDefaultCloudStackParameters(), getDefaultCloudStackTags());
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) FreeMarkerConfigurationFactoryBean(org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean) CloudEfsConfiguration(com.sequenceiq.cloudbreak.cloud.model.filesystem.efs.CloudEfsConfiguration) Configuration(freemarker.template.Configuration) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) Matchers.containsString(org.hamcrest.Matchers.containsString) Security(com.sequenceiq.cloudbreak.cloud.model.Security) Image(com.sequenceiq.cloudbreak.cloud.model.Image) AwsInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 15 with InstanceGroupType

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

the class AzureTemplateBuilderTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean();
    factoryBean.setPreferFileSystemAccess(false);
    factoryBean.setTemplateLoaderPath("classpath:/");
    factoryBean.afterPropertiesSet();
    Configuration configuration = factoryBean.getObject();
    ReflectionTestUtils.setField(azureTemplateBuilder, "freemarkerConfiguration", configuration);
    ReflectionTestUtils.setField(azureTemplateBuilder, "armTemplateParametersPath", "templates/parameters.ftl");
    Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, CORE_CUSTOM_DATA, InstanceGroupType.GATEWAY, GATEWAY_CUSTOM_DATA);
    groups = new ArrayList<>();
    stackName = "testStack";
    name = "master";
    List<Volume> volumes = Arrays.asList(new Volume("/hadoop/fs1", "HDD", 1, CloudVolumeUsageType.GENERAL), new Volume("/hadoop/fs2", "HDD", 1, CloudVolumeUsageType.GENERAL));
    InstanceTemplate instanceTemplate = new InstanceTemplate("m1.medium", name, 0L, volumes, InstanceStatus.CREATE_REQUESTED, new HashMap<>(), 0L, "cb-centos66-amb200-2015-05-25", TemporaryStorage.ATTACHED_VOLUMES, 0L);
    Map<String, Object> params = new HashMap<>();
    params.put(NetworkConstants.SUBNET_ID, "existingSubnet");
    InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
    instance = new CloudInstance("SOME_ID", instanceTemplate, instanceAuthentication, "existingSubnet", "az1", params);
    List<SecurityRule> rules = Collections.singletonList(new SecurityRule("0.0.0.0/0", new PortDefinition[] { new PortDefinition("22", "22"), new PortDefinition("443", "443") }, "tcp"));
    security = new Security(rules, emptyList());
    image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
    cloudContext = CloudContext.Builder.builder().withId(7899L).withName("thisisaverylongazureresourcenamewhichneedstobeshortened").withCrn("crn").withPlatform("dummy1").withLocation(Location.location(Region.region("westus2"), new AvailabilityZone("availabilityZone"))).withWorkspaceId(WORKSPACE_ID).build();
    azureCredentialView = new AzureCredentialView(cloudCredential());
    azureStorageView = new AzureStorageView(azureCredentialView, cloudContext, azureStorage, null);
    azureSubnetStrategy = AzureSubnetStrategy.getAzureSubnetStrategy(FILL, Collections.singletonList("existingSubnet"), ImmutableMap.of("existingSubnet", 100L));
    when(customVMImageNameProvider.getImageNameFromConnectionString(anyString())).thenCallRealMethod();
}
Also used : InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) PortDefinition(com.sequenceiq.cloudbreak.cloud.model.PortDefinition) FreeMarkerConfigurationFactoryBean(org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean) Configuration(freemarker.template.Configuration) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) HashMap(java.util.HashMap) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) AvailabilityZone(com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SecurityRule(com.sequenceiq.cloudbreak.cloud.model.SecurityRule) Security(com.sequenceiq.cloudbreak.cloud.model.Security) Image(com.sequenceiq.cloudbreak.cloud.model.Image) AzureMarketplaceImage(com.sequenceiq.cloudbreak.cloud.azure.image.marketplace.AzureMarketplaceImage) AzureStorageView(com.sequenceiq.cloudbreak.cloud.azure.view.AzureStorageView) AzureCredentialView(com.sequenceiq.cloudbreak.cloud.azure.view.AzureCredentialView) Volume(com.sequenceiq.cloudbreak.cloud.model.Volume) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) AzureInstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)31 Image (com.sequenceiq.cloudbreak.cloud.model.Image)17 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)10 HashMap (java.util.HashMap)10 Test (org.junit.Test)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)8 Network (com.sequenceiq.cloudbreak.cloud.model.Network)8 Security (com.sequenceiq.cloudbreak.cloud.model.Security)8 BeforeEach (org.junit.jupiter.api.BeforeEach)8 CcmConnectivityParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters)7 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)7 Group (com.sequenceiq.cloudbreak.cloud.model.Group)6 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)5 Json (com.sequenceiq.cloudbreak.common.json.Json)5 GroupNetwork (com.sequenceiq.cloudbreak.cloud.model.GroupNetwork)4 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)4 PortDefinition (com.sequenceiq.cloudbreak.cloud.model.PortDefinition)4 SecurityRule (com.sequenceiq.cloudbreak.cloud.model.SecurityRule)4 Volume (com.sequenceiq.cloudbreak.cloud.model.Volume)4