Search in sources :

Example 1 with GetConsoleOutputResult

use of com.amazonaws.services.ec2.model.GetConsoleOutputResult in project cloudbreak by hortonworks.

the class AwsInstanceConnector method getConsoleOutput.

@Override
public String getConsoleOutput(AuthenticatedContext authenticatedContext, CloudInstance vm) {
    if (!verifyHostKey) {
        throw new CloudOperationNotSupportedException("Host key verification is disabled on AWS");
    }
    AmazonEC2Client amazonEC2Client = awsClient.createAccess(new AwsCredentialView(authenticatedContext.getCloudCredential()), authenticatedContext.getCloudContext().getLocation().getRegion().value());
    GetConsoleOutputRequest getConsoleOutputRequest = new GetConsoleOutputRequest().withInstanceId(vm.getInstanceId());
    GetConsoleOutputResult getConsoleOutputResult = amazonEC2Client.getConsoleOutput(getConsoleOutputRequest);
    try {
        return getConsoleOutputResult.getOutput() == null ? "" : getConsoleOutputResult.getDecodedOutput();
    } catch (Exception ex) {
        LOGGER.debug(ex.getMessage(), ex);
        return "";
    }
}
Also used : AmazonEC2Client(com.amazonaws.services.ec2.AmazonEC2Client) AwsCredentialView(com.sequenceiq.cloudbreak.cloud.aws.view.AwsCredentialView) CloudOperationNotSupportedException(com.sequenceiq.cloudbreak.cloud.exception.CloudOperationNotSupportedException) GetConsoleOutputResult(com.amazonaws.services.ec2.model.GetConsoleOutputResult) GetConsoleOutputRequest(com.amazonaws.services.ec2.model.GetConsoleOutputRequest) AmazonEC2Exception(com.amazonaws.services.ec2.model.AmazonEC2Exception) CloudOperationNotSupportedException(com.sequenceiq.cloudbreak.cloud.exception.CloudOperationNotSupportedException)

Aggregations

AmazonEC2Client (com.amazonaws.services.ec2.AmazonEC2Client)1 AmazonEC2Exception (com.amazonaws.services.ec2.model.AmazonEC2Exception)1 GetConsoleOutputRequest (com.amazonaws.services.ec2.model.GetConsoleOutputRequest)1 GetConsoleOutputResult (com.amazonaws.services.ec2.model.GetConsoleOutputResult)1 AwsCredentialView (com.sequenceiq.cloudbreak.cloud.aws.view.AwsCredentialView)1 CloudOperationNotSupportedException (com.sequenceiq.cloudbreak.cloud.exception.CloudOperationNotSupportedException)1