Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 1 | /** |
| 2 | * |
Tomáš Kukrál | 0d00dd2 | 2017-07-27 14:28:36 +0200 | [diff] [blame] | 3 | * Launch stack and work with it |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 4 | * |
| 5 | * Expected parameters: |
| 6 | * STACK_NAME Infrastructure stack name |
Tomáš Kukrál | 4691f68 | 2017-07-27 16:36:12 +0200 | [diff] [blame] | 7 | * STACK_TEMPLATE File with stack template |
| 8 | * STACK_TYPE Deploy OpenStack/AWS [heat/aws], use 'physical' if no stack should be started |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 9 | * |
| 10 | * STACK_TEMPLATE_URL URL to git repo with stack templates |
| 11 | * STACK_TEMPLATE_CREDENTIALS Credentials to the templates repo |
| 12 | * STACK_TEMPLATE_BRANCH Stack templates repo branch |
| 13 | * |
| 14 | * STACK_DELETE Delete stack when finished (bool) |
Tomáš Kukrál | 4691f68 | 2017-07-27 16:36:12 +0200 | [diff] [blame] | 15 | * STACK_REUSE Reuse existing stack (don't create one, only read outputs) |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 16 | * STACK_INSTALL What should be installed (k8s, openstack, ...) |
| 17 | * STACK_TEST Run tests (bool) |
| 18 | * STACK_CLEANUP_JOB Name of job for deleting stack |
| 19 | * |
Tomáš Kukrál | 74f9286 | 2017-06-05 19:18:43 +0200 | [diff] [blame] | 20 | * STACK_COMPUTE_COUNT Number of compute nodes to launch |
| 21 | * |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 22 | * AWS_STACK_REGION CloudFormation AWS region |
| 23 | * AWS_API_CREDENTIALS AWS Access key ID with AWS secret access key |
Tomáš Kukrál | 7a8a4fa | 2017-05-25 14:54:24 +0200 | [diff] [blame] | 24 | * AWS_SSH_KEY AWS key pair name (used for SSH access) |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 25 | * |
| 26 | * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters |
| 27 | * HEAT_STACK_ZONE Heat stack availability zone |
| 28 | * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool |
| 29 | * OPENSTACK_API_URL OpenStack API address |
| 30 | * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API |
| 31 | * OPENSTACK_API_PROJECT OpenStack project to connect to |
| 32 | * OPENSTACK_API_CLIENT Versions of OpenStack python clients |
| 33 | * OPENSTACK_API_VERSION Version of the OpenStack API (2/3) |
Oleh Hryhorov | 9630a76 | 2017-10-24 14:33:25 +0300 | [diff] [blame] | 34 | * SLAVE_NODE Lable or node name where the job will be run |
Tomáš Kukrál | 5c2ec13 | 2017-07-26 09:57:27 +0200 | [diff] [blame] | 35 | |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 36 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API |
Tomáš Kukrál | 4691f68 | 2017-07-27 16:36:12 +0200 | [diff] [blame] | 37 | * required for STACK_TYPE=physical |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 38 | * SALT_MASTER_URL URL of Salt master |
Tomáš Kukrál | 5c2ec13 | 2017-07-26 09:57:27 +0200 | [diff] [blame] | 39 | |
| 40 | * Test settings: |
| 41 | * TEST_K8S_API_SERVER Kubernetes API address |
| 42 | * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 43 | * |
Tomáš Kukrál | 5c2ec13 | 2017-07-26 09:57:27 +0200 | [diff] [blame] | 44 | * TEST_DOCKER_INSTALL Install docker on the target if true |
| 45 | * TEST_TEMPEST_IMAGE Tempest image link |
| 46 | * TEST_TEMPEST_PATTERN If not false, run tests matched to pattern only |
| 47 | * TEST_TEMPEST_TARGET Salt target for tempest node |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 48 | * |
Tomáš Kukrál | 5c2ec13 | 2017-07-26 09:57:27 +0200 | [diff] [blame] | 49 | * optional parameters for overwriting soft params |
| 50 | * SALT_OVERRIDES YAML with overrides for Salt deployment |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 51 | * |
| 52 | */ |
Tomáš Kukrál | 3a17dd6 | 2017-07-27 18:24:16 +0200 | [diff] [blame] | 53 | |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 54 | common = new com.mirantis.mk.Common() |
| 55 | git = new com.mirantis.mk.Git() |
| 56 | openstack = new com.mirantis.mk.Openstack() |
Tomáš Kukrál | 7a8a4fa | 2017-05-25 14:54:24 +0200 | [diff] [blame] | 57 | aws = new com.mirantis.mk.Aws() |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 58 | orchestrate = new com.mirantis.mk.Orchestrate() |
Mykyta Karpin | e016d7e | 2017-10-09 13:35:20 +0300 | [diff] [blame] | 59 | python = new com.mirantis.mk.Python() |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 60 | salt = new com.mirantis.mk.Salt() |
| 61 | test = new com.mirantis.mk.Test() |
| 62 | |
| 63 | _MAX_PERMITTED_STACKS = 2 |
| 64 | overwriteFile = "/srv/salt/reclass/classes/cluster/override.yml" |
| 65 | |
Tomáš Kukrál | a1d86b8 | 2017-07-10 17:24:01 +0200 | [diff] [blame] | 66 | // Define global variables |
Tomáš Kukrál | a1d86b8 | 2017-07-10 17:24:01 +0200 | [diff] [blame] | 67 | def venv |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 68 | def venvPepper |
Tomáš Kukrál | 8e50d8e | 2017-09-01 17:40:53 +0200 | [diff] [blame] | 69 | def outputs = [:] |
Tomáš Kukrál | bc4be25 | 2017-06-06 11:28:40 +0200 | [diff] [blame] | 70 | |
chnyda | e14058a | 2017-08-29 15:07:48 +0200 | [diff] [blame] | 71 | def ipRegex = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}" |
| 72 | |
Tomáš Kukrál | b19bdda | 2017-06-13 17:09:43 +0200 | [diff] [blame] | 73 | if (STACK_TYPE == 'aws') { |
Tomáš Kukrál | a1d86b8 | 2017-07-10 17:24:01 +0200 | [diff] [blame] | 74 | def aws_env_vars |
Tomáš Kukrál | 8427ff5 | 2017-08-30 15:46:52 +0200 | [diff] [blame] | 75 | } else if (STACK_TYPE == 'heat') { |
| 76 | def envParams |
| 77 | def openstackCloud |
Tomáš Kukrál | b19bdda | 2017-06-13 17:09:43 +0200 | [diff] [blame] | 78 | } |
| 79 | |
Oleh Hryhorov | 9630a76 | 2017-10-24 14:33:25 +0300 | [diff] [blame] | 80 | def slave_node = 'python' |
| 81 | |
Oleh Hryhorov | 5446051 | 2017-10-26 18:45:36 +0300 | [diff] [blame] | 82 | if (common.validInputParam('SLAVE_NODE')) { |
Oleh Hryhorov | 9630a76 | 2017-10-24 14:33:25 +0300 | [diff] [blame] | 83 | slave_node = SLAVE_NODE |
| 84 | } |
| 85 | |
| 86 | node(slave_node) { |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 87 | try { |
| 88 | // Set build-specific variables |
| 89 | venv = "${env.WORKSPACE}/venv" |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 90 | venvPepper = "${env.WORKSPACE}/venvPepper" |
Tomáš Kukrál | a1d86b8 | 2017-07-10 17:24:01 +0200 | [diff] [blame] | 91 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 92 | // |
| 93 | // Prepare machines |
| 94 | // |
| 95 | stage ('Create infrastructure') { |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 96 | |
Tomáš Kukrál | 8e50d8e | 2017-09-01 17:40:53 +0200 | [diff] [blame] | 97 | outputs.put('stack_type', STACK_TYPE) |
| 98 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 99 | if (STACK_TYPE == 'heat') { |
| 100 | // value defaults |
Tomáš Kukrál | 8427ff5 | 2017-08-30 15:46:52 +0200 | [diff] [blame] | 101 | envParams = [ |
| 102 | 'cluster_zone': HEAT_STACK_ZONE, |
| 103 | 'cluster_public_net': HEAT_STACK_PUBLIC_NET |
| 104 | ] |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 105 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 106 | if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') { |
| 107 | error("If you want to reuse existing stack you need to provide it's name") |
| 108 | } |
| 109 | |
| 110 | if (STACK_REUSE.toBoolean() == false) { |
| 111 | // Don't allow to set custom heat stack name |
| 112 | wrap([$class: 'BuildUser']) { |
| 113 | if (env.BUILD_USER_ID) { |
| 114 | STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}" |
| 115 | } else { |
| 116 | STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}" |
| 117 | } |
| 118 | currentBuild.description = STACK_NAME |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 119 | } |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 120 | } |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 121 | |
Tomáš Kukrál | 86b9ab2 | 2017-09-05 16:55:58 +0200 | [diff] [blame] | 122 | // no underscore in STACK_NAME |
| 123 | STACK_NAME = STACK_NAME.replaceAll('_', '-') |
Tomáš Kukrál | 77b1b5a | 2017-09-24 18:56:49 +0200 | [diff] [blame] | 124 | outputs.put('stack_name', STACK_NAME) |
Tomáš Kukrál | 86b9ab2 | 2017-09-05 16:55:58 +0200 | [diff] [blame] | 125 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 126 | // set description |
| 127 | currentBuild.description = "${STACK_NAME}" |
| 128 | |
| 129 | // get templates |
| 130 | git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS) |
| 131 | |
| 132 | // create openstack env |
| 133 | openstack.setupOpenstackVirtualenv(venv, OPENSTACK_API_CLIENT) |
| 134 | openstackCloud = openstack.createOpenstackEnv( |
| 135 | OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, |
| 136 | OPENSTACK_API_PROJECT, OPENSTACK_API_PROJECT_DOMAIN, |
| 137 | OPENSTACK_API_PROJECT_ID, OPENSTACK_API_USER_DOMAIN, |
| 138 | OPENSTACK_API_VERSION) |
| 139 | openstack.getKeystoneToken(openstackCloud, venv) |
Tomáš Kukrál | 8427ff5 | 2017-08-30 15:46:52 +0200 | [diff] [blame] | 140 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 141 | // |
| 142 | // Verify possibility of create stack for given user and stack type |
| 143 | // |
| 144 | wrap([$class: 'BuildUser']) { |
| 145 | if (env.BUILD_USER_ID && !env.BUILD_USER_ID.equals("jenkins") && !STACK_REUSE.toBoolean()) { |
Oleh Hryhorov | 8e320ca | 2017-09-22 13:23:44 +0300 | [diff] [blame] | 146 | def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}".replaceAll('_', '-'), venv) |
Tomáš Kukrál | 8427ff5 | 2017-08-30 15:46:52 +0200 | [diff] [blame] | 147 | if (existingStacks.size() >= _MAX_PERMITTED_STACKS) { |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 148 | STACK_DELETE = "false" |
| 149 | throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}") |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | // launch stack |
| 154 | if (STACK_REUSE.toBoolean() == false) { |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 155 | |
Tomáš Kukrál | 550364e | 2017-08-23 11:42:45 +0200 | [diff] [blame] | 156 | // set reclass repo in heat env |
| 157 | try { |
| 158 | envParams.put('cfg_reclass_branch', STACK_RECLASS_BRANCH) |
| 159 | envParams.put('cfg_reclass_address', STACK_RECLASS_ADDRESS) |
| 160 | } catch (MissingPropertyException e) { |
| 161 | common.infoMsg("Property STACK_RECLASS_BRANCH or STACK_RECLASS_ADDRESS not found! Using default values from template.") |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 162 | } |
Tomáš Kukrál | 550364e | 2017-08-23 11:42:45 +0200 | [diff] [blame] | 163 | |
Mykyta Karpin | 8f96113 | 2017-09-22 12:06:44 +0300 | [diff] [blame] | 164 | // put formulas revision - stable, testing or nightly |
| 165 | if (common.validInputParam('FORMULA_PKG_REVISION')) { |
| 166 | common.infoMsg("Setting formulas revision to ${FORMULA_PKG_REVISION}") |
| 167 | envParams.put('cfg_formula_pkg_revision', FORMULA_PKG_REVISION) |
| 168 | } |
| 169 | |
Mykyta Karpin | 0aa35d5 | 2017-08-28 11:44:42 +0300 | [diff] [blame] | 170 | openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, venv) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | // get SALT_MASTER_URL |
| 174 | saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, STACK_NAME, 'salt_master_ip', venv) |
chnyda | e14058a | 2017-08-29 15:07:48 +0200 | [diff] [blame] | 175 | // check that saltMasterHost is valid |
| 176 | if (!saltMasterHost || !saltMasterHost.matches(ipRegex)) { |
| 177 | common.errorMsg("saltMasterHost is not a valid ip, value is: ${saltMasterHost}") |
| 178 | throw new Exception("saltMasterHost is not a valid ip") |
| 179 | } |
| 180 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 181 | currentBuild.description = "${STACK_NAME} ${saltMasterHost}" |
| 182 | |
| 183 | SALT_MASTER_URL = "http://${saltMasterHost}:6969" |
| 184 | |
| 185 | } else if (STACK_TYPE == 'aws') { |
| 186 | |
| 187 | // setup environment |
| 188 | aws.setupVirtualEnv(venv) |
| 189 | |
| 190 | // set aws_env_vars |
| 191 | aws_env_vars = aws.getEnvVars(AWS_API_CREDENTIALS, AWS_STACK_REGION) |
| 192 | |
| 193 | if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') { |
| 194 | error("If you want to reuse existing stack you need to provide it's name") |
| 195 | } |
| 196 | |
| 197 | if (STACK_REUSE.toBoolean() == false) { |
| 198 | // Don't allow to set custom stack name |
| 199 | wrap([$class: 'BuildUser']) { |
| 200 | if (env.BUILD_USER_ID) { |
| 201 | STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}" |
| 202 | } else { |
| 203 | STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}" |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 207 | // no underscore in STACK_NAME |
| 208 | STACK_NAME = STACK_NAME.replaceAll('_', '-') |
| 209 | } |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 210 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 211 | // set description |
| 212 | currentBuild.description = STACK_NAME |
Tomáš Kukrál | 77b1b5a | 2017-09-24 18:56:49 +0200 | [diff] [blame] | 213 | outputs.put('stack_name', STACK_NAME) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 214 | |
| 215 | if (STACK_REUSE.toBoolean() == false) { |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 216 | // get templates |
| 217 | git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS) |
| 218 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 219 | // start stack |
| 220 | def stack_params = [ |
| 221 | "ParameterKey=KeyName,ParameterValue=" + AWS_SSH_KEY, |
| 222 | "ParameterKey=CmpNodeCount,ParameterValue=" + STACK_COMPUTE_COUNT |
| 223 | ] |
| 224 | def template_file = 'cfn/' + STACK_TEMPLATE + '.yml' |
| 225 | aws.createStack(venv, aws_env_vars, template_file, STACK_NAME, stack_params) |
Tomáš Kukrál | 7a8a4fa | 2017-05-25 14:54:24 +0200 | [diff] [blame] | 226 | } |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 227 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 228 | // wait for stack to be ready |
| 229 | aws.waitForStatus(venv, aws_env_vars, STACK_NAME, 'CREATE_COMPLETE') |
| 230 | |
| 231 | // get outputs |
| 232 | saltMasterHost = aws.getOutputs(venv, aws_env_vars, STACK_NAME, 'SaltMasterIP') |
Tomáš Kukrál | 8e50d8e | 2017-09-01 17:40:53 +0200 | [diff] [blame] | 233 | |
chnyda | e14058a | 2017-08-29 15:07:48 +0200 | [diff] [blame] | 234 | // check that saltMasterHost is valid |
| 235 | if (!saltMasterHost || !saltMasterHost.matches(ipRegex)) { |
| 236 | common.errorMsg("saltMasterHost is not a valid ip, value is: ${saltMasterHost}") |
| 237 | throw new Exception("saltMasterHost is not a valid ip") |
| 238 | } |
| 239 | |
Tomáš Kukrál | 8e50d8e | 2017-09-01 17:40:53 +0200 | [diff] [blame] | 240 | currentBuild.description = "${STACK_NAME} ${saltMasterHost}" |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 241 | SALT_MASTER_URL = "http://${saltMasterHost}:6969" |
| 242 | |
| 243 | } else if (STACK_TYPE != 'physical') { |
| 244 | throw new Exception("STACK_TYPE ${STACK_TYPE} is not supported") |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 245 | } |
| 246 | |
Tomáš Kukrál | 8e50d8e | 2017-09-01 17:40:53 +0200 | [diff] [blame] | 247 | outputs.put('salt_api', SALT_MASTER_URL) |
| 248 | |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 249 | // Setup virtualenv for pepper |
| 250 | python.setupPepperVirtualenv(venvPepper, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 251 | } |
Tomáš Kukrál | 4691f68 | 2017-07-27 16:36:12 +0200 | [diff] [blame] | 252 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 253 | |
| 254 | // Set up override params |
Jakub Josef | eb15f0b | 2017-08-03 18:22:06 +0200 | [diff] [blame] | 255 | if (common.validInputParam('SALT_OVERRIDES')) { |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 256 | stage('Set Salt overrides') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 257 | salt.setSaltOverrides(venvPepper, SALT_OVERRIDES) |
Tomáš Kukrál | 4691f68 | 2017-07-27 16:36:12 +0200 | [diff] [blame] | 258 | } |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 259 | } |
Tomáš Kukrál | 4691f68 | 2017-07-27 16:36:12 +0200 | [diff] [blame] | 260 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 261 | // |
| 262 | // Install |
| 263 | // |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 264 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 265 | if (common.checkContains('STACK_INSTALL', 'core')) { |
| 266 | stage('Install core infrastructure') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 267 | orchestrate.installFoundationInfra(venvPepper) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 268 | |
| 269 | if (common.checkContains('STACK_INSTALL', 'kvm')) { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 270 | orchestrate.installInfraKvm(venvPepper) |
| 271 | orchestrate.installFoundationInfra(venvPepper) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 272 | } |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 273 | |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 274 | orchestrate.validateFoundationInfra(venvPepper) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 275 | } |
| 276 | } |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 277 | |
Tomáš Kukrál | b6777fa | 2017-08-11 10:36:30 +0200 | [diff] [blame] | 278 | // install ceph |
| 279 | if (common.checkContains('STACK_INSTALL', 'ceph')) { |
Tomáš Kukrál | 7b949ea | 2017-08-19 10:08:39 +0200 | [diff] [blame] | 280 | stage('Install Ceph MONs') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 281 | orchestrate.installCephMon(venvPepper) |
Tomáš Kukrál | 7b949ea | 2017-08-19 10:08:39 +0200 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | stage('Install Ceph OSDs') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 285 | orchestrate.installCephOsd(venvPepper) |
Tomáš Kukrál | 7b949ea | 2017-08-19 10:08:39 +0200 | [diff] [blame] | 286 | } |
Tomáš Kukrál | a77caa9 | 2017-08-25 18:19:52 +0200 | [diff] [blame] | 287 | |
Tomáš Kukrál | 0cc0109 | 2017-08-28 18:25:00 +0200 | [diff] [blame] | 288 | |
| 289 | stage('Install Ceph clients') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 290 | orchestrate.installCephClient(venvPepper) |
Tomáš Kukrál | a77caa9 | 2017-08-25 18:19:52 +0200 | [diff] [blame] | 291 | } |
Jiri Broulik | 8c38003 | 2017-10-06 13:36:03 +0200 | [diff] [blame] | 292 | |
| 293 | stage('Connect Ceph') { |
chnyda | 625f4b4 | 2017-10-11 14:10:31 +0200 | [diff] [blame] | 294 | orchestrate.connectCeph(venvPepper) |
Jiri Broulik | 8c38003 | 2017-10-06 13:36:03 +0200 | [diff] [blame] | 295 | } |
Tomáš Kukrál | b6777fa | 2017-08-11 10:36:30 +0200 | [diff] [blame] | 296 | } |
| 297 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 298 | // install k8s |
| 299 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
| 300 | |
| 301 | stage('Install Kubernetes infra') { |
| 302 | if (STACK_TYPE == 'aws') { |
| 303 | // configure kubernetes_control_address - save loadbalancer |
Tomáš Kukrál | 8e50d8e | 2017-09-01 17:40:53 +0200 | [diff] [blame] | 304 | def awsOutputs = aws.getOutputs(venv, aws_env_vars, STACK_NAME) |
Tomáš Kukrál | 685f3b8 | 2017-09-03 10:14:40 +0200 | [diff] [blame] | 305 | common.prettyPrint(awsOutputs) |
Tomáš Kukrál | 8e50d8e | 2017-09-01 17:40:53 +0200 | [diff] [blame] | 306 | if (awsOutputs.containsKey('ControlLoadBalancer')) { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 307 | salt.runSaltProcessStep(venvPepper, 'I@salt:master', 'reclass.cluster_meta_set', ['kubernetes_control_address', awsOutputs['ControlLoadBalancer']], null, true) |
Tomáš Kukrál | 8e50d8e | 2017-09-01 17:40:53 +0200 | [diff] [blame] | 308 | outputs.put('kubernetes_apiserver', 'https://' + awsOutputs['ControlLoadBalancer']) |
| 309 | } |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | // ensure certificates are generated properly |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 313 | salt.runSaltProcessStep(venvPepper, '*', 'saltutil.refresh_pillar', [], null, true) |
| 314 | salt.enforceState(venvPepper, '*', ['salt.minion.cert'], true) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 315 | |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 316 | orchestrate.installKubernetesInfra(venvPepper) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | if (common.checkContains('STACK_INSTALL', 'contrail')) { |
| 320 | stage('Install Contrail for Kubernetes') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 321 | orchestrate.installContrailNetwork(venvPepper) |
| 322 | orchestrate.installContrailCompute(venvPepper) |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 323 | } |
| 324 | } |
| 325 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 326 | stage('Install Kubernetes control') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 327 | orchestrate.installKubernetesControl(venvPepper) |
Tomáš Kukrál | 7e48706 | 2017-08-31 11:20:08 +0200 | [diff] [blame] | 328 | |
| 329 | // collect artifacts (kubeconfig) |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 330 | writeFile(file: 'kubeconfig', text: salt.getFileContent(venvPepper, 'I@kubernetes:master and *01*', '/etc/kubernetes/admin-kube-config')) |
Tomáš Kukrál | 7e48706 | 2017-08-31 11:20:08 +0200 | [diff] [blame] | 331 | archiveArtifacts(artifacts: 'kubeconfig') |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 332 | } |
| 333 | |
Tomáš Kukrál | f83409d | 2017-11-08 20:56:57 +0100 | [diff] [blame] | 334 | stage('Install Kubernetes computes') { |
| 335 | if (common.validInputParam('STACK_COMPUTE_COUNT')) { |
| 336 | if (STACK_COMPUTE_COUNT > 0) { |
| 337 | if (STACK_TYPE == 'aws') { |
| 338 | // get stack info |
| 339 | def scaling_group = aws.getOutputs(venv, aws_env_vars, STACK_NAME, 'ComputesScalingGroup') |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 340 | |
Tomáš Kukrál | f83409d | 2017-11-08 20:56:57 +0100 | [diff] [blame] | 341 | //update autoscaling group |
| 342 | aws.updateAutoscalingGroup(venv, aws_env_vars, scaling_group, ["--desired-capacity " + STACK_COMPUTE_COUNT]) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 343 | |
Tomáš Kukrál | f83409d | 2017-11-08 20:56:57 +0100 | [diff] [blame] | 344 | // wait for computes to boot up |
| 345 | aws.waitForAutoscalingInstances(venv, aws_env_vars, scaling_group) |
| 346 | sleep(60) |
Tomáš Kukrál | 8427ff5 | 2017-08-30 15:46:52 +0200 | [diff] [blame] | 347 | |
Tomáš Kukrál | f83409d | 2017-11-08 20:56:57 +0100 | [diff] [blame] | 348 | } else if (STACK_TYPE == 'heat') { |
| 349 | envParams.put('cluster_node_count', STACK_COMPUTE_COUNT) |
Tomáš Kukrál | 8427ff5 | 2017-08-30 15:46:52 +0200 | [diff] [blame] | 350 | |
Tomáš Kukrál | f83409d | 2017-11-08 20:56:57 +0100 | [diff] [blame] | 351 | openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, venv, "update") |
| 352 | sleep(60) |
| 353 | } |
| 354 | |
Tomáš Kukrál | 39c96cd | 2017-07-11 10:14:13 +0200 | [diff] [blame] | 355 | } |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 356 | } |
Tomáš Kukrál | f83409d | 2017-11-08 20:56:57 +0100 | [diff] [blame] | 357 | |
| 358 | orchestrate.installKubernetesCompute(venvPepper) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 359 | } |
| 360 | } |
| 361 | |
| 362 | // install openstack |
| 363 | if (common.checkContains('STACK_INSTALL', 'openstack')) { |
| 364 | // install Infra and control, tests, ... |
| 365 | |
| 366 | stage('Install OpenStack infra') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 367 | orchestrate.installOpenstackInfra(venvPepper) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | stage('Install OpenStack control') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 371 | orchestrate.installOpenstackControl(venvPepper) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | stage('Install OpenStack network') { |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 375 | |
vrovachev | 7be1e96 | 2017-07-05 13:28:26 +0400 | [diff] [blame] | 376 | if (common.checkContains('STACK_INSTALL', 'contrail')) { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 377 | orchestrate.installContrailNetwork(venvPepper) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 378 | } else if (common.checkContains('STACK_INSTALL', 'ovs')) { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 379 | orchestrate.installOpenstackNetwork(venvPepper) |
vrovachev | 7be1e96 | 2017-07-05 13:28:26 +0400 | [diff] [blame] | 380 | } |
| 381 | |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 382 | salt.runSaltProcessStep(venvPepper, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list']) |
| 383 | salt.runSaltProcessStep(venvPepper, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list']) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 384 | } |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 385 | |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 386 | if (salt.testTarget(venvPepper, 'I@ironic:conductor')){ |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 387 | stage('Install OpenStack Ironic conductor') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 388 | orchestrate.installIronicConductor(venvPepper) |
Tomáš Kukrál | 74f9286 | 2017-06-05 19:18:43 +0200 | [diff] [blame] | 389 | } |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 390 | } |
| 391 | |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 392 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 393 | stage('Install OpenStack compute') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 394 | orchestrate.installOpenstackCompute(venvPepper) |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 395 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 396 | if (common.checkContains('STACK_INSTALL', 'contrail')) { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 397 | orchestrate.installContrailCompute(venvPepper) |
Martin Polreich | 4697110 | 2017-07-11 12:56:40 +0200 | [diff] [blame] | 398 | } |
| 399 | } |
| 400 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 401 | } |
| 402 | |
Mikhail Ivanov | 3deb79a | 2017-12-06 17:44:47 +0400 | [diff] [blame^] | 403 | if (common.checkContains('STACK_INSTALL', 'oss')) { |
| 404 | stage('Install Oss infra') { |
| 405 | orchestrate.installOssInfra(venvPepper) |
| 406 | } |
| 407 | } |
| 408 | |
Jiri Broulik | b27b483 | 2017-09-05 16:41:03 +0200 | [diff] [blame] | 409 | if (common.checkContains('STACK_INSTALL', 'cicd')) { |
| 410 | stage('Install Cicd') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 411 | orchestrate.installDockerSwarm(venvPepper) |
| 412 | orchestrate.installCicd(venvPepper) |
Jiri Broulik | b27b483 | 2017-09-05 16:41:03 +0200 | [diff] [blame] | 413 | } |
| 414 | } |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 415 | |
| 416 | if (common.checkContains('STACK_INSTALL', 'sl-legacy')) { |
| 417 | stage('Install StackLight v1') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 418 | orchestrate.installStacklightv1Control(venvPepper) |
| 419 | orchestrate.installStacklightv1Client(venvPepper) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 420 | } |
| 421 | } |
| 422 | |
| 423 | if (common.checkContains('STACK_INSTALL', 'stacklight')) { |
| 424 | stage('Install StackLight') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 425 | orchestrate.installDockerSwarm(venvPepper) |
| 426 | orchestrate.installStacklight(venvPepper) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 427 | } |
| 428 | } |
| 429 | |
Mikhail Ivanov | 3deb79a | 2017-12-06 17:44:47 +0400 | [diff] [blame^] | 430 | if (common.checkContains('STACK_INSTALL', 'oss')) { |
| 431 | stage('Install OSS') { |
| 432 | if (!common.checkContains('STACK_INSTALL', 'stacklight')) { |
| 433 | // In case if StackLightv2 enabled containers already started |
| 434 | orchestrate.installDockerSwarm(venvPepper) |
| 435 | salt.enforceState(venvPepper, 'I@docker:swarm:role:master and I@devops_portal:config', 'docker.client', true) |
| 436 | } |
| 437 | orchestrate.installOss(venvPepper) |
| 438 | } |
| 439 | } |
| 440 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 441 | // |
| 442 | // Test |
| 443 | // |
| 444 | def artifacts_dir = '_artifacts/' |
| 445 | |
| 446 | if (common.checkContains('STACK_TEST', 'k8s')) { |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 447 | stage('Run k8s conformance e2e tests') { |
Anna Babich | 12dd5b1 | 2017-08-21 18:01:35 +0300 | [diff] [blame] | 448 | def image = TEST_K8S_CONFORMANCE_IMAGE |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 449 | def output_file = image.replaceAll('/', '-') + '.output' |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 450 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 451 | // run image |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 452 | test.runConformanceTests(venvPepper, 'ctl01*', TEST_K8S_API_SERVER, image) |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 453 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 454 | // collect output |
| 455 | sh "mkdir -p ${artifacts_dir}" |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 456 | file_content = salt.getFileContent(venvPepper, 'ctl01*', '/tmp/' + output_file) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 457 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 458 | sh "cat ${artifacts_dir}${output_file}" |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 459 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 460 | // collect artifacts |
| 461 | archiveArtifacts artifacts: "${artifacts_dir}${output_file}" |
| 462 | } |
| 463 | } |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 464 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 465 | if (common.checkContains('STACK_TEST', 'openstack')) { |
| 466 | if (common.checkContains('TEST_DOCKER_INSTALL', 'true')) { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 467 | test.install_docker(venvPepper, TEST_TEMPEST_TARGET) |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 468 | } |
| 469 | stage('Run OpenStack tests') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 470 | test.runTempestTests(venvPepper, TEST_TEMPEST_IMAGE, TEST_TEMPEST_TARGET, TEST_TEMPEST_PATTERN) |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 471 | } |
| 472 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 473 | stage('Copy Tempest results to config node') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 474 | test.copyTempestResults(venvPepper, TEST_TEMPEST_TARGET) |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 475 | } |
Vasyl Saienko | ff24e58 | 2017-08-04 10:04:33 +0300 | [diff] [blame] | 476 | |
| 477 | stage('Archive rally artifacts') { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 478 | test.archiveRallyArtifacts(venvPepper, TEST_TEMPEST_TARGET) |
Vasyl Saienko | ff24e58 | 2017-08-04 10:04:33 +0300 | [diff] [blame] | 479 | } |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 480 | } |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 481 | |
Tomáš Kukrál | 4b6b4d3 | 2017-08-21 20:29:21 +0200 | [diff] [blame] | 482 | |
| 483 | if (common.checkContains('STACK_TEST', 'ceph')) { |
Tomáš Kukrál | f579808 | 2017-08-21 22:37:41 +0200 | [diff] [blame] | 484 | stage('Run infra tests') { |
Tomáš Kukrál | 36d4397 | 2017-08-30 12:43:17 +0200 | [diff] [blame] | 485 | sleep(120) |
Tomáš Kukrál | 07ad0c9 | 2017-08-21 23:19:40 +0200 | [diff] [blame] | 486 | def cmd = "apt-get install -y python-pip && pip install -r /usr/share/salt-formulas/env/ceph/files/testinfra/requirements.txt && python -m pytest --junitxml=/root/report.xml /usr/share/salt-formulas/env/ceph/files/testinfra/" |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 487 | salt.cmdRun(venvPepper, 'I@salt:master', cmd, false) |
| 488 | writeFile(file: 'report.xml', text: salt.getFileContent(venvPepper, 'I@salt:master', '/root/report.xml')) |
Tomáš Kukrál | c48456a | 2017-08-21 23:03:37 +0200 | [diff] [blame] | 489 | junit(keepLongStdio: true, testResults: 'report.xml') |
Tomáš Kukrál | 4b6b4d3 | 2017-08-21 20:29:21 +0200 | [diff] [blame] | 490 | } |
| 491 | } |
| 492 | |
| 493 | |
Tomáš Kukrál | 8e50d8e | 2017-09-01 17:40:53 +0200 | [diff] [blame] | 494 | stage('Finalize') { |
| 495 | if (common.checkContains('STACK_INSTALL', 'finalize')) { |
chnyda | 597fb03 | 2017-10-06 13:42:48 +0200 | [diff] [blame] | 496 | salt.runSaltProcessStep(venvPepper, '*', 'state.apply', [], null, true) |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 497 | } |
Tomáš Kukrál | 8e50d8e | 2017-09-01 17:40:53 +0200 | [diff] [blame] | 498 | |
| 499 | outputsPretty = common.prettify(outputs) |
| 500 | print(outputsPretty) |
| 501 | writeFile(file: 'outputs.json', text: outputsPretty) |
| 502 | archiveArtifacts(artifacts: 'outputs.json') |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 503 | } |
Tomáš Kukrál | 53224c2 | 2017-07-26 10:53:20 +0200 | [diff] [blame] | 504 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 505 | } catch (Throwable e) { |
| 506 | currentBuild.result = 'FAILURE' |
| 507 | throw e |
| 508 | } finally { |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 509 | |
| 510 | |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 511 | // |
| 512 | // Clean |
| 513 | // |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 514 | |
Jakub Josef | eb15f0b | 2017-08-03 18:22:06 +0200 | [diff] [blame] | 515 | if (common.validInputParam('STACK_NAME')) { |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 516 | // send notification |
| 517 | common.sendNotification(currentBuild.result, STACK_NAME, ["slack"]) |
| 518 | } |
| 519 | |
Jakub Josef | eb15f0b | 2017-08-03 18:22:06 +0200 | [diff] [blame] | 520 | if (common.validInputParam('STACK_DELETE') && STACK_DELETE.toBoolean() == true) { |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 521 | stage('Trigger cleanup job') { |
| 522 | common.errorMsg('Stack cleanup job triggered') |
| 523 | build(job: STACK_CLEANUP_JOB, parameters: [ |
| 524 | [$class: 'StringParameterValue', name: 'STACK_NAME', value: STACK_NAME], |
| 525 | [$class: 'StringParameterValue', name: 'STACK_TYPE', value: STACK_TYPE], |
| 526 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_URL', value: OPENSTACK_API_URL], |
| 527 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_CREDENTIALS', value: OPENSTACK_API_CREDENTIALS], |
| 528 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT', value: OPENSTACK_API_PROJECT], |
| 529 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_DOMAIN', value: OPENSTACK_API_PROJECT_DOMAIN], |
| 530 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_ID', value: OPENSTACK_API_PROJECT_ID], |
| 531 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_USER_DOMAIN', value: OPENSTACK_API_USER_DOMAIN], |
| 532 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_CLIENT', value: OPENSTACK_API_CLIENT], |
| 533 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_VERSION', value: OPENSTACK_API_VERSION] |
| 534 | ]) |
Tomáš Kukrál | 439c62e | 2017-06-02 11:42:36 +0200 | [diff] [blame] | 535 | } |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 536 | } else { |
| 537 | if (currentBuild.result == 'FAILURE') { |
| 538 | common.errorMsg("Deploy job FAILED and was not deleted. Please fix the problem and delete stack on you own.") |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 539 | |
Jakub Josef | eb15f0b | 2017-08-03 18:22:06 +0200 | [diff] [blame] | 540 | if (common.validInputParam('SALT_MASTER_URL')) { |
Ruslan Kamaldinov | 6514432 | 2017-08-02 15:16:55 +0400 | [diff] [blame] | 541 | common.errorMsg("Salt master URL: ${SALT_MASTER_URL}") |
Ales Komarek | 2409740 | 2017-05-22 16:28:10 +0200 | [diff] [blame] | 542 | } |
| 543 | } |
| 544 | } |
| 545 | } |
| 546 | } |