Example usage for com.amazonaws.services.ec2.model DryRunSupportedRequest DryRunSupportedRequest

List of usage examples for com.amazonaws.services.ec2.model DryRunSupportedRequest DryRunSupportedRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model DryRunSupportedRequest DryRunSupportedRequest.

Prototype

DryRunSupportedRequest

Source Link

Usage

From source file:de.unibi.cebitec.bibigrid.meta.aws.ValidateIntentAWS.java

@Override
public boolean validate() {
    log.info("Validating config file...");
    /*/* ww w.  j  av a 2 s.c  o  m*/
     * 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;
}