Implemented broken stacks delete pipeline
Change-Id: I316e27765813395bac1fab5844ae594f96faca7d
diff --git a/cleanup-pipeline.groovy b/cleanup-pipeline.groovy
index 2a59bf6..e57e704 100644
--- a/cleanup-pipeline.groovy
+++ b/cleanup-pipeline.groovy
@@ -1,6 +1,6 @@
/**
*
- * Launch heat stack with basic k8s
+ * Delete heat stack pipeline
*
* Expected parameters:
* OPENSTACK_API_URL OpenStack API address
@@ -20,7 +20,6 @@
// connection objects
def openstackCloud
- def saltMaster
// value defaults
def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
diff --git a/delete-broken-stacks-pipeline.groovy b/delete-broken-stacks-pipeline.groovy
new file mode 100644
index 0000000..a24b3b6
--- /dev/null
+++ b/delete-broken-stacks-pipeline.groovy
@@ -0,0 +1,46 @@
+/**
+ *
+ * Delete broken heat stacks pipeline (in CREATE_FAILED or DELETE_FAILED state)
+ *
+ * Expected parameters:
+ * OPENSTACK_API_URL OpenStack API address
+ * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API
+ * OPENSTACK_API_PROJECT OpenStack project to connect to
+ * OPENSTACK_API_CLIENT Versions of OpenStack python clients
+ * OPENSTACK_API_VERSION Version of the OpenStack API (2/3)
+ *
+ *
+ */
+
+git = new com.mirantis.mk.Git()
+openstack = new com.mirantis.mk.Openstack()
+salt = new com.mirantis.mk.Salt()
+
+node {
+
+ // connection objects
+ def openstackCloud
+ // value defaults
+ def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
+ def openstackEnv = "${env.WORKSPACE}/venv"
+
+ stage('Install OpenStack env') {
+ openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
+ }
+
+ stage('Connect to OpenStack cloud') {
+ openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
+ openstack.getKeystoneToken(openstackCloud, openstackEnv)
+ }
+
+ stage('Delete broken Heat stacks') {
+ // get failed stacks
+ def brokenStacks = []
+ brokenStacks.addAll(openstack.getStacksWithStatus(openstackCloud, "CREATE_FAILED", openstackEnv))
+ brokenStacks.addAll(openstack.getStacksWithStatus(openstackCloud, "DELETE_FAILED", openstackEnv))
+ for(int i=0;i<brokenStacks.size();i++){
+ openstack.deleteHeatStack(openstackCloud, brokenStacks[i], openstackEnv)
+ }
+ }
+
+}