Search in sources :

Example 1 with CloudIdentityType

use of com.sequenceiq.common.model.CloudIdentityType in project cloudbreak by hortonworks.

the class GrainPropertiesService method setCloudIdentityRoles.

private void setCloudIdentityRoles(GrainProperties propertiesForIdentityRoles, InstanceMetaData instanceMetaData) {
    InstanceGroup instanceGroup = instanceMetaData.getInstanceGroup();
    CloudIdentityType cloudIdentityType = instanceGroup.getCloudIdentityType().orElse(CloudIdentityType.LOG);
    Map<String, String> grainsForInstance = new HashMap<>();
    grainsForInstance.put(ROLES, cloudIdentityType.roleName());
    propertiesForIdentityRoles.put(instanceMetaData.getDiscoveryFQDN(), grainsForInstance);
}
Also used : HashMap(java.util.HashMap) CloudIdentityType(com.sequenceiq.common.model.CloudIdentityType) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 2 with CloudIdentityType

use of com.sequenceiq.common.model.CloudIdentityType 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 3 with CloudIdentityType

use of com.sequenceiq.common.model.CloudIdentityType in project cloudbreak by hortonworks.

the class AzureIDBrokerObjectStorageValidator method validateObjectStorage.

public ValidationResult validateObjectStorage(AzureClient client, SpiFileSystem spiFileSystem, String logsLocationBase, String backupLocationBase, String singleResourceGroupName, ValidationResultBuilder resultBuilder) {
    LOGGER.info("Validating Azure identities...");
    List<CloudFileSystemView> cloudFileSystems = spiFileSystem.getCloudFileSystems();
    validateHierarchicalNamespace(client, spiFileSystem, logsLocationBase, backupLocationBase, resultBuilder);
    if (Objects.nonNull(cloudFileSystems) && cloudFileSystems.size() > 0) {
        for (CloudFileSystemView cloudFileSystemView : cloudFileSystems) {
            CloudAdlsGen2View cloudFileSystem = (CloudAdlsGen2View) cloudFileSystemView;
            String managedIdentityId = cloudFileSystem.getManagedIdentity();
            Identity identity = client.getIdentityById(managedIdentityId);
            CloudIdentityType cloudIdentityType = cloudFileSystem.getCloudIdentityType();
            if (identity != null) {
                if (ID_BROKER.equals(cloudIdentityType)) {
                    List<RoleAssignmentInner> roleAssignments;
                    Optional<ResourceGroup> singleResourceGroup;
                    if (singleResourceGroupName != null) {
                        ResourceGroup resourceGroup = client.getResourceGroup(singleResourceGroupName);
                        roleAssignments = client.listRoleAssignmentsByScopeInner(resourceGroup.id());
                        singleResourceGroup = Optional.of(resourceGroup);
                    } else {
                        roleAssignments = client.listRoleAssignments();
                        singleResourceGroup = Optional.empty();
                    }
                    validateIDBroker(client, roleAssignments, identity, cloudFileSystem, singleResourceGroup, resultBuilder);
                } else if (LOG.equals(cloudIdentityType)) {
                    validateLog(client, identity, logsLocationBase, resultBuilder);
                }
            } else {
                addError(resultBuilder, String.format("%s Identity with id %s does not exist in the given Azure subscription. %s", getIdentityType(cloudIdentityType), managedIdentityId, getAdviceMessage(IDENTITY, cloudIdentityType)));
            }
        }
    }
    return resultBuilder.build();
}
Also used : CloudFileSystemView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView) CloudAdlsGen2View(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View) CloudIdentityType(com.sequenceiq.common.model.CloudIdentityType) Identity(com.microsoft.azure.management.msi.Identity) RoleAssignmentInner(com.microsoft.azure.management.graphrbac.implementation.RoleAssignmentInner) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup)

Example 4 with CloudIdentityType

use of com.sequenceiq.common.model.CloudIdentityType in project cloudbreak by hortonworks.

the class AwsIDBrokerObjectStorageValidator method validateObjectStorage.

public ValidationResult validateObjectStorage(AmazonIdentityManagementClient iam, SpiFileSystem spiFileSystem, String logsLocationBase, String backupLocationBase, ValidationResultBuilder resultBuilder) {
    List<CloudFileSystemView> cloudFileSystems = spiFileSystem.getCloudFileSystems();
    for (CloudFileSystemView cloudFileSystemView : cloudFileSystems) {
        CloudS3View cloudFileSystem = (CloudS3View) cloudFileSystemView;
        String instanceProfileArn = cloudFileSystem.getInstanceProfile();
        InstanceProfile instanceProfile = awsIamService.getInstanceProfile(iam, instanceProfileArn, cloudFileSystem.getCloudIdentityType(), resultBuilder);
        if (instanceProfile != null) {
            CloudIdentityType cloudIdentityType = cloudFileSystem.getCloudIdentityType();
            if (CloudIdentityType.ID_BROKER.equals(cloudIdentityType)) {
                validateIDBroker(iam, instanceProfile, cloudFileSystem, resultBuilder);
            } else if (CloudIdentityType.LOG.equals(cloudIdentityType)) {
                validateLog(iam, instanceProfile, cloudFileSystem, logsLocationBase, backupLocationBase, resultBuilder);
            }
        }
    }
    return resultBuilder.build();
}
Also used : InstanceProfile(com.amazonaws.services.identitymanagement.model.InstanceProfile) CloudFileSystemView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView) CloudIdentityType(com.sequenceiq.common.model.CloudIdentityType) CloudS3View(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudS3View)

Aggregations

CloudIdentityType (com.sequenceiq.common.model.CloudIdentityType)4 CloudFileSystemView (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView)3 InstanceProfile (com.amazonaws.services.identitymanagement.model.InstanceProfile)1 RoleAssignmentInner (com.microsoft.azure.management.graphrbac.implementation.RoleAssignmentInner)1 Identity (com.microsoft.azure.management.msi.Identity)1 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)1 SpiFileSystem (com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem)1 CloudAdlsGen2View (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View)1 CloudS3View (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudS3View)1 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)1 HashMap (java.util.HashMap)1