List of usage examples for com.amazonaws.services.ec2.model DryRunResult isSuccessful
boolean isSuccessful
To view the source code for com.amazonaws.services.ec2.model DryRunResult isSuccessful.
Click Source Link
From source file:aws.example.ec2.MonitorInstance.java
License:Open Source License
public static void monitorInstance(String instance_id) { final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); DryRunSupportedRequest<MonitorInstancesRequest> dry_request = () -> { MonitorInstancesRequest request = new MonitorInstancesRequest().withInstanceIds(instance_id); return request.getDryRunRequest(); };//from www . j a va 2 s .com DryRunResult dry_response = ec2.dryRun(dry_request); if (!dry_response.isSuccessful()) { System.out.printf("Failed dry run to enable monitoring on instance %s", instance_id); throw dry_response.getDryRunResponse(); } MonitorInstancesRequest request = new MonitorInstancesRequest().withInstanceIds(instance_id); ec2.monitorInstances(request); System.out.printf("Successfully enabled monitoring for instance %s", instance_id); }
From source file:aws.example.ec2.MonitorInstance.java
License:Open Source License
public static void unmonitorInstance(String instance_id) { final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); DryRunSupportedRequest<UnmonitorInstancesRequest> dry_request = () -> { UnmonitorInstancesRequest request = new UnmonitorInstancesRequest().withInstanceIds(instance_id); return request.getDryRunRequest(); };//from ww w . j a v a 2s .c om DryRunResult dry_response = ec2.dryRun(dry_request); if (!dry_response.isSuccessful()) { System.out.printf("Failed dry run to disable monitoring on instance %s", instance_id); throw dry_response.getDryRunResponse(); } UnmonitorInstancesRequest request = new UnmonitorInstancesRequest().withInstanceIds(instance_id); ec2.unmonitorInstances(request); System.out.printf("Successfully disabled monitoring for instance %s", instance_id); }
From source file:aws.example.ec2.StartStopInstance.java
License:Open Source License
public static void startInstance(String instance_id) { final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); DryRunSupportedRequest<StartInstancesRequest> dry_request = () -> { StartInstancesRequest request = new StartInstancesRequest().withInstanceIds(instance_id); return request.getDryRunRequest(); };//from w w w. j a v a 2 s . com DryRunResult dry_response = ec2.dryRun(dry_request); if (!dry_response.isSuccessful()) { System.out.printf("Failed dry run to start instance %s", instance_id); throw dry_response.getDryRunResponse(); } StartInstancesRequest request = new StartInstancesRequest().withInstanceIds(instance_id); ec2.startInstances(request); System.out.printf("Successfully started instance %s", instance_id); }
From source file:aws.example.ec2.StartStopInstance.java
License:Open Source License
public static void stopInstance(String instance_id) { final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); DryRunSupportedRequest<StopInstancesRequest> dry_request = () -> { StopInstancesRequest request = new StopInstancesRequest().withInstanceIds(instance_id); return request.getDryRunRequest(); };// w ww.j av a 2 s . c om DryRunResult dry_response = ec2.dryRun(dry_request); if (!dry_response.isSuccessful()) { System.out.printf("Failed dry run to stop instance %s", instance_id); throw dry_response.getDryRunResponse(); } StopInstancesRequest request = new StopInstancesRequest().withInstanceIds(instance_id); ec2.stopInstances(request); System.out.printf("Successfully stop instance %s", instance_id); }
From source file:de.unibi.cebitec.bibigrid.meta.aws.ValidateIntentAWS.java
@Override public boolean validate() { log.info("Validating config file..."); /*/*from www . j av a 2 s . c om*/ * Access Key Check */ ec2 = new AmazonEC2Client(conf.getCredentials()); ec2.setEndpoint("ec2." + conf.getRegion() + ".amazonaws.com"); boolean success = true; try { DryRunSupportedRequest<CreateTagsRequest> tryKeys = new DryRunSupportedRequest<CreateTagsRequest>() { @Override public Request<CreateTagsRequest> getDryRunRequest() { return new CreateTagsRequest().getDryRunRequest(); } }; DryRunResult dryRunResult = ec2.dryRun(tryKeys); if (dryRunResult.isSuccessful()) { log.info(I, "Access Key Test successful."); } else { log.error("AccessKey test not successful. Please check your configuration."); return false; } } catch (AmazonClientException e) { log.error("The access or secret key does not seem to valid."); return false; } sleep(1); if (checkImages()) { log.info(I, "Image check has been successful."); } else { success = false; log.error("There were one or more errors during the last step."); } sleep(1); if (checkSnapshots()) { log.info(I, "Snapshot check has been successful."); } else { success = false; log.error("One or more snapshots could not be found."); } sleep(1); if (success) { log.info(I, "You can now start your cluster."); } else { log.error("There were one or more errors. Please adjust your configuration."); } return true; }
From source file:ec2.MonitorInstance.java
License:Open Source License
public static void monitorInstance(String instanceId) { final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); DryRunSupportedRequest<MonitorInstancesRequest> monitorInstancesDryRun = () -> { MonitorInstancesRequest request = new MonitorInstancesRequest().withInstanceIds(instanceId); return request.getDryRunRequest(); };//from w w w . j av a 2 s . c o m DryRunResult dryRunResponse = ec2.dryRun(monitorInstancesDryRun); if (!dryRunResponse.isSuccessful()) { System.out.printf("Failed dry run to enable monitoring on instance %s", instanceId); throw dryRunResponse.getDryRunResponse(); } MonitorInstancesRequest request = new MonitorInstancesRequest().withInstanceIds(instanceId); ec2.monitorInstances(request); System.out.printf("Successfully enabled monitoring for instance %s", instanceId); }
From source file:ec2.MonitorInstance.java
License:Open Source License
public static void unmonitorInstance(String instanceId) { final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); DryRunSupportedRequest<UnmonitorInstancesRequest> unmonitorInstancesDryRun = () -> { UnmonitorInstancesRequest request = new UnmonitorInstancesRequest().withInstanceIds(instanceId); return request.getDryRunRequest(); };/*from ww w. j a v a2s . com*/ DryRunResult dryRunResponse = ec2.dryRun(unmonitorInstancesDryRun); if (!dryRunResponse.isSuccessful()) { System.out.printf("Failed dry run to disable monitoring on instance %s", instanceId); throw dryRunResponse.getDryRunResponse(); } UnmonitorInstancesRequest request = new UnmonitorInstancesRequest().withInstanceIds(instanceId); ec2.unmonitorInstances(request); System.out.printf("Successfully disabled monitoring for instance %s", instanceId); }
From source file:ec2.StartStopInstance.java
License:Open Source License
public static void startInstance(String instanceId) { final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); DryRunSupportedRequest<StartInstancesRequest> startInstanceDryRun = () -> { StartInstancesRequest request = new StartInstancesRequest().withInstanceIds(instanceId); return request.getDryRunRequest(); };//from ww w . j a va 2 s. com DryRunResult dryRunResponse = ec2.dryRun(startInstanceDryRun); if (!dryRunResponse.isSuccessful()) { System.out.printf("Failed dry run to start instance %s", instanceId); throw dryRunResponse.getDryRunResponse(); } StartInstancesRequest request = new StartInstancesRequest().withInstanceIds(instanceId); ec2.startInstances(request); System.out.printf("Successfully started instance %s", instanceId); }
From source file:ec2.StartStopInstance.java
License:Open Source License
public static void stopInstance(String instanceId) { final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); DryRunSupportedRequest<StopInstancesRequest> stopInstanceDryRun = () -> { StopInstancesRequest request = new StopInstancesRequest().withInstanceIds(instanceId); return request.getDryRunRequest(); };//from w w w .j a v a2 s . c om DryRunResult dryRunResponse = ec2.dryRun(stopInstanceDryRun); if (!dryRunResponse.isSuccessful()) { System.out.printf("Failed dry run to stop instance %s", instanceId); throw dryRunResponse.getDryRunResponse(); } StopInstancesRequest request = new StopInstancesRequest().withInstanceIds(instanceId); ec2.stopInstances(request); System.out.printf("Successfully stop instance %s", instanceId); }
From source file:org.xmlsh.aws.util.AWSEC2Command.java
License:BSD License
protected <X extends AmazonWebServiceRequest> int dryRun(DryRunSupportedRequest<X> request) throws XMLStreamException, InvalidArgumentException, SaxonApiException, CoreException, IOException { DryRunResult<X> result; try {/* w w w .ja v a 2 s . c o m*/ result = this.getAWSClient().dryRun(request); } catch (AmazonServiceException e) { if (e.isRetryable()) throw e; return super.handleException(e); } catch (AmazonClientException e) { if (e.getCause() instanceof AmazonServiceException) return super.handleException((AmazonServiceException) e.getCause()); return super.handleException(e); } startResult(); startElement("dry-run"); attribute("success", result.isSuccessful()); if (!result.isSuccessful()) textElement("message", result.getMessage()); endElement(); endResult(); return 0; }