Search in sources :

Example 1 with Credential

use of com.sequenceiq.cloudbreak.domain.Credential in project cloudbreak by hortonworks.

the class AbstractFileSystemConfiguratorTest method testGetScripts.

@Test
public void testGetScripts() {
    Credential credential = new Credential();
    credential.setId(0L);
    FileSystemConfiguration fsConfig = new FileSystemConfiguration();
    List<RecipeScript> actual = underTest.getScripts(credential, fsConfig);
    List<RecipeScript> expected = singletonList(new RecipeScript("echo 'newContent'", ExecutionType.ALL_NODES, RecipeType.POST_AMBARI_START));
    Assert.assertEquals(expected, actual);
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) RecipeScript(com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript) FileSystemConfiguration(com.sequenceiq.cloudbreak.api.model.FileSystemConfiguration) Test(org.junit.Test)

Example 2 with Credential

use of com.sequenceiq.cloudbreak.domain.Credential in project cloudbreak by hortonworks.

the class CredentialController method getPublics.

@Override
public Set<CredentialResponse> getPublics() {
    IdentityUser user = authenticatedUserService.getCbUser();
    Set<Credential> credentials = credentialService.retrieveAccountCredentials(user);
    return convertCredentials(credentials);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) Credential(com.sequenceiq.cloudbreak.domain.Credential)

Example 3 with Credential

use of com.sequenceiq.cloudbreak.domain.Credential in project cloudbreak by hortonworks.

the class CredentialController method convert.

private Credential convert(CredentialRequest json, boolean publicInAccount) {
    Credential converted = conversionService.convert(json, Credential.class);
    converted.setPublicInAccount(publicInAccount);
    return converted;
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential)

Example 4 with Credential

use of com.sequenceiq.cloudbreak.domain.Credential in project cloudbreak by hortonworks.

the class CredentialController method modifyCredential.

private CredentialResponse modifyCredential(IdentityUser user, CredentialRequest credentialRequest, boolean publicInAccount) {
    Credential credential = convert(credentialRequest, publicInAccount);
    credential = credentialService.modify(user, credential);
    return convert(credential);
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential)

Example 5 with Credential

use of com.sequenceiq.cloudbreak.domain.Credential in project cloudbreak by hortonworks.

the class CredentialRequestToCredentialConverter method convert.

@Override
public Credential convert(CredentialRequest source) {
    Credential credential = new Credential();
    credential.setName(source.getName());
    credential.setDescription(source.getDescription());
    String cloudPlatform = source.getCloudPlatform();
    credential.setCloudPlatform(cloudPlatform);
    Map<String, Object> parameters = credentialDefinitionService.processProperties(platform(cloudPlatform), source.getParameters());
    if (parameters != null && !parameters.isEmpty()) {
        try {
            credential.setAttributes(new Json(parameters));
        } catch (JsonProcessingException ignored) {
            throw new BadRequestException("Invalid parameters");
        }
    }
    if (source.getTopologyId() != null) {
        credential.setTopology(topologyService.getById(source.getTopologyId()));
    }
    return credential;
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) Json(com.sequenceiq.cloudbreak.domain.json.Json) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

Credential (com.sequenceiq.cloudbreak.domain.Credential)44 Test (org.junit.Test)14 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)8 AccessDeniedException (org.springframework.security.access.AccessDeniedException)8 Json (com.sequenceiq.cloudbreak.domain.json.Json)7 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)6 Template (com.sequenceiq.cloudbreak.domain.Template)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 FileSystemConfiguration (com.sequenceiq.cloudbreak.api.model.FileSystemConfiguration)3 FileSystemScriptConfig (com.sequenceiq.cloudbreak.blueprint.filesystem.FileSystemScriptConfig)3 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)3 Transactional (javax.transaction.Transactional)3 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)2 GcsFileSystemConfiguration (com.sequenceiq.cloudbreak.api.model.GcsFileSystemConfiguration)2 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)2 Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)2 PlatformDisks (com.sequenceiq.cloudbreak.cloud.model.PlatformDisks)2 VmTypeMeta (com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta)2 VolumeParameterConfig (com.sequenceiq.cloudbreak.cloud.model.VolumeParameterConfig)2 RecipeScript (com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript)2