use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView in project cloudbreak by hortonworks.
the class StackToCloudStackConverterTest method testBuildFileSystemViewSameAWSInstanceProfile.
@Test
public void testBuildFileSystemViewSameAWSInstanceProfile() throws Exception {
Telemetry telemetry = mock(Telemetry.class);
Backup backup = mock(Backup.class);
Logging logging = mock(Logging.class);
S3CloudStorageV1Parameters s3Logging = new S3CloudStorageV1Parameters();
s3Logging.setInstanceProfile("arn:aws:iam::id:instance-profile/role");
S3CloudStorageV1Parameters s3Backup = new S3CloudStorageV1Parameters();
s3Backup.setInstanceProfile("arn:aws:iam::id:instance-profile/role");
when(stack.getTelemetry()).thenReturn(telemetry);
when(telemetry.getLogging()).thenReturn(logging);
when(stack.getBackup()).thenReturn(backup);
when(backup.getS3()).thenReturn(s3Backup);
when(logging.getS3()).thenReturn(s3Logging);
Optional<CloudFileSystemView> fileSystemView = underTest.buildFileSystemView(stack);
assertEquals(Optional.empty(), fileSystemView);
}
use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView in project cloudbreak by hortonworks.
the class StackToCloudStackConverterTest method testBuildFileSystemViewSameAzureManagedIdentity.
@Test
public void testBuildFileSystemViewSameAzureManagedIdentity() throws Exception {
Telemetry telemetry = mock(Telemetry.class);
Backup backup = mock(Backup.class);
Logging logging = mock(Logging.class);
AdlsGen2CloudStorageV1Parameters adlsGen2Logging = new AdlsGen2CloudStorageV1Parameters();
adlsGen2Logging.setManagedIdentity("/subscriptions/id/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity");
AdlsGen2CloudStorageV1Parameters adlsGen2Backup = new AdlsGen2CloudStorageV1Parameters();
adlsGen2Backup.setManagedIdentity("/subscriptions/id/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity");
when(stack.getTelemetry()).thenReturn(telemetry);
when(telemetry.getLogging()).thenReturn(logging);
when(stack.getBackup()).thenReturn(backup);
when(backup.getAdlsGen2()).thenReturn(adlsGen2Logging);
when(logging.getAdlsGen2()).thenReturn(adlsGen2Backup);
Optional<CloudFileSystemView> fileSystemView = underTest.buildFileSystemView(stack);
assertEquals(Optional.empty(), fileSystemView);
}
use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView in project cloudbreak by hortonworks.
the class CloudFileSystemViewProvider method getCloudFileSystemView.
public Optional<CloudFileSystemView> getCloudFileSystemView(FileSystem fileSystem, Map<String, Set<String>> componentsByHostGroup, InstanceGroup instanceGroup) {
Optional<CloudFileSystemView> fileSystemView;
if (fileSystem != null) {
SpiFileSystem spiFileSystem = fileSystemConverter.fileSystemToSpi(fileSystem);
Set<String> components = componentsByHostGroup.get(instanceGroup.getGroupName());
CloudIdentityType identityType = cloudIdentityTypeDecider.getIdentityType(components);
if (identityType == CloudIdentityType.ID_BROKER) {
instanceGroupService.setCloudIdentityType(instanceGroup, CloudIdentityType.ID_BROKER);
fileSystemView = spiFileSystem.getCloudFileSystems().stream().filter(cloudFileSystemView -> CloudIdentityType.ID_BROKER.equals(cloudFileSystemView.getCloudIdentityType())).findFirst();
} else {
instanceGroupService.setCloudIdentityType(instanceGroup, CloudIdentityType.LOG);
fileSystemView = spiFileSystem.getCloudFileSystems().stream().filter(cloudFileSystemView -> CloudIdentityType.LOG.equals(cloudFileSystemView.getCloudIdentityType())).findFirst();
}
} else {
fileSystemView = Optional.empty();
}
return fileSystemView;
}
use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView in project cloudbreak by hortonworks.
the class FileSystemConverter method legacyConvertFromConfiguration.
private List<CloudFileSystemView> legacyConvertFromConfiguration(FileSystem source) {
try {
CloudFileSystemView fileSystemView;
if (source.getType().isAdls()) {
AdlsFileSystem adlsFileSystem = source.getConfigurations().get(AdlsFileSystem.class);
fileSystemView = convertAdlsLegacy(adlsFileSystem);
} else if (source.getType().isGcs()) {
GcsFileSystem gcsFileSystem = source.getConfigurations().get(GcsFileSystem.class);
fileSystemView = convertGcsLegacy(gcsFileSystem);
} else if (source.getType().isS3()) {
S3FileSystem s3FileSystem = source.getConfigurations().get(S3FileSystem.class);
fileSystemView = convertS3Legacy(s3FileSystem);
} else if (source.getType().isEfs()) {
EfsFileSystem efsFileSystem = source.getConfigurations().get(EfsFileSystem.class);
fileSystemView = convertEfsLegacy(efsFileSystem);
} else if (source.getType().isWasb()) {
WasbFileSystem wasbFileSystem = source.getConfigurations().get(WasbFileSystem.class);
fileSystemView = convertWasbLegacy(wasbFileSystem);
} else if (source.getType().isAdlsGen2()) {
AdlsGen2FileSystem adlsGen2FileSystem = source.getConfigurations().get(AdlsGen2FileSystem.class);
fileSystemView = convertAdlsGen2Legacy(adlsGen2FileSystem);
} else if (source.getType().isGcs()) {
GcsFileSystem gcsFileSystem = source.getConfigurations().get(GcsFileSystem.class);
fileSystemView = convertGcsLegacy(gcsFileSystem);
} else {
return Collections.emptyList();
}
return List.of(fileSystemView);
} catch (IOException e) {
LOGGER.warn("Error occurred when tried to convert filesystem object: {}", e.getMessage());
}
return Collections.emptyList();
}
use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView in project cloudbreak by hortonworks.
the class StackToCloudStackConverter method buildInstanceGroups.
private List<Group> buildInstanceGroups(Stack stack, List<InstanceGroup> instanceGroups, StackAuthentication stackAuthentication, Collection<String> deleteRequests, DetailedEnvironmentResponse environment) {
// sort by name to avoid shuffling the different instance groups
Collections.sort(instanceGroups);
List<Group> groups = new ArrayList<>();
Cluster cluster = stack.getCluster();
if (cluster != null) {
String blueprintText = cluster.getBlueprint() != null ? cluster.getBlueprint().getBlueprintText() : cluster.getExtendedBlueprintText();
if (blueprintText != null) {
CmTemplateProcessor cmTemplateProcessor = cmTemplateProcessorFactory.get(blueprintText);
Map<String, Set<String>> componentsByHostGroup = cmTemplateProcessor.getComponentsByHostGroup();
Map<String, String> userDefinedTags = getUserDefinedTags(stack);
for (InstanceGroup instanceGroup : instanceGroups) {
if (instanceGroup.getTemplate() != null) {
InstanceAuthentication instanceAuthentication = buildInstanceAuthentication(stackAuthentication);
Optional<CloudFileSystemView> cloudFileSystemView = cloudFileSystemViewProvider.getCloudFileSystemView(cluster.getFileSystem(), componentsByHostGroup, instanceGroup);
groups.add(new Group(instanceGroup.getGroupName(), instanceGroup.getInstanceGroupType(), buildCloudInstances(environment, stackAuthentication, deleteRequests, instanceGroup), buildSecurity(instanceGroup), buildCloudInstanceSkeleton(environment, stackAuthentication, instanceGroup), getFields(instanceGroup), instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), getRootVolumeSize(instanceGroup), cloudFileSystemView, buildDeletedCloudInstances(environment, stackAuthentication, instanceGroup), buildGroupNetwork(stack.getNetwork(), instanceGroup), userDefinedTags));
}
}
}
} else {
LOGGER.warn("Cluster or blueprint is null for stack id:[{}] name:[{}]", stack.getId(), stack.getName());
}
return groups;
}
Aggregations