Search in sources :

Example 1 with CloudAdlsGen2View

use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View in project cloudbreak by hortonworks.

the class CloudStorageParametersConverter method adlsGen2ToCloudView.

public CloudAdlsGen2View adlsGen2ToCloudView(StorageIdentityBase source) {
    CloudAdlsGen2View cloudAdlsGen2View = new CloudAdlsGen2View(source.getType());
    AdlsGen2CloudStorageV1Parameters adlsGen2 = source.getAdlsGen2();
    cloudAdlsGen2View.setAccountKey(adlsGen2.getAccountKey());
    cloudAdlsGen2View.setAccountName(adlsGen2.getAccountName());
    cloudAdlsGen2View.setSecure(adlsGen2.isSecure());
    cloudAdlsGen2View.setManagedIdentity(adlsGen2.getManagedIdentity());
    return cloudAdlsGen2View;
}
Also used : AdlsGen2CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters) CloudAdlsGen2View(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View)

Example 2 with CloudAdlsGen2View

use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View in project cloudbreak by hortonworks.

the class AzureSetup method validateAdlsGen2FileSystem.

private void validateAdlsGen2FileSystem(SpiFileSystem fileSystem) throws URISyntaxException, InvalidKeyException, StorageException {
    CloudAdlsGen2View cloudFileSystem = (CloudAdlsGen2View) fileSystem.getCloudFileSystems().get(0);
    String accountName = cloudFileSystem.getAccountName();
    String accountKey = cloudFileSystem.getAccountKey();
    String connectionString = "DefaultEndpointsProtocol=https;AccountName=" + accountName + ";AccountKey=" + accountKey + ";EndpointSuffix=core.windows.net";
    CloudStorageAccount storageAccount = CloudStorageAccount.parse(connectionString);
    CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
    CloudBlobContainer containerReference = blobClient.getContainerReference(TEST_CONTAINER + System.nanoTime());
    try {
        containerReference.createIfNotExists();
        containerReference.delete();
    } catch (StorageException e) {
        if (e.getCause() instanceof UnknownHostException) {
            throw new CloudConnectorException("The provided account does not belong to a valid storage account");
        }
    }
}
Also used : CloudBlobClient(com.microsoft.azure.storage.blob.CloudBlobClient) UnknownHostException(java.net.UnknownHostException) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) CloudStorageAccount(com.microsoft.azure.storage.CloudStorageAccount) CloudAdlsGen2View(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View) CloudBlobContainer(com.microsoft.azure.storage.blob.CloudBlobContainer) StorageException(com.microsoft.azure.storage.StorageException)

Example 3 with CloudAdlsGen2View

use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View in project cloudbreak by hortonworks.

the class StackToCloudStackConverter method buildFileSystemViewFromTelemetry.

private Optional<CloudFileSystemView> buildFileSystemViewFromTelemetry(Logging logging) {
    if (logging.getStorageLocation() != null) {
        if (logging.getS3() != null) {
            CloudS3View s3View = new CloudS3View(CloudIdentityType.LOG);
            s3View.setInstanceProfile(logging.getS3().getInstanceProfile());
            return Optional.of(s3View);
        } else if (logging.getAdlsGen2() != null) {
            CloudAdlsGen2View adlsGen2View = new CloudAdlsGen2View(CloudIdentityType.LOG);
            AdlsGen2CloudStorageV1Parameters adlsGen2Params = logging.getAdlsGen2();
            adlsGen2View.setAccountKey(adlsGen2Params.getAccountKey());
            adlsGen2View.setAccountName(adlsGen2Params.getAccountName());
            adlsGen2View.setSecure(adlsGen2Params.isSecure());
            adlsGen2View.setManagedIdentity(adlsGen2Params.getManagedIdentity());
            return Optional.of(adlsGen2View);
        } else if (logging.getGcs() != null) {
            CloudGcsView cloudGcsView = new CloudGcsView(CloudIdentityType.LOG);
            cloudGcsView.setServiceAccountEmail(logging.getGcs().getServiceAccountEmail());
            return Optional.of(cloudGcsView);
        } else if (logging.getCloudwatch() != null) {
            CloudS3View s3View = new CloudS3View(CloudIdentityType.LOG);
            s3View.setInstanceProfile(logging.getCloudwatch().getInstanceProfile());
            return Optional.of(s3View);
        }
    }
    return Optional.empty();
}
Also used : CloudGcsView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudGcsView) AdlsGen2CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters) CloudAdlsGen2View(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View) CloudS3View(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudS3View)

Example 4 with CloudAdlsGen2View

use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View in project cloudbreak by hortonworks.

the class StackToCloudStackConverter method buildFileSystemViewFromBackup.

private Optional<CloudFileSystemView> buildFileSystemViewFromBackup(Backup backup) {
    if (backup.getStorageLocation() != null) {
        if (backup.getS3() != null) {
            CloudS3View s3View = new CloudS3View(CloudIdentityType.LOG);
            s3View.setInstanceProfile(backup.getS3().getInstanceProfile());
            return Optional.of(s3View);
        } else if (backup.getAdlsGen2() != null) {
            CloudAdlsGen2View adlsGen2View = new CloudAdlsGen2View(CloudIdentityType.LOG);
            AdlsGen2CloudStorageV1Parameters adlsGen2Params = backup.getAdlsGen2();
            adlsGen2View.setAccountKey(adlsGen2Params.getAccountKey());
            adlsGen2View.setAccountName(adlsGen2Params.getAccountName());
            adlsGen2View.setSecure(adlsGen2Params.isSecure());
            adlsGen2View.setManagedIdentity(adlsGen2Params.getManagedIdentity());
            return Optional.of(adlsGen2View);
        } else if (backup.getGcs() != null) {
            CloudGcsView cloudGcsView = new CloudGcsView(CloudIdentityType.LOG);
            cloudGcsView.setServiceAccountEmail(backup.getGcs().getServiceAccountEmail());
            return Optional.of(cloudGcsView);
        }
    }
    return Optional.empty();
}
Also used : CloudGcsView(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudGcsView) AdlsGen2CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.AdlsGen2CloudStorageV1Parameters) CloudAdlsGen2View(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View) CloudS3View(com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudS3View)

Example 5 with CloudAdlsGen2View

use of com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudAdlsGen2View in project cloudbreak by hortonworks.

the class FileSystemConverter method cloudIdentityToAdlsGen2View.

private CloudFileSystemView cloudIdentityToAdlsGen2View(CloudIdentity cloudIdentity) {
    CloudAdlsGen2View cloudAdlsGen2View = new CloudAdlsGen2View(cloudIdentity.getIdentityType());
    AdlsGen2Identity adlsGen2Identity = cloudIdentity.getAdlsGen2Identity();
    if (Objects.isNull(adlsGen2Identity)) {
        LOGGER.warn("ADLS Gen2 managed identity with type {} is null.", cloudIdentity.getIdentityType());
        return null;
    }
    cloudAdlsGen2View.setManagedIdentity(adlsGen2Identity.getManagedIdentity());
    return cloudAdlsGen2View;
}
Also used : AdlsGen2Identity(com.sequenceiq.cloudbreak.domain.cloudstorage.AdlsGen2Identity) 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