use of com.sequenceiq.common.api.cloudstorage.CloudStorageBase 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;
}
Aggregations