Search in sources :

Example 26 with SpiFileSystem

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

the class AwsObjectStorageConnector method validateObjectStorage.

@Override
public ObjectStorageValidateResponse validateObjectStorage(ObjectStorageValidateRequest request) {
    String accountId = Crn.safeFromString(request.getCredential().getId()).getAccountId();
    if (!entitlementService.awsCloudStorageValidationEnabled(accountId)) {
        LOGGER.info("Aws Cloud storage validation entitlement is missing, not validating cloudStorageRequest: {}", JsonUtil.writeValueAsStringSilent(request));
        return ObjectStorageValidateResponse.builder().withStatus(ResponseStatus.OK).build();
    }
    AwsCredentialView awsCredentialView = new AwsCredentialView(request.getCredential());
    AmazonIdentityManagementClient iam = awsClient.createAmazonIdentityManagement(awsCredentialView);
    SpiFileSystem spiFileSystem = request.getSpiFileSystem();
    ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
    resultBuilder.prefix("Cloud Storage validation failed");
    ValidationResult validationResult = awsIDBrokerObjectStorageValidator.validateObjectStorage(iam, spiFileSystem, request.getLogsLocationBase(), request.getBackupLocationBase(), resultBuilder);
    ObjectStorageValidateResponse response;
    if (validationResult.hasError()) {
        response = ObjectStorageValidateResponse.builder().withStatus(ResponseStatus.ERROR).withError(validationResult.getFormattedErrors()).build();
    } else {
        response = ObjectStorageValidateResponse.builder().withStatus(ResponseStatus.OK).withError(validationResult.getFormattedWarnings()).build();
    }
    return response;
}
Also used : AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.common.view.AwsCredentialView) AmazonIdentityManagementClient(com.sequenceiq.cloudbreak.cloud.aws.common.client.AmazonIdentityManagementClient) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) ObjectStorageValidateResponse(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageValidateResponse) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult)

Example 27 with SpiFileSystem

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

the class ComponentTestUtil method getStackForLaunch.

public CloudStack getStackForLaunch(InstanceStatus createRequested, InstanceStatus createRequested1) throws IOException {
    InstanceAuthentication instanceAuthentication = new InstanceAuthentication(PUBLIC_KEY, "pubkeyid", LOGIN_USER_NAME);
    CloudInstance instance = getCloudInstance(instanceAuthentication, "group1", InstanceStatus.CREATE_REQUESTED, 0L, null);
    Security security = getSecurity();
    List<Group> groups = List.of(new Group("group1", InstanceGroupType.CORE, List.of(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), ROOT_VOLUME_SIZE, Optional.empty(), createGroupNetwork(), emptyMap()));
    Network network = new Network(new Subnet(CIDR));
    Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, CORE_CUSTOM_DATA, InstanceGroupType.GATEWAY, GATEWAY_CUSTOM_DATA);
    Image image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
    String template = configuration.getTemplate(LATEST_AWS_CLOUD_FORMATION_TEMPLATE_PATH, "UTF-8").toString();
    SpiFileSystem efsFileSystem = getEfsFileSystem();
    return new CloudStack(groups, network, image, Map.of(), Map.of(), template, instanceAuthentication, LOGIN_USER_NAME, PUBLIC_KEY, efsFileSystem);
}
Also used : Group(com.sequenceiq.cloudbreak.cloud.model.Group) InstanceAuthentication(com.sequenceiq.cloudbreak.cloud.model.InstanceAuthentication) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem) Security(com.sequenceiq.cloudbreak.cloud.model.Security) Image(com.sequenceiq.cloudbreak.cloud.model.Image) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) GroupNetwork(com.sequenceiq.cloudbreak.cloud.model.GroupNetwork) Network(com.sequenceiq.cloudbreak.cloud.model.Network) Subnet(com.sequenceiq.cloudbreak.cloud.model.Subnet)

Example 28 with SpiFileSystem

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

the class ComponentTestUtil method getEfsFileSystem.

private SpiFileSystem getEfsFileSystem() {
    String fileSystemName = "efs-test";
    Map<String, String> tags = new HashMap<>();
    tags.put(CloudEfsConfiguration.KEY_FILESYSTEM_TAGS_NAME, fileSystemName);
    SpiFileSystem newEfsFileSystem = new SpiFileSystem(fileSystemName, FileSystemType.EFS, null, new HashMap<>());
    newEfsFileSystem.putParameter(CloudEfsConfiguration.KEY_ENCRYPTED, true);
    newEfsFileSystem.putParameter(CloudEfsConfiguration.KEY_FILESYSTEM_TAGS, tags);
    newEfsFileSystem.putParameter(CloudEfsConfiguration.KEY_PERFORMANCE_MODE, "generalPurpose");
    newEfsFileSystem.putParameter(CloudEfsConfiguration.KEY_THROUGHPUT_MODE, "provisioned");
    return newEfsFileSystem;
}
Also used : HashMap(java.util.HashMap) SpiFileSystem(com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem)

Aggregations

SpiFileSystem (com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem)28 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)16 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)16 Test (org.junit.Test)15 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 CloudFileSystemView (com.sequenceiq.cloudbreak.cloud.model.filesystem.CloudFileSystemView)5 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)4 Identity (com.microsoft.azure.management.msi.Identity)3 AzureClient (com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient)3 Group (com.sequenceiq.cloudbreak.cloud.model.Group)3 GroupNetwork (com.sequenceiq.cloudbreak.cloud.model.GroupNetwork)3 Network (com.sequenceiq.cloudbreak.cloud.model.Network)3 StorageLocationBase (com.sequenceiq.common.api.cloudstorage.StorageLocationBase)3 List (java.util.List)3 PagedList (com.microsoft.azure.PagedList)2 RoleAssignmentInner (com.microsoft.azure.management.graphrbac.implementation.RoleAssignmentInner)2 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)2 Subscription (com.microsoft.azure.management.resources.Subscription)2 StorageAccount (com.microsoft.azure.management.storage.StorageAccount)2 AzureStorage (com.sequenceiq.cloudbreak.cloud.azure.AzureStorage)2