use of com.sequenceiq.cloudbreak.cloud.event.credential.CredentialPrerequisitesResult in project cloudbreak by hortonworks.
the class CredentialPrerequisiteService method getCloudbreakPrerequisites.
public CredentialPrerequisitesResponse getCloudbreakPrerequisites(String cloudPlatform, String deploymentAddress, CredentialType type) {
CloudContext cloudContext = CloudContext.Builder.builder().withPlatform(cloudPlatform).withWorkspaceId(TEMP_WORKSPACE_ID).build();
CredentialPrerequisitesRequest request = new CredentialPrerequisitesRequest(cloudContext, userPreferencesService.getExternalIdForCurrentUser(), userPreferencesService.getAuditExternalIdForCurrentUser(), deploymentAddress, type);
LOGGER.debug("Triggering event: {}", request);
eventBus.notify(request.selector(), eventFactory.createEvent(request));
String message = String.format("Failed to get prerequisites for platform '%s': ", cloudPlatform);
try {
CredentialPrerequisitesResult res = request.await();
LOGGER.debug("Result: {}", res);
if (res.getStatus() != EventStatus.OK) {
LOGGER.info(message, res.getErrorDetails());
throw new BadRequestException(message + res.getErrorDetails(), res.getErrorDetails());
}
return res.getCredentialPrerequisitesResponse();
} catch (InterruptedException e) {
LOGGER.error(message, e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.credential.CredentialPrerequisitesResult in project cloudbreak by hortonworks.
the class CredentialPrerequisiteService method getCloudbreakPrerequisites.
public CredentialPrerequisitesResponse getCloudbreakPrerequisites(String cloudPlatform, boolean govCloud, String deploymentAddress, CredentialType type) {
CloudContext cloudContext = CloudContext.Builder.builder().withPlatform(cloudPlatform).withGovCloud(govCloud).withWorkspaceId(TEMP_WORKSPACE_ID).build();
CredentialPrerequisitesRequest request = new CredentialPrerequisitesRequest(cloudContext, userPreferencesService.getExternalIdForCurrentUser(), userPreferencesService.getAuditExternalIdForCurrentUser(), deploymentAddress, type);
LOGGER.debug("Triggering event: {}", request);
eventBus.notify(request.selector(), eventFactory.createEvent(request));
String message = String.format("Failed to get prerequisites for platform '%s': ", cloudPlatform);
try {
CredentialPrerequisitesResult res = request.await();
LOGGER.debug("Result: {}", res);
if (res.getStatus() != EventStatus.OK) {
LOGGER.info(message, res.getErrorDetails());
throw new BadRequestException(message + res.getErrorDetails(), res.getErrorDetails());
}
return res.getCredentialPrerequisitesResponse();
} catch (InterruptedException e) {
LOGGER.error(message, e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.cloud.event.credential.CredentialPrerequisitesResult 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()));
}
}
Aggregations