blob: a24b3b614354895885b180d2c90cf8efa1ce4267 [file] [log] [blame]
Jakub Josef4cb727e2017-04-19 16:44:47 +02001/**
2 *
3 * Delete broken heat stacks pipeline (in CREATE_FAILED or DELETE_FAILED state)
4 *
5 * Expected parameters:
6 * OPENSTACK_API_URL OpenStack API address
7 * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API
8 * OPENSTACK_API_PROJECT OpenStack project to connect to
9 * OPENSTACK_API_CLIENT Versions of OpenStack python clients
10 * OPENSTACK_API_VERSION Version of the OpenStack API (2/3)
11 *
12 *
13 */
14
15git = new com.mirantis.mk.Git()
16openstack = new com.mirantis.mk.Openstack()
17salt = new com.mirantis.mk.Salt()
18
19node {
20
21 // connection objects
22 def openstackCloud
23 // value defaults
24 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
25 def openstackEnv = "${env.WORKSPACE}/venv"
26
27 stage('Install OpenStack env') {
28 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
29 }
30
31 stage('Connect to OpenStack cloud') {
32 openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
33 openstack.getKeystoneToken(openstackCloud, openstackEnv)
34 }
35
36 stage('Delete broken Heat stacks') {
37 // get failed stacks
38 def brokenStacks = []
39 brokenStacks.addAll(openstack.getStacksWithStatus(openstackCloud, "CREATE_FAILED", openstackEnv))
40 brokenStacks.addAll(openstack.getStacksWithStatus(openstackCloud, "DELETE_FAILED", openstackEnv))
41 for(int i=0;i<brokenStacks.size();i++){
42 openstack.deleteHeatStack(openstackCloud, brokenStacks[i], openstackEnv)
43 }
44 }
45
46}