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