@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 { if (getConsoleOutputResult.getOutput() == null) { return ""; } else { return getConsoleOutputResult.getDecodedOutput(); } } catch (Exception ex) { LOGGER.debug(ex.getMessage(), ex); return ""; } }
@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(); }
@Override public GetConsoleOutputResult consoleOutput( ResultCapture<GetConsoleOutputResult> extractor) { GetConsoleOutputRequest request = new GetConsoleOutputRequest(); return consoleOutput(request, extractor); }
@Override public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) throws IOException { Machine machine = (Machine) execution.getVariable("machine"); checkNotNull(machine, "expecting 'machine' as a process variable"); LOG.info(">> Requesting console output for instance {}", machine.getExternalId()); GetConsoleOutputResult result = client.getConsoleOutput( new GetConsoleOutputRequest().withInstanceId(machine.getExternalId())); if (result.getOutput() != null) { String content = new String(Base64.decode(result.getOutput()), Charsets.UTF_8); LOG.info("<< Console output for instance {}: {}", machine.getExternalId(), content); } else { LOG.warn("<< Console output was null for instance {}", machine.getExternalId()); } }
@Override public GetConsoleOutputResult getConsoleOutput(GetConsoleOutputRequest getConsoleOutputRequest) throws AmazonServiceException, AmazonClientException { throw new UnsupportedOperationException("Not supported in mock"); }
/** * Gets the EC2 console output. */ public String getConsoleOutput() throws AmazonClientException { AmazonEC2 ec2 = getCloud().connect(); GetConsoleOutputRequest request = new GetConsoleOutputRequest(getInstanceId()); return ec2.getConsoleOutput(request).getOutput(); }
@Override public GetConsoleOutputResult consoleOutput(GetConsoleOutputRequest request) { return consoleOutput(request, null); }
/** * 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);
/** * 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);