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);
}
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;
}
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();
}
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();
}
Aggregations