use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View in project cloudbreak by hortonworks.
the class FileSystemConverter method convertAdlsGen2Legacy.
private CloudAdlsGen2View convertAdlsGen2Legacy(AdlsGen2FileSystem source) {
CloudAdlsGen2View cloudAdlsGen2View = new CloudAdlsGen2View(CloudIdentityType.LOG);
cloudAdlsGen2View.setAccountName(source.getAccountName());
cloudAdlsGen2View.setAccountKey(source.getAccountKey());
cloudAdlsGen2View.setResourceGroupName(source.getStorageContainerName());
cloudAdlsGen2View.setSecure(source.isSecure());
cloudAdlsGen2View.setManagedIdentity(source.getManagedIdentity());
return cloudAdlsGen2View;
}
use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View 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.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View in project cloudbreak by hortonworks.
the class CloudStorageParametersConverter method adlsGen2ToCloudView.
public CloudAdlsGen2View adlsGen2ToCloudView(AdlsGen2CloudStorageV1Parameters source) {
CloudAdlsGen2View cloudAdlsGen2View = new CloudAdlsGen2View(CloudIdentityType.LOG);
cloudAdlsGen2View.setAccountKey(source.getAccountKey());
cloudAdlsGen2View.setAccountName(source.getAccountName());
cloudAdlsGen2View.setSecure(source.isSecure());
cloudAdlsGen2View.setManagedIdentity(source.getManagedIdentity());
return cloudAdlsGen2View;
}
use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View in project cloudbreak by hortonworks.
the class AzureTemplateBuilderTest method buildTestWithManagedIdentityGiven.
@ParameterizedTest(name = "buildTestWithManagedIdentityGiven {0}")
@MethodSource("templatesPathDataProvider")
public void buildTestWithManagedIdentityGiven(String templatePath) {
// GIVEN
assumeTrue(isTemplateVersionGreaterOrEqualThan2100(templatePath));
ReflectionTestUtils.setField(azureTemplateBuilder, FIELD_ARM_TEMPLATE_PATH, templatePath);
Network network = new Network(new Subnet("testSubnet"));
when(azureUtils.isPrivateIp(any())).thenReturn(false);
when(azureAcceleratedNetworkValidator.validate(any())).thenReturn(ACCELERATED_NETWORK_SUPPORT);
Map<String, String> parameters = new HashMap<>();
parameters.put("persistentStorage", "persistentStorageTest");
parameters.put("attachedStorageOption", "attachedStorageOptionTest");
InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak");
CloudAdlsGen2View cloudAdlsGen2View = new CloudAdlsGen2View(CloudIdentityType.LOG);
cloudAdlsGen2View.setManagedIdentity("myIdentity");
groups.add(new Group(name, InstanceGroupType.CORE, Collections.singletonList(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), ROOT_VOLUME_SIZE, Optional.of(cloudAdlsGen2View), createGroupNetwork(), emptyMap()));
cloudStack = new CloudStack(groups, network, image, parameters, tags, azureTemplateBuilder.getTemplateString(), instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), null);
azureStackView = new AzureStackView("mystack", 3, groups, azureStorageView, azureSubnetStrategy, Collections.emptyMap());
// WHEN
when(azureStorage.getImageStorageName(any(AzureCredentialView.class), any(CloudContext.class), any(CloudStack.class))).thenReturn("test");
when(azureStorage.getDiskContainerName(any(CloudContext.class))).thenReturn("testStorageContainer");
String templateString = azureTemplateBuilder.build(stackName, CUSTOM_IMAGE_NAME, azureCredentialView, azureStackView, cloudContext, cloudStack, AzureInstanceTemplateOperation.PROVISION, azureMarketplaceImage);
// THEN
gson.fromJson(templateString, Map.class);
assertThat(templateString).contains("\"identity\": {");
assertThat(templateString).contains("\"type\": \"userAssigned\",");
assertThat(templateString).contains(" \"userAssignedIdentities\": {\n" + " \"myIdentity\": {\n" + " }\n" + " }\n");
}
use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View in project cloudbreak by hortonworks.
the class AzureIDBrokerObjectStorageValidatorTest method getCloudFileSystemViews.
private List<CloudFileSystemView> getCloudFileSystemViews(boolean addMapping) {
CloudAdlsGen2View idBrokerCloudFileSystem = new CloudAdlsGen2View(CloudIdentityType.ID_BROKER);
idBrokerCloudFileSystem.setManagedIdentity(ASSUMER_IDENTITY);
idBrokerCloudFileSystem.setLocations(getStorageLocation());
if (addMapping) {
AccountMappingBase accountMapping = new AccountMappingBase();
accountMapping.setGroupMappings(Map.ofEntries(Map.entry(GROUP_1, GROUP_IDENTITY_1)));
accountMapping.setUserMappings(Map.ofEntries(Map.entry(USER_1, USER_IDENTITY_1_CASE)));
idBrokerCloudFileSystem.setAccountMapping(accountMapping);
}
CloudAdlsGen2View loggerCloudFileSystem = new CloudAdlsGen2View(CloudIdentityType.LOG);
loggerCloudFileSystem.setManagedIdentity(LOG_IDENTITY);
loggerCloudFileSystem.setLocations(getStorageLocation());
return List.of(idBrokerCloudFileSystem, loggerCloudFileSystem);
}
Aggregations