Search in sources :

Example 6 with CloudFileSystemView

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);
}
Also used : Logging(com.sequenceiq.common.api.telemetry.model.Logging) S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) Backup(com.sequenceiq.freeipa.api.model.Backup) CloudFileSystemView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Test(org.junit.Test)

Example 7 with CloudFileSystemView

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);
}
Also used : Logging(com.sequenceiq.common.api.telemetry.model.Logging) AdlsGen2CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters) Backup(com.sequenceiq.freeipa.api.model.Backup) CloudFileSystemView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Test(org.junit.Test)

Example 8 with CloudFileSystemView

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;
}
Also used : CloudFileSystemView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) CloudIdentityType(com.sequenceiq.common.model.CloudIdentityType)

Example 9 with CloudFileSystemView

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();
}
Also used : GcsFileSystem(com.sequenceiq.common.api.filesystem.GcsFileSystem) AdlsGen2FileSystem(com.sequenceiq.common.api.filesystem.AdlsGen2FileSystem) CloudFileSystemView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView) IOException(java.io.IOException) EfsFileSystem(com.sequenceiq.common.api.filesystem.EfsFileSystem) AdlsFileSystem(com.sequenceiq.common.api.filesystem.AdlsFileSystem) WasbFileSystem(com.sequenceiq.common.api.filesystem.WasbFileSystem) S3FileSystem(com.sequenceiq.common.api.filesystem.S3FileSystem)

Example 10 with CloudFileSystemView

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;
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) AzureResourceGroup(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceGroup) SecurityGroup(com.sequenceiq.cloudbreak.domain.SecurityGroup) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) CloudFileSystemView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)

Aggregations

CloudFileSystemView (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView)18 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 Set (java.util.Set)4 Group (com.sequenceiq.cloudbreak.cloud.model.Group)3 SpiFileSystem (com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem)3 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)3 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)3 CloudIdentityType (com.sequenceiq.common.model.CloudIdentityType)3 Backup (com.sequenceiq.freeipa.api.model.Backup)3 HashSet (java.util.HashSet)3 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)2 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)2 CloudGcsView (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudGcsView)2 FileSystem (com.sequenceiq.cloudbreak.domain.FileSystem)2 CloudIdentity (com.sequenceiq.cloudbreak.domain.cloudstorage.CloudIdentity)2 CloudStorage (com.sequenceiq.cloudbreak.domain.cloudstorage.CloudStorage)2 Logging (com.sequenceiq.common.api.telemetry.model.Logging)2 FileSystemType (com.sequenceiq.common.model.FileSystemType)2 AzureResourceGroup (com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceGroup)2