Search in sources :

Example 6 with CloudAdlsGen2View

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

Example 7 with 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();
}
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 8 with CloudAdlsGen2View

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

Example 9 with 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");
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) AzureCredentialView(com.sequenceiq.cloudbreak.cloud.azure.view.AzureCredentialView) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) HashMap(java.util.HashMap) GroupNetwork(com.sequenceiq.cloudbreak.cloud.model.GroupNetwork) Network(com.sequenceiq.cloudbreak.cloud.model.Network) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CloudAdlsGen2View(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View) AzureStackView(com.sequenceiq.cloudbreak.cloud.azure.view.AzureStackView) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Subnet(com.sequenceiq.cloudbreak.cloud.model.Subnet) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 10 with CloudAdlsGen2View

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);
}
Also used : AccountMappingBase(com.sequenceiq.common.api.cloudstorage.AccountMappingBase) CloudAdlsGen2View(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View)

Aggregations

CloudAdlsGen2View (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View)10 AdlsGen2CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters)3 CloudGcsView (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudGcsView)2 CloudS3View (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudS3View)2 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 CloudStorageAccount (com.microsoft.azure.storage.CloudStorageAccount)1 StorageException (com.microsoft.azure.storage.StorageException)1 CloudBlobClient (com.microsoft.azure.storage.blob.CloudBlobClient)1 CloudBlobContainer (com.microsoft.azure.storage.blob.CloudBlobContainer)1 AzureCredentialView (com.sequenceiq.cloudbreak.cloud.azure.view.AzureCredentialView)1 AzureStackView (com.sequenceiq.cloudbreak.cloud.azure.view.AzureStackView)1 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)1 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)1 Group (com.sequenceiq.cloudbreak.cloud.model.Group)1 GroupNetwork (com.sequenceiq.cloudbreak.cloud.model.GroupNetwork)1 InstanceAuthentication (com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication)1 Network (com.sequenceiq.cloudbreak.cloud.model.Network)1