use of com.sequenceiq.cloudbreak.cloud.aws.common.efs.AwsEfsFileSystem in project cloudbreak by hortonworks.
the class CloudFormationTemplateBuilderTest method setupEfsFileSystemValidSet.
private AwsEfsFileSystem setupEfsFileSystemValidSet() {
String fileSystemName = "efs-test";
Map<String, String> fileSystemTags = new HashMap<>();
fileSystemTags.put(CloudEfsConfiguration.KEY_FILESYSTEM_TAGS_NAME, fileSystemName);
JSONObject fileSystemPolicy = null;
try {
fileSystemPolicy = new JSONObject("{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": " + "[\"elasticfilesystem:ClientMount\"],\"Principal\": {\"AWS\": \"arn:aws:iam::111122223333:root\"}}]}");
} catch (JSONException e) {
}
// It does not make sense to have more than one such policy. but to test the syntex, create two policies
List<String> lifeCyclePolicies = new ArrayList<>();
lifeCyclePolicies.add("{\"TransitionToIA\" : \"AFTER_30_DAYS\"}");
lifeCyclePolicies.add("{\"TransitionToIA\" : \"AFTER_7_DAYS\"}");
return new AwsEfsFileSystem("DISABLED", false, fileSystemPolicy != null ? fileSystemPolicy.toString() : null, fileSystemTags, "sdx-key", lifeCyclePolicies, "maxIO", 1.0, "provisioned");
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.efs.AwsEfsFileSystem in project cloudbreak by hortonworks.
the class AwsModelService method buildDefaultModelContext.
public ModelContext buildDefaultModelContext(AuthenticatedContext ac, CloudStack stack, PersistenceNotifier resourceNotifier) {
Network network = stack.getNetwork();
AwsNetworkView awsNetworkView = new AwsNetworkView(network);
AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential());
String regionName = ac.getCloudContext().getLocation().getRegion().value();
AmazonEc2Client amazonEC2Client = awsClient.createEc2Client(credentialView, regionName);
boolean mapPublicIpOnLaunch = awsNetworkService.isMapPublicOnLaunch(awsNetworkView, amazonEC2Client);
boolean existingVPC = awsNetworkView.isExistingVPC();
boolean existingSubnet = awsNetworkView.isExistingSubnet();
String cidr = network.getSubnet().getCidr();
String subnet = isNoCIDRProvided(existingVPC, existingSubnet, cidr) ? awsNetworkService.findNonOverLappingCIDR(ac, stack) : cidr;
AwsInstanceProfileView awsInstanceProfileView = new AwsInstanceProfileView(stack);
ModelContext modelContext = new ModelContext().withAuthenticatedContext(ac).withStack(stack).withExistingVpc(existingVPC).withExistingIGW(awsNetworkView.isExistingIGW()).withExistingSubnetCidr(existingSubnet ? awsNetworkService.getExistingSubnetCidr(ac, stack) : null).withExistinVpcCidr(awsNetworkService.getVpcCidrs(ac, awsNetworkView)).withExistingSubnetIds(existingSubnet ? awsNetworkView.getSubnetList() : null).mapPublicIpOnLaunch(mapPublicIpOnLaunch).withEnableInstanceProfile(awsInstanceProfileView.isInstanceProfileAvailable()).withInstanceProfileAvailable(awsInstanceProfileView.isInstanceProfileAvailable()).withTemplate(stack.getTemplate()).withDefaultSubnet(subnet).withOutboundInternetTraffic(network.getOutboundInternetTraffic()).withVpcCidrs(network.getNetworkCidrs()).withPrefixListIds(awsNetworkService.getPrefixListIds(amazonEC2Client, regionName, network.getOutboundInternetTraffic()));
AwsEfsFileSystem efsFileSystem = getAwsEfsFileSystem(stack);
if (efsFileSystem != null) {
modelContext.withEnableEfs(true);
modelContext.withEfsFileSystem(efsFileSystem);
} else {
modelContext.withEnableEfs(false);
}
return modelContext;
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.efs.AwsEfsFileSystem in project cloudbreak by hortonworks.
the class CloudFormationTemplateBuilderTest method buildTestEfsNullFields.
@Test
public void buildTestEfsNullFields() {
// GIVEN
AwsEfsFileSystem awsEfsFileSystem = setupEfsFileSystemNullFields();
// WHEN
modelContext = new ModelContext().withAuthenticatedContext(authenticatedContext).withStack(cloudStack).withExistingVpc(true).withExistingIGW(true).withExistingSubnetCidr(singletonList(existingSubnetCidr)).withExistinVpcCidr(List.of(existingSubnetCidr)).mapPublicIpOnLaunch(true).withEnableInstanceProfile(true).withInstanceProfileAvailable(true).withOutboundInternetTraffic(OutboundInternetTraffic.ENABLED).withTemplate(awsCloudFormationTemplate).withEnableEfs(true).withEfsFileSystem(awsEfsFileSystem);
String templateString = cloudFormationTemplateBuilder.build(modelContext);
// THEN
Assertions.assertThat(templateString).matches(JsonUtil::isValid, "Invalid JSON: " + templateString).contains("AWS::EFS::FileSystem").contains("\"Encrypted\" : \"true\"").contains("\"PerformanceMode\": \"generalPurpose\"").contains("\"ThroughputMode\": \"bursting\"");
}
use of com.sequenceiq.cloudbreak.cloud.aws.common.efs.AwsEfsFileSystem in project cloudbreak by hortonworks.
the class CloudFormationTemplateBuilderTest method buildTestEfsSetFields.
@Test
public void buildTestEfsSetFields() {
// GIVEN
AwsEfsFileSystem awsEfsFileSystem = setupEfsFileSystemValidSet();
// WHEN
modelContext = new ModelContext().withAuthenticatedContext(authenticatedContext).withStack(cloudStack).withExistingVpc(true).withExistingIGW(true).withExistingSubnetCidr(singletonList(existingSubnetCidr)).withExistinVpcCidr(List.of(existingSubnetCidr)).mapPublicIpOnLaunch(true).withEnableInstanceProfile(true).withInstanceProfileAvailable(true).withOutboundInternetTraffic(OutboundInternetTraffic.ENABLED).withTemplate(awsCloudFormationTemplate).withEnableEfs(true).withEfsFileSystem(awsEfsFileSystem);
String templateString = cloudFormationTemplateBuilder.build(modelContext);
// THEN
Assertions.assertThat(templateString).matches(JsonUtil::isValid, "Invalid JSON: " + templateString).contains("AWS::EFS::FileSystem").contains("\"Encrypted\" : \"false\"").contains("\"PerformanceMode\": \"maxIO\"").contains("\"ThroughputMode\": \"provisioned\"");
}
Aggregations