use of com.sequenceiq.cloudbreak.common.type.APIResourceType.FILESYSTEM in project cloudbreak by hortonworks.
the class CloudStorageConverter method requestToAdditionalFileSystem.
public FileSystem requestToAdditionalFileSystem(CloudStorageBase cloudStorageRequest) {
FileSystem fileSystem = new FileSystem();
AwsEfsParameters efsParameters = cloudStorageRequest.getAws() == null ? null : cloudStorageRequest.getAws().getEfsParameters();
if (efsParameters == null || StringUtils.isEmpty(efsParameters.getName())) {
return null;
}
fileSystem.setName(efsParameters.getName());
FileSystemType fileSystemType = FileSystemType.EFS;
fileSystem.setType(fileSystemType);
Map<String, Object> configurations = new HashMap<>();
configurations.put(CloudEfsConfiguration.KEY_BACKUP_POLICY_STATUS, efsParameters.getBackupPolicyStatus());
configurations.put(CloudEfsConfiguration.KEY_ENCRYPTED, efsParameters.getEncrypted());
configurations.put(CloudEfsConfiguration.KEY_FILESYSTEM_POLICY, efsParameters.getFileSystemPolicy());
configurations.put(CloudEfsConfiguration.KEY_FILESYSTEM_TAGS, efsParameters.getFileSystemTags());
configurations.put(CloudEfsConfiguration.KEY_KMSKEYID, efsParameters.getKmsKeyId());
configurations.put(CloudEfsConfiguration.KEY_LIFECYCLE_POLICIES, efsParameters.getLifeCyclePolicies());
configurations.put(CloudEfsConfiguration.KEY_PERFORMANCE_MODE, efsParameters.getPerformanceMode());
configurations.put(CloudEfsConfiguration.KEY_PROVISIONED_THROUGHPUT_INMIBPS, efsParameters.getProvisionedThroughputInMibps());
configurations.put(CloudEfsConfiguration.KEY_THROUGHPUT_MODE, efsParameters.getThroughputMode());
String configString;
try {
configString = JsonUtil.writeValueAsString(configurations);
} catch (JsonProcessingException ignored) {
configString = configurations.toString();
}
fileSystem.setConfigurations(new Json(configString));
CloudStorage cloudStorage = new CloudStorage();
if (cloudStorageRequest.getIdentities() != null) {
Optional<CloudIdentity> cloudIdentity = cloudStorageRequest.getIdentities().stream().map(this::identityRequestToCloudIdentity).filter(currCloudIdentity -> currCloudIdentity.getEfsIdentity() != null).findFirst();
if (cloudIdentity != null && cloudIdentity.get() != null) {
cloudStorage.setCloudIdentities(List.of(cloudIdentity.get()));
}
}
cloudStorage.setAccountMapping(accountMappingRequestToAccountMapping(cloudStorageRequest.getAccountMapping()));
fileSystem.setCloudStorage(cloudStorage);
return fileSystem;
}
use of com.sequenceiq.cloudbreak.common.type.APIResourceType.FILESYSTEM in project cloudbreak by hortonworks.
the class CloudStorageConverter method fileSystemToResponse.
public CloudStorageResponse fileSystemToResponse(FileSystem fileSystem) {
CloudStorageResponse response = new CloudStorageResponse();
CloudStorage cloudStorage = fileSystem.getCloudStorage();
if (cloudStorage != null) {
if (StringUtils.isNotEmpty(cloudStorage.getS3GuardDynamoTableName())) {
AwsStorageParameters awsStorageParameters = new AwsStorageParameters();
S3Guard s3Guard = new S3Guard();
s3Guard.setDynamoTableName(cloudStorage.getS3GuardDynamoTableName());
awsStorageParameters.setS3Guard(s3Guard);
response.setAws(awsStorageParameters);
}
List<StorageIdentityBase> storageIdentities = cloudStorage.getCloudIdentities().stream().map(this::cloudIdentityToStorageIdentityBase).collect(Collectors.toList());
response.setIdentities(storageIdentities);
List<StorageLocationBase> storageLocations = cloudStorage.getLocations().stream().map(storageLocation -> {
StorageLocationBase storageLocationBase = new StorageLocationBase();
storageLocationBase.setType(storageLocation.getType());
storageLocationBase.setValue(storageLocation.getValue());
return storageLocationBase;
}).collect(Collectors.toList());
response.setLocations(storageLocations);
response.setAccountMapping(accountMappingToAccountMappingRequest(cloudStorage.getAccountMapping()));
}
return response;
}
Aggregations