@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getInstanceId() == null) ? 0 : getInstanceId().hashCode()); hashCode = prime * hashCode + ((getLatest() == null) ? 0 : getLatest().hashCode()); return hashCode; }
/** * Constructs a new GetConsoleOutputRequest object. Callers should use the setter or fluent setter (with...) methods * to initialize any additional object members. * * @param instanceId * The ID of the instance. */ public GetConsoleOutputRequest(String instanceId) { setInstanceId(instanceId); }
/** * <p> * When enabled, retrieves the latest console output for the instance. * </p> * <p> * Default: disabled (<code>false</code>) * </p> * * @param latest * When enabled, retrieves the latest console output for the instance.</p> * <p> * Default: disabled (<code>false</code>) * @return Returns a reference to this object so that method calls can be chained together. */ public GetConsoleOutputRequest withLatest(Boolean latest) { setLatest(latest); return this; }
@Override public GetConsoleOutputResult consoleOutput( ResultCapture<GetConsoleOutputResult> extractor) { GetConsoleOutputRequest request = new GetConsoleOutputRequest(); return consoleOutput(request, extractor); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetConsoleOutputRequest == false) return false; GetConsoleOutputRequest other = (GetConsoleOutputRequest)obj; if (other.getInstanceId() == null ^ this.getInstanceId() == null) return false; if (other.getInstanceId() != null && other.getInstanceId().equals(this.getInstanceId()) == false) return false; return true; }
@Override public GetConsoleOutputResult consoleOutput( ResultCapture<GetConsoleOutputResult> extractor) { GetConsoleOutputRequest request = new GetConsoleOutputRequest(); return consoleOutput(request, extractor); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getInstanceId() == null) ? 0 : getInstanceId().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetConsoleOutputRequest == false) return false; GetConsoleOutputRequest other = (GetConsoleOutputRequest) obj; if (other.getInstanceId() == null ^ this.getInstanceId() == null) return false; if (other.getInstanceId() != null && other.getInstanceId().equals(this.getInstanceId()) == false) return false; if (other.getLatest() == null ^ this.getLatest() == null) return false; if (other.getLatest() != null && other.getLatest().equals(this.getLatest()) == false) return false; return true; }
/** * Gets the EC2 console output. */ public String getConsoleOutput() throws AmazonClientException { AmazonEC2 ec2 = getCloud().connect(); GetConsoleOutputRequest request = new GetConsoleOutputRequest(getInstanceId()); return ec2.getConsoleOutput(request).getOutput(); }
/** * <p> * The ID of the instance. * </p> * * @param instanceId * The ID of the instance. * @return Returns a reference to this object so that method calls can be chained together. */ public GetConsoleOutputRequest withInstanceId(String instanceId) { setInstanceId(instanceId); return this; }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getInstanceId() != null) sb.append("InstanceId: " + getInstanceId() ); sb.append("}"); return sb.toString(); }
/** * <p> * When enabled, retrieves the latest console output for the instance. * </p> * <p> * Default: disabled (<code>false</code>) * </p> * * @param latest * When enabled, retrieves the latest console output for the instance.</p> * <p> * Default: disabled (<code>false</code>) * @return Returns a reference to this object so that method calls can be chained together. */ public GetConsoleOutputRequest withLatest(Boolean latest) { setLatest(latest); return this; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getInstanceId() != null) sb.append("InstanceId: ").append(getInstanceId()).append(","); if (getLatest() != null) sb.append("Latest: ").append(getLatest()); sb.append("}"); return sb.toString(); }
/** * Gets the EC2 console output. */ public String getConsoleOutput() throws AmazonClientException { AmazonEC2 ec2 = getCloud().connect(); GetConsoleOutputRequest request = new GetConsoleOutputRequest(getInstanceId()); return ec2.getConsoleOutput(request).getOutput(); }
/** * Constructs a new GetConsoleOutputRequest object. * Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param instanceId The ID of the instance. */ public GetConsoleOutputRequest(String instanceId) { setInstanceId(instanceId); }
public Request<GetConsoleOutputRequest> marshall(GetConsoleOutputRequest getConsoleOutputRequest) { if (getConsoleOutputRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<GetConsoleOutputRequest> request = new DefaultRequest<GetConsoleOutputRequest>(getConsoleOutputRequest, "AmazonEC2"); request.addParameter("Action", "GetConsoleOutput"); request.addParameter("Version", "2015-10-01"); if (getConsoleOutputRequest.getInstanceId() != null) { request.addParameter("InstanceId", StringUtils.fromString(getConsoleOutputRequest.getInstanceId())); } return request; } }
public Request<GetConsoleOutputRequest> marshall(GetConsoleOutputRequest getConsoleOutputRequest) { if (getConsoleOutputRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<GetConsoleOutputRequest> request = new DefaultRequest<GetConsoleOutputRequest>(getConsoleOutputRequest, "AmazonEC2"); request.addParameter("Action", "GetConsoleOutput"); request.addParameter("Version", "2016-11-15"); request.setHttpMethod(HttpMethodName.POST); if (getConsoleOutputRequest.getInstanceId() != null) { request.addParameter("InstanceId", StringUtils.fromString(getConsoleOutputRequest.getInstanceId())); } if (getConsoleOutputRequest.getLatest() != null) { request.addParameter("Latest", StringUtils.fromBoolean(getConsoleOutputRequest.getLatest())); } return request; }
public static void logEC2InstanceOutputToCloudwatch(String t, ECSConfiguration configuration) { AwsLogs.Driver driver = AwsLogs.getAwsLogsDriver(configuration); if (driver != null && driver.getRegion() != null && driver.getLogGroupName() != null) { try { AmazonEC2 client = AmazonEC2ClientBuilder.defaultClient(); GetConsoleOutputResult result = client.getConsoleOutput(new GetConsoleOutputRequest(t)); AWSLogsClient logs = new AWSLogsClient().withRegion(Regions.fromName(driver.getRegion())); // t (ec2 instance id) should be unique within reason final String logStreamName = "pbc-ec2-instance-stale/" + t; logs.createLogStream(new CreateLogStreamRequest(driver.getLogGroupName(), logStreamName)); logs.putLogEvents(new PutLogEventsRequest().withLogGroupName(driver.getLogGroupName()).withLogStreamName(logStreamName).withLogEvents(new InputLogEvent().withMessage(result.getDecodedOutput()).withTimestamp(System.currentTimeMillis()))); } catch (Exception th) { //we are fine swallowing any errors, has no direct influence on proper function. logger.error("failed to retrieve ec2 instance logs or send them to cloudwatch", th); } } }
/** * Constructs a new GetConsoleOutputRequest object. Callers should use the setter or fluent setter (with...) methods * to initialize any additional object members. * * @param instanceId * The ID of the instance. */ public GetConsoleOutputRequest(String instanceId) { setInstanceId(instanceId); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getInstanceId() == null) ? 0 : getInstanceId().hashCode()); hashCode = prime * hashCode + ((getLatest() == null) ? 0 : getLatest().hashCode()); return hashCode; }