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