use of com.sequenceiq.cloudbreak.service.stack.connector.OperationException in project cloudbreak by hortonworks.
the class ServiceProviderConnectorAdapter method getPlatformParameters.
public PlatformParameters getPlatformParameters(Stack stack) {
LOGGER.debug("Get platform parameters for: {}", stack);
Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
CloudContext cloudContext = new CloudContext(stack.getId(), stack.getName(), stack.cloudPlatform(), stack.getOwner(), stack.getPlatformVariant(), location);
CloudCredential cloudCredential = credentialConverter.convert(stack.getCredential());
PlatformParameterRequest parameterRequest = new PlatformParameterRequest(cloudContext, cloudCredential);
eventBus.notify(parameterRequest.selector(), eventFactory.createEvent(parameterRequest));
try {
PlatformParameterResult res = parameterRequest.await();
LOGGER.info("Platform parameter result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
LOGGER.error("Failed to get platform parameters", res.getErrorDetails());
throw new OperationException(res.getErrorDetails());
}
return res.getPlatformParameters();
} catch (InterruptedException e) {
LOGGER.error("Error while getting platform parameters: " + cloudContext, e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.service.stack.connector.OperationException in project cloudbreak by hortonworks.
the class ServiceProviderConnectorAdapter method deleteStack.
public void deleteStack(Stack stack, Credential credential) {
LOGGER.debug("Assembling terminate stack event for stack: {}", stack);
Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
CloudContext cloudContext = new CloudContext(stack.getId(), stack.getName(), stack.cloudPlatform(), stack.getOwner(), stack.getPlatformVariant(), location);
CloudCredential cloudCredential = credentialConverter.convert(stack.getCredential());
List<CloudResource> resources = cloudResourceConverter.convert(stack.getResources());
CloudStack cloudStack = cloudStackConverter.convert(stack);
TerminateStackRequest<TerminateStackResult> terminateRequest = new TerminateStackRequest<>(cloudContext, cloudStack, cloudCredential, resources);
LOGGER.info("Triggering terminate stack event: {}", terminateRequest);
eventBus.notify(terminateRequest.selector(), eventFactory.createEvent(terminateRequest));
try {
TerminateStackResult res = terminateRequest.await();
LOGGER.info("Terminate stack result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
if (res.getErrorDetails() != null) {
LOGGER.error("Failed to terminate the stack", res.getErrorDetails());
throw new OperationException(res.getErrorDetails());
}
throw new OperationException(format("Failed to terminate the stack: %s due to %s", cloudContext, res.getStatusReason()));
}
} catch (InterruptedException e) {
LOGGER.error("Error while terminating the stack", e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.service.stack.connector.OperationException in project cloudbreak by hortonworks.
the class ServiceProviderConnectorAdapter method getTemplate.
public String getTemplate(Stack stack) {
Location location = location(region(stack.getRegion()), availabilityZone(stack.getAvailabilityZone()));
CloudContext cloudContext = new CloudContext(stack.getId(), stack.getName(), stack.cloudPlatform(), stack.getOwner(), stack.getPlatformVariant(), location);
CloudCredential cloudCredential = credentialConverter.convert(stack.getCredential());
GetPlatformTemplateRequest getPlatformTemplateRequest = new GetPlatformTemplateRequest(cloudContext, cloudCredential);
eventBus.notify(getPlatformTemplateRequest.selector(), eventFactory.createEvent(getPlatformTemplateRequest));
try {
GetPlatformTemplateResult res = getPlatformTemplateRequest.await();
LOGGER.info("Get template result: {}", res);
if (res.getStatus().equals(EventStatus.FAILED)) {
LOGGER.error("Failed to get template", res.getErrorDetails());
throw new OperationException(res.getErrorDetails());
}
return res.getTemplate();
} catch (InterruptedException e) {
LOGGER.error("Error while getting template: " + cloudContext, e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.service.stack.connector.OperationException in project cloudbreak by hortonworks.
the class ServiceProviderCredentialAdapter method interactiveLogin.
public Map<String, String> interactiveLogin(Credential credential) {
CloudContext cloudContext = new CloudContext(credential.getId(), credential.getName(), credential.cloudPlatform(), credential.getOwner());
ExtendedCloudCredential cloudCredential = extendedCloudCredentialConverter.convert(credential);
InteractiveLoginRequest request = new InteractiveLoginRequest(cloudContext, cloudCredential);
LOGGER.info("Triggering event: {}", request);
eventBus.notify(request.selector(), eventFactory.createEvent(request));
try {
InteractiveLoginResult res = request.await();
String message = "Interactive login Failed: ";
LOGGER.info("Result: {}", res);
if (res.getStatus() != EventStatus.OK) {
LOGGER.error(message, res.getErrorDetails());
throw new BadRequestException(message + res.getErrorDetails(), res.getErrorDetails());
}
return res.getParameters();
} catch (InterruptedException e) {
LOGGER.error("Error while executing credential verification", e);
throw new OperationException(e);
}
}
use of com.sequenceiq.cloudbreak.service.stack.connector.OperationException in project cloudbreak by hortonworks.
the class ServiceProviderCredentialAdapter method init.
public Credential init(Credential credential) {
CloudContext cloudContext = new CloudContext(credential.getId(), credential.getName(), credential.cloudPlatform(), credential.getOwner());
CloudCredential cloudCredential = credentialConverter.convert(credential);
CredentialVerificationRequest request = new CredentialVerificationRequest(cloudContext, cloudCredential);
LOGGER.info("Triggering event: {}", request);
eventBus.notify(request.selector(), eventFactory.createEvent(request));
try {
CredentialVerificationResult res = request.await();
String message = "Failed to verify the credential: ";
LOGGER.info("Result: {}", res);
if (res.getStatus() != EventStatus.OK) {
LOGGER.error(message, res.getErrorDetails());
throw new BadRequestException(message + res.getErrorDetails(), res.getErrorDetails());
}
if (CredentialStatus.FAILED.equals(res.getCloudCredentialStatus().getStatus())) {
throw new BadRequestException(message + res.getCloudCredentialStatus().getStatusReason(), res.getCloudCredentialStatus().getException());
}
CloudCredential cloudCredentialResponse = res.getCloudCredentialStatus().getCloudCredential();
mergeSmartSenseAttributeIfExists(credential, cloudCredentialResponse);
} catch (InterruptedException e) {
LOGGER.error("Error while executing credential verification", e);
throw new OperationException(e);
}
return credential;
}
Aggregations