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));
}
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);
}
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());
}
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());
}
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();
}
Aggregations