com.amazonaws.services.ec2.model.GetConsoleOutputRequest Java Examples
The following examples show how to use
com.amazonaws.services.ec2.model.GetConsoleOutputRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AWSProvider.java From testgrid with Apache License 2.0 | 6 votes |
/** * * Logs are retrieved via aws api that looks similar to this cli command: * aws ec2 get-console-output --instance-id i-123456789abcd --output text * * This won't contain the entire ec2 instance console (system) log. * It'll be truncated to last {@link #EC2_SYSTEM_LOG_NO_OF_LINES} lines. * * @param instance the ec2 instance object * @param amazonEC2 AmazonEC2 command handler * @return return string will be of following format: * <pre> * ${ec2-nickname} logs { * <br/> * ${truncated-logs} * <br/> * } * </pre> */ private String getEC2InstanceConsoleLogs(Instance instance, AmazonEC2 amazonEC2) { String decodedOutput; String instanceName = instance.getTags().stream() .filter(t -> t.getKey().equals("Name")) .map(com.amazonaws.services.ec2.model.Tag::getValue) .findAny().orElse("<name-empty>"); try { GetConsoleOutputRequest consoleOutputRequest = new GetConsoleOutputRequest(instance.getInstanceId()); final GetConsoleOutputResult consoleOutputResult = amazonEC2.getConsoleOutput(consoleOutputRequest); decodedOutput = consoleOutputResult.getDecodedOutput(); decodedOutput = reduceLogVerbosity(decodedOutput); } catch (NullPointerException e) { String error = e.getMessage() + (e.getStackTrace().length > 0 ? "at " + e.getStackTrace()[0].toString() : ""); decodedOutput = "Error occurred while retrieving instance console logs for " + instance.getInstanceId() + ". Error: " + error; } return instanceName + " logs {\n" + decodedOutput + "\n" + "}\n"; }
Example #2
Source File: InstanceImpl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@Override public GetConsoleOutputResult consoleOutput(GetConsoleOutputRequest request, ResultCapture<GetConsoleOutputResult> extractor) { ActionResult result = resource.performAction("ConsoleOutput", request, extractor); if (result == null) return null; return (GetConsoleOutputResult) result.getData(); }
Example #3
Source File: InstanceImpl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@Override public GetConsoleOutputResult consoleOutput( ResultCapture<GetConsoleOutputResult> extractor) { GetConsoleOutputRequest request = new GetConsoleOutputRequest(); return consoleOutput(request, extractor); }
Example #4
Source File: AwsInstanceConnector.java From cloudbreak with Apache License 2.0 | 5 votes |
@Override public String getConsoleOutput(AuthenticatedContext authenticatedContext, CloudInstance vm) { if (!verifyHostKey) { throw new CloudOperationNotSupportedException("Host key verification is disabled on AWS"); } AmazonEC2Client amazonEC2Client = new AuthenticatedContextView(authenticatedContext).getAmazonEC2Client(); GetConsoleOutputRequest getConsoleOutputRequest = new GetConsoleOutputRequest().withInstanceId(vm.getInstanceId()); GetConsoleOutputResult getConsoleOutputResult = amazonEC2Client.getConsoleOutput(getConsoleOutputRequest); try { return getConsoleOutputResult.getOutput() == null ? "" : getConsoleOutputResult.getDecodedOutput(); } catch (Exception ex) { LOGGER.warn(ex.getMessage(), ex); return ""; } }
Example #5
Source File: InstanceImpl.java From aws-sdk-java-resources with Apache License 2.0 | 4 votes |
@Override public GetConsoleOutputResult consoleOutput(GetConsoleOutputRequest request) { return consoleOutput(request, null); }
Example #6
Source File: Instance.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * Performs the <code>ConsoleOutput</code> action. * * <p> * The following request parameters will be populated from the data of this * <code>Instance</code> resource, and any conflicting parameter value set * in the request will be overridden: * <ul> * <li> * <b><code>InstanceId</code></b> * - mapped from the <code>Id</code> identifier. * </li> * </ul> * * <p> * * @return The response of the low-level client operation associated with * this resource action. * @see GetConsoleOutputRequest */ GetConsoleOutputResult consoleOutput(GetConsoleOutputRequest request);
Example #7
Source File: Instance.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * Performs the <code>ConsoleOutput</code> action and use a ResultCapture to * retrieve the low-level client response. * * <p> * The following request parameters will be populated from the data of this * <code>Instance</code> resource, and any conflicting parameter value set * in the request will be overridden: * <ul> * <li> * <b><code>InstanceId</code></b> * - mapped from the <code>Id</code> identifier. * </li> * </ul> * * <p> * * @return The response of the low-level client operation associated with * this resource action. * @see GetConsoleOutputRequest */ GetConsoleOutputResult consoleOutput(GetConsoleOutputRequest request, ResultCapture<GetConsoleOutputResult> extractor);