use of com.sequenceiq.common.api.cloudstorage.AwsEfsParameters in project cloudbreak by hortonworks.
the class CloudStorageConverter method fileSystemToEfsParameters.
public AwsEfsParameters fileSystemToEfsParameters(FileSystem fileSystem) {
if (fileSystem == null || !FileSystemType.EFS.equals(fileSystem.getType()) || fileSystem.getConfigurations() == null) {
return null;
}
AwsEfsParameters efsParameters = new AwsEfsParameters();
efsParameters.setName(fileSystem.getName());
Map<String, String> configurations = null;
try {
configurations = JsonUtil.readValue(fileSystem.getConfigurations().getValue(), Map.class);
} catch (IOException ex) {
// TODO: log the error
return null;
}
efsParameters.setName(fileSystem.getName());
efsParameters.setEncrypted(Boolean.valueOf(configurations.get(CloudEfsConfiguration.KEY_ENCRYPTED)));
if (configurations.containsKey(CloudEfsConfiguration.KEY_FILESYSTEM_ID)) {
efsParameters.setFilesystemId(configurations.get(CloudEfsConfiguration.KEY_FILESYSTEM_ID));
}
if (configurations.containsKey(CloudEfsConfiguration.KEY_LIFECYCLE_STATE)) {
efsParameters.setLifeCycleState(configurations.get(CloudEfsConfiguration.KEY_LIFECYCLE_STATE));
}
return efsParameters;
}
use of com.sequenceiq.common.api.cloudstorage.AwsEfsParameters 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