use of com.sequenceiq.cloudbreak.cloud.response.CredentialPrerequisitesResponse in project cloudbreak by hortonworks.
the class AzureCredentialConnectorTest method testGetPrerequisitesOnlyAzureIsImplemented.
@Test
public void testGetPrerequisitesOnlyAzureIsImplemented() {
String expected = "someAppCreationCommandValue";
when(appCreationCommand.generateEnvironmentCredentialCommand(anyString())).thenReturn(expected);
CredentialPrerequisitesResponse result = underTest.getPrerequisites(TEST_CLOUD_CONTEXT, "2", "3", DEPLOYMENT_ADDRESS, CredentialType.ENVIRONMENT);
assertNull(result.getAws());
assertNull(result.getGcp());
assertNotNull(result.getAzure());
}
use of com.sequenceiq.cloudbreak.cloud.response.CredentialPrerequisitesResponse in project cloudbreak by hortonworks.
the class GcpCredentialConnector method getPrerequisites.
@Override
public CredentialPrerequisitesResponse getPrerequisites(CloudContext cloudContext, String externalId, String auditExternalId, String deploymentAddress, CredentialType type) {
String prerequisitesCreationCommand = gcpPlatformParameters.getPrerequisitesCreationCommand(type);
GcpCredentialPrerequisites gcpPrereqs = new GcpCredentialPrerequisites(Base64.encodeBase64String(prerequisitesCreationCommand.getBytes()));
return new CredentialPrerequisitesResponse(cloudContext.getPlatform().value(), gcpPrereqs);
}
use of com.sequenceiq.cloudbreak.cloud.response.CredentialPrerequisitesResponse in project cloudbreak by hortonworks.
the class CredentialPrerequisitesHandler method accept.
@Override
public void accept(Event<CredentialPrerequisitesRequest> credentialPrerequisitesRequestEvent) {
LOGGER.debug("Received event: {}", credentialPrerequisitesRequestEvent);
CredentialPrerequisitesRequest request = credentialPrerequisitesRequestEvent.getData();
CloudContext cloudContext = request.getCloudContext();
try {
LOGGER.info("Gathering credential prerequisites for platform: '{}'", cloudContext.getPlatform());
CloudConnector<?> connector = cloudPlatformConnectors.getDefault(cloudContext.getPlatform());
CredentialPrerequisitesResponse result = connector.credentials().getPrerequisites(cloudContext, request.getExternalId(), request.getAuditExternalId(), request.getDeploymentAddress(), request.getType());
CredentialPrerequisitesResult credentialPrerequisitesResult = new CredentialPrerequisitesResult(request.getResourceId(), result);
request.getResult().onNext(credentialPrerequisitesResult);
LOGGER.debug("Credential prerequisites have been collected successfully for platform: '{}'!", cloudContext.getPlatform().value());
} catch (RuntimeException e) {
request.getResult().onNext(new CredentialPrerequisitesResult(e.getMessage(), e, request.getResourceId()));
}
}
use of com.sequenceiq.cloudbreak.cloud.response.CredentialPrerequisitesResponse in project cloudbreak by hortonworks.
the class AzureCredentialConnector method getPrerequisites.
@Override
public CredentialPrerequisitesResponse getPrerequisites(CloudContext cloudContext, String externalId, String auditExternalId, String deploymentAddress, CredentialType type) {
String credentialCreationCommand = appCreationCommand.generateEnvironmentCredentialCommand(deploymentAddress);
String auditCredentialCreationCommand = appCreationCommand.generateAuditCredentialCommand(deploymentAddress);
String encodedCommand;
String roleDefJson;
switch(type) {
case ENVIRONMENT:
roleDefJson = azurePlatformParameters.getRoleDefJson();
encodedCommand = Base64.encodeBase64String(credentialCreationCommand.getBytes());
break;
case AUDIT:
roleDefJson = azurePlatformParameters.getAuditRoleDefJson();
encodedCommand = Base64.encodeBase64String(auditCredentialCreationCommand.getBytes());
break;
default:
encodedCommand = null;
roleDefJson = null;
break;
}
AzureCredentialPrerequisites azurePrerequisites = new AzureCredentialPrerequisites(encodedCommand, roleDefJson);
return new CredentialPrerequisitesResponse(cloudContext.getPlatform().value(), azurePrerequisites);
}
use of com.sequenceiq.cloudbreak.cloud.response.CredentialPrerequisitesResponse in project cloudbreak by hortonworks.
the class CredentialPrerequisiteService method getPrerequisites.
public CredentialPrerequisitesResponse getPrerequisites(String cloudPlatform, String deploymentAddress, CredentialType type) {
CredentialPrerequisitesResponse result = getCloudbreakPrerequisites(cloudPlatform, deploymentAddress, type);
if (isPolicyFetchFromExperiencesAllowed()) {
if (AWS.name().equalsIgnoreCase(cloudPlatform)) {
try {
Map<String, String> policies = getExperiencePrerequisites(cloudPlatform);
if (result.getAws().getPolicies() != null) {
policies.putAll(result.getAws().getPolicies());
}
fillPoliciesWithDefaultIfMissing(result.getAws().getPolicyJson(), policies);
result.getAws().setPolicies(policies);
} catch (Exception e) {
LOGGER.warn("Something has happened during the granular policy fetch from the experiences!", e);
}
} else {
LOGGER.info("Fetching is enabled but the requested prerequisites from the experiences are addressed for a currently not supported " + "cloud platform: " + cloudPlatform);
}
} else {
LOGGER.info("Fetching fine graded policies from the experiences has disabled by the entitlement: " + CDP_AWS_RESTRICTED_POLICY.name());
}
return result;
}
Aggregations