Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 1 | /** |
Tomáš Kukrál | 4691f68 | 2017-07-27 16:36:12 +0200 | [diff] [blame] | 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | * This pipeline is deprecated, please use cloud-deploy-pipeline |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 24 | * |
| 25 | * Launch heat stack with basic k8s |
| 26 | * Flow parameters: |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 27 | * STACK_NAME Heat stack name |
| 28 | * STACK_TYPE Orchestration engine: heat, '' |
| 29 | * STACK_INSTALL What should be installed (k8s, openstack, ...) |
| 30 | * STACK_TEST What should be tested (k8s, openstack, ...) |
| 31 | * |
| 32 | * STACK_TEMPLATE_URL URL to git repo with stack templates |
| 33 | * STACK_TEMPLATE_BRANCH Stack templates repo branch |
| 34 | * STACK_TEMPLATE_CREDENTIALS Credentials to the stack templates repo |
| 35 | * STACK_TEMPLATE Heat stack HOT template |
Vasyl Saienko | d3bbc50 | 2017-07-17 10:46:36 +0300 | [diff] [blame] | 36 | * STACK_RECLASS_ADDRESS Stack reclass address |
| 37 | * STACK_RECLASS_BRANCH Stack reclass repo branch |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 38 | * STACK_DELETE Delete stack when finished (bool) |
| 39 | * STACK_REUSE Reuse stack (don't create one) |
| 40 | * STACK_CLEANUP_JOB Name of job for deleting Heat stack |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 41 | * |
| 42 | * Expected parameters: |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 43 | * required for STACK_TYPE=heat |
Matthew Mosesohn | 59fc648 | 2017-06-01 18:53:10 +0300 | [diff] [blame] | 44 | * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters |
| 45 | * HEAT_STACK_ZONE Heat stack availability zone |
| 46 | * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool |
| 47 | * OPENSTACK_API_URL OpenStack API address |
| 48 | * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API |
| 49 | * OPENSTACK_API_PROJECT OpenStack project to connect to |
| 50 | * OPENSTACK_API_PROJECT_DOMAIN Domain for OpenStack project |
| 51 | * OPENSTACK_API_PROJECT_ID ID for OpenStack project |
| 52 | * OPENSTACK_API_USER_DOMAIN Domain for OpenStack user |
| 53 | * OPENSTACK_API_CLIENT Versions of OpenStack python clients |
| 54 | * OPENSTACK_API_VERSION Version of the OpenStack API (2/3) |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 55 | * |
| 56 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API |
| 57 | * |
| 58 | * required for STACK_TYPE=NONE or empty string |
| 59 | * SALT_MASTER_URL URL of Salt-API |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 60 | * |
Tomáš Kukrál | 5c2ec13 | 2017-07-26 09:57:27 +0200 | [diff] [blame] | 61 | * Test settings: |
| 62 | * TEST_K8S_API_SERVER Kubernetes API address |
| 63 | * TEST_K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests |
| 64 | * |
| 65 | * TEST_TEMPEST_IMAGE Tempest image link |
| 66 | * TEST_DOCKER_INSTALL Install docker on the target if tue |
| 67 | * TEST_TEMPEST_PATTERN If not false, run tests matched to pattern only |
| 68 | * TEST_TEMPEST_TARGET Salt target for tempest node |
Victor Ryzhenkin | 5f3b7e6 | 2017-03-09 16:02:58 +0400 | [diff] [blame] | 69 | * |
Matthew Mosesohn | a85f24e | 2017-04-28 13:45:19 +0300 | [diff] [blame] | 70 | * optional parameters for overwriting soft params |
Matthew Mosesohn | 1393344 | 2017-07-04 21:20:08 +0300 | [diff] [blame] | 71 | * SALT_OVERRIDES YAML with overrides for Salt deployment |
Matthew Mosesohn | a85f24e | 2017-04-28 13:45:19 +0300 | [diff] [blame] | 72 | * |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 73 | */ |
| 74 | |
Tomáš Kukrál | 1f8b501 | 2017-04-28 21:07:10 +0200 | [diff] [blame] | 75 | common = new com.mirantis.mk.Common() |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 76 | git = new com.mirantis.mk.Git() |
| 77 | openstack = new com.mirantis.mk.Openstack() |
Tomáš Kukrál | 1f8b501 | 2017-04-28 21:07:10 +0200 | [diff] [blame] | 78 | orchestrate = new com.mirantis.mk.Orchestrate() |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 79 | salt = new com.mirantis.mk.Salt() |
Ondrej Smola | 8f35e48 | 2017-03-30 14:04:36 +0200 | [diff] [blame] | 80 | test = new com.mirantis.mk.Test() |
Tomáš Kukrál | 1f8b501 | 2017-04-28 21:07:10 +0200 | [diff] [blame] | 81 | |
Tomáš Kukrál | ab2f370 | 2017-05-11 09:17:43 +0200 | [diff] [blame] | 82 | _MAX_PERMITTED_STACKS = 2 |
Tomáš Kukrál | e80680a | 2017-03-02 16:34:35 +0100 | [diff] [blame] | 83 | |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 84 | timestamps { |
| 85 | node { |
Jakub Josef | 96ec3aa | 2017-05-29 17:53:56 +0200 | [diff] [blame] | 86 | // try to get STACK_INSTALL or fallback to INSTALL if exists |
| 87 | try { |
| 88 | def temporary = STACK_INSTALL |
| 89 | } catch (MissingPropertyException e) { |
| 90 | try { |
| 91 | STACK_INSTALL = INSTALL |
| 92 | env['STACK_INSTALL'] = INSTALL |
| 93 | } catch (MissingPropertyException e2) { |
| 94 | common.errorMsg("Property STACK_INSTALL or INSTALL not found!") |
| 95 | } |
| 96 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 97 | try { |
| 98 | // |
| 99 | // Prepare machines |
| 100 | // |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 101 | stage ('Create infrastructure') { |
Tomáš Kukrál | 6d627d6 | 2017-03-23 17:39:07 +0100 | [diff] [blame] | 102 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 103 | if (STACK_TYPE == 'heat') { |
| 104 | // value defaults |
| 105 | def openstackCloud |
| 106 | def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty' |
| 107 | def openstackEnv = "${env.WORKSPACE}/venv" |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 108 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 109 | if (STACK_REUSE.toBoolean() == true && STACK_NAME == '') { |
Filip Pytloun | 794ad95 | 2017-03-03 10:39:26 +0100 | [diff] [blame] | 110 | error("If you want to reuse existing stack you need to provide it's name") |
| 111 | } |
| 112 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 113 | if (STACK_REUSE.toBoolean() == false) { |
Filip Pytloun | 794ad95 | 2017-03-03 10:39:26 +0100 | [diff] [blame] | 114 | // Don't allow to set custom heat stack name |
| 115 | wrap([$class: 'BuildUser']) { |
Tomáš Kukrál | 24d7fe6 | 2017-03-03 10:57:11 +0100 | [diff] [blame] | 116 | if (env.BUILD_USER_ID) { |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 117 | STACK_NAME = "${env.BUILD_USER_ID}-${JOB_NAME}-${BUILD_NUMBER}" |
Tomáš Kukrál | 24d7fe6 | 2017-03-03 10:57:11 +0100 | [diff] [blame] | 118 | } else { |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 119 | STACK_NAME = "jenkins-${JOB_NAME}-${BUILD_NUMBER}" |
Tomáš Kukrál | 24d7fe6 | 2017-03-03 10:57:11 +0100 | [diff] [blame] | 120 | } |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 121 | currentBuild.description = STACK_NAME |
Filip Pytloun | 794ad95 | 2017-03-03 10:39:26 +0100 | [diff] [blame] | 122 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 123 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 124 | |
Tomáš Kukrál | cbabec4 | 2017-03-02 16:24:04 +0100 | [diff] [blame] | 125 | // set description |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 126 | currentBuild.description = "${STACK_NAME}" |
Tomáš Kukrál | cbabec4 | 2017-03-02 16:24:04 +0100 | [diff] [blame] | 127 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 128 | // get templates |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 129 | git.checkoutGitRepository('template', STACK_TEMPLATE_URL, STACK_TEMPLATE_BRANCH, STACK_TEMPLATE_CREDENTIALS) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 130 | |
| 131 | // create openstack env |
| 132 | openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion) |
Matthew Mosesohn | bd7976b | 2017-05-29 19:35:44 +0300 | [diff] [blame] | 133 | openstackCloud = openstack.createOpenstackEnv( |
| 134 | OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, |
Matthew Mosesohn | 59fc648 | 2017-06-01 18:53:10 +0300 | [diff] [blame] | 135 | OPENSTACK_API_PROJECT, OPENSTACK_API_PROJECT_DOMAIN, |
| 136 | OPENSTACK_API_PROJECT_ID, OPENSTACK_API_USER_DOMAIN, |
Matthew Mosesohn | bd7976b | 2017-05-29 19:35:44 +0300 | [diff] [blame] | 137 | OPENSTACK_API_VERSION) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 138 | openstack.getKeystoneToken(openstackCloud, openstackEnv) |
Jakub Josef | 458913d | 2017-05-10 15:37:56 +0200 | [diff] [blame] | 139 | // |
| 140 | // Verify possibility of create stack for given user and stack type |
| 141 | // |
| 142 | wrap([$class: 'BuildUser']) { |
chnyda | f23f46b | 2017-06-05 14:54:27 +0200 | [diff] [blame] | 143 | if (env.BUILD_USER_ID && !env.BUILD_USER_ID.equals("jenkins") && !env.BUILD_USER_ID.equals("mceloud") && !STACK_REUSE.toBoolean()) { |
Jakub Josef | 78c3f8b | 2017-05-10 15:45:29 +0200 | [diff] [blame] | 144 | def existingStacks = openstack.getStacksForNameContains(openstackCloud, "${env.BUILD_USER_ID}-${JOB_NAME}", openstackEnv) |
| 145 | if(existingStacks.size() >= _MAX_PERMITTED_STACKS){ |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 146 | STACK_DELETE = "false" |
Jakub Josef | 78c3f8b | 2017-05-10 15:45:29 +0200 | [diff] [blame] | 147 | throw new Exception("You cannot create new stack, you already have ${_MAX_PERMITTED_STACKS} stacks of this type (${JOB_NAME}). \nStack names: ${existingStacks}") |
| 148 | } |
Jakub Josef | 458913d | 2017-05-10 15:37:56 +0200 | [diff] [blame] | 149 | } |
| 150 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 151 | // launch stack |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 152 | if (STACK_REUSE.toBoolean() == false) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 153 | stage('Launch new Heat stack') { |
| 154 | // create stack |
| 155 | envParams = [ |
| 156 | 'instance_zone': HEAT_STACK_ZONE, |
| 157 | 'public_net': HEAT_STACK_PUBLIC_NET |
| 158 | ] |
Vasyl Saienko | d3bbc50 | 2017-07-17 10:46:36 +0300 | [diff] [blame] | 159 | try { |
| 160 | envParams.put('cfg_reclass_branch', STACK_RECLASS_BRANCH) |
| 161 | envParams.put('cfg_reclass_address', STACK_RECLASS_ADDRESS) |
| 162 | } catch (MissingPropertyException e) { |
| 163 | common.infoMsg("Property STACK_RECLASS_BRANCH or STACK_RECLASS_ADDRESS not found! Using default values from template.") |
| 164 | } |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 165 | openstack.createHeatStack(openstackCloud, STACK_NAME, STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | |
| 169 | // get SALT_MASTER_URL |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 170 | saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, STACK_NAME, 'salt_master_ip', openstackEnv) |
| 171 | currentBuild.description = "${STACK_NAME}: ${saltMasterHost}" |
Tomáš Kukrál | 615aa9c | 2017-03-04 15:29:08 +0100 | [diff] [blame] | 172 | |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 173 | SALT_MASTER_URL = "http://${saltMasterHost}:6969" |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 174 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 175 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 176 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 177 | // |
| 178 | // Connect to Salt master |
| 179 | // |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 180 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 181 | def saltMaster |
| 182 | stage('Connect to Salt API') { |
| 183 | saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 184 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 185 | |
Vasyl Saienko | 70fec66 | 2017-07-27 17:36:09 +0300 | [diff] [blame] | 186 | // Set up override params |
| 187 | if (env.getEnvironment().containsKey('SALT_OVERRIDES')) { |
| 188 | stage('Set Salt overrides') { |
| 189 | salt.setSaltOverrides(saltMaster, SALT_OVERRIDES) |
| 190 | } |
| 191 | } |
| 192 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 193 | // |
| 194 | // Install |
| 195 | // |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 196 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 197 | if (common.checkContains('STACK_INSTALL', 'core')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 198 | stage('Install core infrastructure') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 199 | orchestrate.installFoundationInfra(saltMaster) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 200 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 201 | if (common.checkContains('STACK_INSTALL', 'kvm')) { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 202 | orchestrate.installInfraKvm(saltMaster) |
| 203 | orchestrate.installFoundationInfra(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 204 | } |
| 205 | |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 206 | orchestrate.validateFoundationInfra(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 207 | } |
| 208 | } |
| 209 | |
| 210 | // install k8s |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 211 | if (common.checkContains('STACK_INSTALL', 'k8s')) { |
vrovachev | 48ea862 | 2017-06-28 10:28:56 +0400 | [diff] [blame] | 212 | |
vrovachev | 7be1e96 | 2017-07-05 13:28:26 +0400 | [diff] [blame] | 213 | // install infra libs for k8s |
| 214 | stage('Install Kubernetes infra') { |
| 215 | orchestrate.installKubernetesInfra(saltMaster) |
| 216 | } |
| 217 | |
vrovachev | 48ea862 | 2017-06-28 10:28:56 +0400 | [diff] [blame] | 218 | // If k8s install with contrail network manager then contrail need to be install first |
| 219 | if (common.checkContains('STACK_INSTALL', 'contrail')) { |
| 220 | stage('Install Contrail for Kubernetes') { |
| 221 | orchestrate.installContrailNetwork(saltMaster) |
| 222 | orchestrate.installContrailCompute(saltMaster) |
| 223 | orchestrate.installKubernetesContrailCompute(saltMaster) |
| 224 | } |
| 225 | } |
| 226 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 227 | stage('Install Kubernetes control') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 228 | orchestrate.installKubernetesControl(saltMaster) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 229 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 230 | } |
| 231 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 232 | // install openstack |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 233 | if (common.checkContains('STACK_INSTALL', 'openstack')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 234 | // install Infra and control, tests, ... |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 235 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 236 | stage('Install OpenStack infra') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 237 | orchestrate.installOpenstackInfra(saltMaster) |
Tomáš Kukrál | c265e35 | 2017-03-02 11:45:11 +0100 | [diff] [blame] | 238 | } |
| 239 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 240 | stage('Install OpenStack control') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 241 | orchestrate.installOpenstackControl(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | stage('Install OpenStack network') { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 245 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 246 | if (common.checkContains('STACK_INSTALL', 'contrail')) { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 247 | orchestrate.installContrailNetwork(saltMaster) |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 248 | } else if (common.checkContains('STACK_INSTALL', 'ovs')) { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 249 | orchestrate.installOpenstackNetwork(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 250 | } |
| 251 | |
Tomáš Kukrál | fbb9832 | 2017-05-02 10:38:05 +0200 | [diff] [blame] | 252 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list']) |
| 253 | salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list']) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 254 | } |
| 255 | |
Vasyl Saienko | 58ccaee | 2017-07-17 09:34:13 +0300 | [diff] [blame] | 256 | if (salt.testTarget(saltMaster, 'I@ironic:conductor')){ |
| 257 | stage('Install OpenStack Ironic conductor') { |
| 258 | orchestrate.installIronicConductor(saltMaster) |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 263 | stage('Install OpenStack compute') { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 264 | orchestrate.installOpenstackCompute(saltMaster) |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 265 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 266 | if (common.checkContains('STACK_INSTALL', 'contrail')) { |
Ales Komarek | 47a29f1 | 2017-04-26 12:05:47 +0200 | [diff] [blame] | 267 | orchestrate.installContrailCompute(saltMaster) |
Tomáš Kukrál | d5a40af | 2017-03-07 15:34:58 +0100 | [diff] [blame] | 268 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 269 | } |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 270 | |
Tomáš Kukrál | 00ed130 | 2017-03-03 17:38:40 +0100 | [diff] [blame] | 271 | } |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 272 | |
Tomáš Kukrál | 00ed130 | 2017-03-03 17:38:40 +0100 | [diff] [blame] | 273 | |
Martin Polreich | bb6f575 | 2017-06-30 12:37:41 +0200 | [diff] [blame] | 274 | if (common.checkContains('STACK_INSTALL', 'sl-legacy')) { |
| 275 | stage('Install StackLight v1') { |
| 276 | orchestrate.installStacklightv1Control(saltMaster) |
| 277 | orchestrate.installStacklightv1Client(saltMaster) |
| 278 | } |
| 279 | } |
| 280 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 281 | if (common.checkContains('STACK_INSTALL', 'stacklight')) { |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 282 | stage('Install StackLight') { |
Martin Polreich | bb6f575 | 2017-06-30 12:37:41 +0200 | [diff] [blame] | 283 | orchestrate.installDockerSwarm(saltMaster) |
| 284 | orchestrate.installStacklight(saltMaster) |
Tomáš Kukrál | 2b4c128 | 2017-03-03 17:25:26 +0100 | [diff] [blame] | 285 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 286 | } |
| 287 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 288 | // |
| 289 | // Test |
| 290 | // |
Tomáš Kukrál | 695d646 | 2017-04-21 16:31:52 +0200 | [diff] [blame] | 291 | def artifacts_dir = '_artifacts/' |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 292 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 293 | if (common.checkContains('STACK_TEST', 'k8s')) { |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 294 | stage('Run k8s bootstrap tests') { |
Tomáš Kukrál | 695d646 | 2017-04-21 16:31:52 +0200 | [diff] [blame] | 295 | def image = 'tomkukral/k8s-scripts' |
Tomáš Kukrál | 44ca7fe | 2017-04-21 16:44:19 +0200 | [diff] [blame] | 296 | def output_file = image.replaceAll('/', '-') + '.output' |
Tomáš Kukrál | 695d646 | 2017-04-21 16:31:52 +0200 | [diff] [blame] | 297 | |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame] | 298 | // run image |
Tomáš Kukrál | 5c2ec13 | 2017-07-26 09:57:27 +0200 | [diff] [blame] | 299 | test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, image) |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 300 | |
| 301 | // collect output |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 302 | sh "mkdir -p ${artifacts_dir}" |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame] | 303 | file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file) |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 304 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
Tomáš Kukrál | f56beed | 2017-04-21 16:21:06 +0200 | [diff] [blame] | 305 | sh "cat ${artifacts_dir}${output_file}" |
| 306 | |
| 307 | // collect artifacts |
| 308 | archiveArtifacts artifacts: "${artifacts_dir}${output_file}" |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 309 | } |
| 310 | |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame] | 311 | stage('Run k8s conformance e2e tests') { |
Tomáš Kukrál | 5c2ec13 | 2017-07-26 09:57:27 +0200 | [diff] [blame] | 312 | //test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, TEST_K8S_CONFORMANCE_IMAGE) |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame] | 313 | |
Tomáš Kukrál | 5c2ec13 | 2017-07-26 09:57:27 +0200 | [diff] [blame] | 314 | def image = TEST_K8S_CONFORMANCE_IMAGE |
Tomáš Kukrál | 44ca7fe | 2017-04-21 16:44:19 +0200 | [diff] [blame] | 315 | def output_file = image.replaceAll('/', '-') + '.output' |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame] | 316 | |
| 317 | // run image |
Tomáš Kukrál | 5c2ec13 | 2017-07-26 09:57:27 +0200 | [diff] [blame] | 318 | test.runConformanceTests(saltMaster, TEST_K8S_API_SERVER, image) |
Tomáš Kukrál | b22826d | 2017-04-21 16:38:00 +0200 | [diff] [blame] | 319 | |
| 320 | // collect output |
| 321 | sh "mkdir -p ${artifacts_dir}" |
| 322 | file_content = salt.getFileContent(saltMaster, 'ctl01*', '/tmp/' + output_file) |
| 323 | writeFile file: "${artifacts_dir}${output_file}", text: file_content |
| 324 | sh "cat ${artifacts_dir}${output_file}" |
| 325 | |
| 326 | // collect artifacts |
| 327 | archiveArtifacts artifacts: "${artifacts_dir}${output_file}" |
| 328 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 329 | } |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 330 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 331 | if (common.checkContains('STACK_TEST', 'openstack')) { |
Tomáš Kukrál | 5c2ec13 | 2017-07-26 09:57:27 +0200 | [diff] [blame] | 332 | if (common.checkContains('TEST_DOCKER_INSTALL', 'true')) { |
| 333 | test.install_docker(saltMaster, TEST_TEMPEST_TARGET) |
Tatyana Leontovich | a6c0291 | 2017-07-10 20:02:18 +0300 | [diff] [blame] | 334 | } |
Victor Ryzhenkin | 5f3b7e6 | 2017-03-09 16:02:58 +0400 | [diff] [blame] | 335 | stage('Run OpenStack tests') { |
Tomáš Kukrál | 5c2ec13 | 2017-07-26 09:57:27 +0200 | [diff] [blame] | 336 | test.runTempestTests(saltMaster, TEST_TEMPEST_IMAGE, TEST_TEMPEST_TARGET, TEST_TEMPEST_PATTERN) |
Victor Ryzhenkin | 5f3b7e6 | 2017-03-09 16:02:58 +0400 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | stage('Copy Tempest results to config node') { |
Tomáš Kukrál | 5c2ec13 | 2017-07-26 09:57:27 +0200 | [diff] [blame] | 340 | test.copyTempestResults(saltMaster, TEST_TEMPEST_TARGET) |
Victor Ryzhenkin | 5f3b7e6 | 2017-03-09 16:02:58 +0400 | [diff] [blame] | 341 | } |
| 342 | } |
| 343 | |
Tomáš Kukrál | 53224c2 | 2017-07-26 10:53:20 +0200 | [diff] [blame] | 344 | if (common.checkContains('STACK_INSTALL', 'finalize')) { |
| 345 | stage('Finalize') { |
| 346 | salt.runSaltProcessStep(saltMaster, '*', 'state.apply', [], null, true) |
Tomáš Kukrál | 420d7ff | 2017-03-21 11:38:33 +0100 | [diff] [blame] | 347 | } |
| 348 | } |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 349 | } catch (Throwable e) { |
| 350 | currentBuild.result = 'FAILURE' |
| 351 | throw e |
Tomáš Kukrál | 65fb5fd | 2017-03-02 14:56:49 +0100 | [diff] [blame] | 352 | } finally { |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 353 | |
Tomáš Kukrál | 96b12d5 | 2017-03-07 22:43:37 +0100 | [diff] [blame] | 354 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 355 | // |
| 356 | // Clean |
| 357 | // |
| 358 | |
Tomáš Kukrál | c9a630a | 2017-03-07 17:28:53 +0100 | [diff] [blame] | 359 | if (STACK_TYPE == 'heat') { |
Tomáš Kukrál | 4507c6a | 2017-03-23 19:00:39 +0100 | [diff] [blame] | 360 | // send notification |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 361 | common.sendNotification(currentBuild.result, STACK_NAME, ["slack"]) |
Tomáš Kukrál | 4507c6a | 2017-03-23 19:00:39 +0100 | [diff] [blame] | 362 | |
Jakub Josef | 3c7915f | 2017-05-24 11:23:57 +0200 | [diff] [blame] | 363 | if (STACK_DELETE.toBoolean() == true) { |
Tomáš Kukrál | c9a630a | 2017-03-07 17:28:53 +0100 | [diff] [blame] | 364 | common.errorMsg('Heat job cleanup triggered') |
| 365 | stage('Trigger cleanup job') { |
Tomáš Kukrál | ea07992 | 2017-06-22 09:12:15 +0200 | [diff] [blame] | 366 | build(job: STACK_CLEANUP_JOB, parameters: [ |
| 367 | [$class: 'StringParameterValue', name: 'STACK_NAME', value: STACK_NAME], |
| 368 | [$class: 'StringParameterValue', name: 'STACK_TYPE', value: STACK_TYPE], |
| 369 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_URL', value: OPENSTACK_API_URL], |
| 370 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_CREDENTIALS', value: OPENSTACK_API_CREDENTIALS], |
| 371 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT', value: OPENSTACK_API_PROJECT], |
| 372 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_DOMAIN', value: OPENSTACK_API_PROJECT_DOMAIN], |
| 373 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_PROJECT_ID', value: OPENSTACK_API_PROJECT_ID], |
| 374 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_USER_DOMAIN', value: OPENSTACK_API_USER_DOMAIN], |
| 375 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_CLIENT', value: OPENSTACK_API_CLIENT], |
| 376 | [$class: 'StringParameterValue', name: 'OPENSTACK_API_VERSION', value: OPENSTACK_API_VERSION] |
| 377 | ]) |
Tomáš Kukrál | c9a630a | 2017-03-07 17:28:53 +0100 | [diff] [blame] | 378 | } |
| 379 | } else { |
Tomáš Kukrál | bcc53ea | 2017-03-08 08:15:57 +0100 | [diff] [blame] | 380 | if (currentBuild.result == 'FAILURE') { |
| 381 | common.errorMsg("Deploy job FAILED and was not deleted. Please fix the problem and delete stack on you own.") |
Tomáš Kukrál | c9a630a | 2017-03-07 17:28:53 +0100 | [diff] [blame] | 382 | |
Tomáš Kukrál | bcc53ea | 2017-03-08 08:15:57 +0100 | [diff] [blame] | 383 | if (SALT_MASTER_URL) { |
| 384 | common.errorMsg("Salt master URL: ${SALT_MASTER_URL}") |
| 385 | } |
Tomáš Kukrál | b908dac | 2017-03-07 18:58:35 +0100 | [diff] [blame] | 386 | } |
| 387 | |
Tomáš Kukrál | a18de11 | 2017-03-02 13:57:47 +0100 | [diff] [blame] | 388 | } |
Tomáš Kukrál | 9e0fb73 | 2017-03-02 10:12:05 +0100 | [diff] [blame] | 389 | } |
Tomáš Kukrál | b9957b3 | 2017-02-28 14:49:00 +0100 | [diff] [blame] | 390 | } |
| 391 | } |
| 392 | } |