Example usage for com.amazonaws.services.cloudformation.model StackStatus ROLLBACK_FAILED

List of usage examples for com.amazonaws.services.cloudformation.model StackStatus ROLLBACK_FAILED

Introduction

In this page you can find the example usage for com.amazonaws.services.cloudformation.model StackStatus ROLLBACK_FAILED.

Prototype

StackStatus ROLLBACK_FAILED

To view the source code for com.amazonaws.services.cloudformation.model StackStatus ROLLBACK_FAILED.

Click Source Link

Usage

From source file:CloudFormation.java

License:Open Source License

public static String waitForCompletion(AmazonCloudFormation stackbuilder, String stackName) throws Exception {

    DescribeStacksRequest wait = new DescribeStacksRequest();
    wait.setStackName(stackName);//from w ww  .j  av  a  2s.c o  m
    Boolean completed = false;
    String stackStatus = "Unknown";
    String stackReason = "";

    System.out.print("Waiting");

    while (!completed) {
        List<Stack> stacks = stackbuilder.describeStacks(wait).getStacks();
        if (stacks.isEmpty()) {
            completed = true;
            stackStatus = "NO_SUCH_STACK";
            stackReason = "Stack has been deleted";
        } else {
            for (Stack stack : stacks) {
                if (stack.getStackStatus().equals(StackStatus.CREATE_COMPLETE.toString())
                        || stack.getStackStatus().equals(StackStatus.CREATE_FAILED.toString())
                        || stack.getStackStatus().equals(StackStatus.ROLLBACK_FAILED.toString())
                        || stack.getStackStatus().equals(StackStatus.DELETE_FAILED.toString())) {
                    completed = true;
                    stackStatus = stack.getStackStatus();
                    stackReason = stack.getStackStatusReason();
                }
            }
        }

        // Show we are waiting
        System.out.print(".");

        // Not done yet so sleep for 10 seconds.
        if (!completed)
            Thread.sleep(10000);
    }

    // Show we are done
    System.out.print("done\n");

    return stackStatus + " (" + stackReason + ")";
}

From source file:jetbrains.buildServer.runner.cloudformation.AWSClient.java

License:Apache License

public void waitForCompletion(AmazonCloudFormationClient stackbuilder, String stackName)
        throws InterruptedException {
    DescribeStacksRequest wait = new DescribeStacksRequest();
    wait.setStackName(stackName);// w ww.  j av a2 s. co m
    Boolean completed = false;
    String action = "CREATE";
    String stackStatus = "Waiting";
    String stackReason = "";
    String stackId = "";
    List<String> events;
    int len, first, last;

    first = 0;

    myListener.waitForStack(stackStatus);

    while (!completed) {
        List<Stack> stacks = stackbuilder.describeStacks(wait).getStacks();
        if (stacks.isEmpty()) {
            completed = true;
            stackStatus = "NO_SUCH_STACK";
            stackReason = "Stack has been deleted";
        } else {
            for (Stack stack : stacks) {
                if (stack.getStackStatus().equals(StackStatus.CREATE_COMPLETE.toString())
                        || stack.getStackStatus().equals(StackStatus.CREATE_FAILED.toString())
                        || stack.getStackStatus().equals(StackStatus.ROLLBACK_FAILED.toString())
                        || stack.getStackStatus().equals(StackStatus.DELETE_FAILED.toString())) {
                    completed = true;
                    stackStatus = stack.getStackStatus();
                    if (stack.getStackStatus().equals(StackStatus.CREATE_COMPLETE.toString())) {
                        stackReason = "Success";
                    } else {
                        stackReason = "Failure";
                    }
                    stackId = stack.getStackId();
                }
            }
        }
        //sleep for 10 seconds
        Thread.sleep(10000);
    }

    if (completed) {
        events = describeStackEvents(stackbuilder, stackName, action);
        for (String event : events) {
            myListener.waitForStack(event.toString());
        }
        events.clear();

    }
    myListener.waitForStack(stackStatus);
    if (stackReason.contains("Failure")) {
        myListener.createStackFailed(stackName, stackStatus, stackReason);
    } else {
        myListener.createStackFinished(stackName, stackStatus);
    }
}

From source file:org.springframework.cloud.stream.app.aws.AwsIntegrationTestStackRule.java

License:Apache License

private void waitForCompletion() throws InterruptedException {
    DescribeStacksRequest wait = new DescribeStacksRequest();
    wait.setStackName(this.stackName);
    Boolean completed = false;// w  w  w  .j  a v  a  2  s  .c  o  m
    String stackStatus = "Unknown";
    String stackReason = "";

    while (!completed) {
        List<Stack> stacks = null;
        try {
            stacks = this.cloudFormation.describeStacks(wait).getStacks();
        } catch (Exception e) {
            logger.error("cloudFormation.describeStacks() exception", e);
        }
        if (CollectionUtils.isEmpty(stacks)) {
            completed = true;
            stackStatus = StackStatus.DELETE_COMPLETE.toString();
            stackReason = "Stack has been deleted";
        } else {
            for (Stack stack : stacks) {
                if (stack.getStackStatus().equals(StackStatus.CREATE_COMPLETE.toString())
                        || stack.getStackStatus().equals(StackStatus.CREATE_FAILED.toString())
                        || stack.getStackStatus().equals(StackStatus.ROLLBACK_FAILED.toString())
                        || stack.getStackStatus().equals(StackStatus.DELETE_FAILED.toString())) {
                    completed = true;
                    stackStatus = stack.getStackStatus();
                    stackReason = stack.getStackStatusReason();
                }
            }
        }

        // Not done yet so sleep for 2 seconds.
        if (!completed) {
            Thread.sleep(2000);
        } else {
            if (stackStatus.equals(StackStatus.CREATE_FAILED.toString())) {
                Assume.assumeTrue(
                        "The test AWS stack [" + this.stackName + "] cannot be created. Reason: " + stackReason,
                        true);
            }
        }
    }
}

From source file:org.terracotta.TerracottaCloudFormationSample.java

License:Open Source License

public static String waitForCompletion(AmazonCloudFormation stackbuilder, String stackName) throws Exception {

    DescribeStacksRequest wait = new DescribeStacksRequest();
    wait.setStackName(stackName);/*from www . j a  v a  2s  . co  m*/
    Boolean completed = false;
    String stackStatus = "Unknown";
    String stackReason = "";

    System.out.print("Waiting");

    while (!completed) {
        List<Stack> stacks = stackbuilder.describeStacks(wait).getStacks();
        if (stacks.isEmpty()) {
            completed = true;
            stackStatus = "NO_SUCH_STACK";
            stackReason = "Stack has been deleted";
        } else {
            for (Stack stack : stacks) {
                if (stack.getStackStatus().equals(StackStatus.CREATE_COMPLETE.toString())
                        || stack.getStackStatus().equals(StackStatus.CREATE_FAILED.toString())
                        || stack.getStackStatus().equals(StackStatus.ROLLBACK_FAILED.toString())
                        || stack.getStackStatus().equals(StackStatus.DELETE_FAILED.toString())) {
                    completed = true;
                    stackStatus = stack.getStackStatus();
                    stackReason = stack.getStackStatusReason();
                }
            }
        }

        // Show we are waiting
        System.out.print(".");

        // Not done yet so sleep for 30 seconds.
        if (!completed)
            Thread.sleep(30000);
    }

    // Show we are done
    System.out.print("done\n");

    return stackStatus + " (" + stackReason + ")";
}