blob: 8d40265a59608238a710d9e232b42f281ea5e562 [file] [log] [blame]
Tomáš Kukrálb9957b32017-02-28 14:49:00 +01001/**
2 *
3 * Launch heat stack with basic k8s
4 * Flow parameters:
5 * STACK_TYPE Orchestration engine: heat, ''
6 * INSTALL What should be installed (k8s, openstack, ...)
Tomáš Kukrál55357d02017-02-28 22:56:45 +01007 * TEST What should be tested (k8s, openstack, ...)
Tomáš Kukrálb9957b32017-02-28 14:49:00 +01008 *
9 * Expected parameters:
10 *
11 * required for STACK_TYPE=heat
12 * HEAT_TEMPLATE_URL URL to git repo with Heat templates
13 * HEAT_TEMPLATE_CREDENTIALS Credentials to the Heat templates repo
14 * HEAT_TEMPLATE_BRANCH Heat templates repo branch
15 * HEAT_STACK_TEMPLATE Heat stack HOT template
16 * HEAT_STACK_ENVIRONMENT Heat stack environmental parameters
17 * HEAT_STACK_ZONE Heat stack availability zone
18 * HEAT_STACK_PUBLIC_NET Heat stack floating IP pool
19 * HEAT_STACK_DELETE Delete Heat stack when finished (bool)
20 * HEAT_STACK_CLEANUP_JOB Name of job for deleting Heat stack
21 * HEAT_STACK_REUSE Reuse Heat stack (don't create one)
22 * OPENSTACK_API_URL OpenStack API address
23 * OPENSTACK_API_CREDENTIALS Credentials to the OpenStack API
24 * OPENSTACK_API_PROJECT OpenStack project to connect to
25 * OPENSTACK_API_CLIENT Versions of OpenStack python clients
26 * OPENSTACK_API_VERSION Version of the OpenStack API (2/3)
27 *
28 * SALT_MASTER_CREDENTIALS Credentials to the Salt API
29 *
30 * required for STACK_TYPE=NONE or empty string
31 * SALT_MASTER_URL URL of Salt-API
32
33 * K8S_API_SERVER Kubernetes API address
34 * K8S_CONFORMANCE_IMAGE Path to docker image with conformance e2e tests
35 *
36 */
37
38git = new com.mirantis.mk.Git()
39openstack = new com.mirantis.mk.Openstack()
40salt = new com.mirantis.mk.Salt()
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010041
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010042timestamps {
43 node {
Tomáš Kukrála18de112017-03-02 13:57:47 +010044 try {
45 //
46 // Prepare machines
47 //
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010048
Tomáš Kukrála18de112017-03-02 13:57:47 +010049 stage ('Create infrastructure') {
50 if (STACK_TYPE == 'heat') {
51 // value defaults
52 def openstackCloud
53 def openstackVersion = OPENSTACK_API_CLIENT ? OPENSTACK_API_CLIENT : 'liberty'
54 def openstackEnv = "${env.WORKSPACE}/venv"
Tomáš Kukrálb9957b32017-02-28 14:49:00 +010055
Tomáš Kukrála18de112017-03-02 13:57:47 +010056 if (HEAT_STACK_NAME == '') {
57 HEAT_STACK_NAME = BUILD_TAG
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010058 }
Tomáš Kukrála18de112017-03-02 13:57:47 +010059
Tomáš Kukrálcbabec42017-03-02 16:24:04 +010060 // set description
61 currentBuild.description = "stack: ${HEAT_STACK_NAME}"
62
Tomáš Kukrála18de112017-03-02 13:57:47 +010063 // get templates
64 git.checkoutGitRepository('template', HEAT_TEMPLATE_URL, HEAT_TEMPLATE_BRANCH, HEAT_TEMPLATE_CREDENTIALS)
65
66 // create openstack env
67 openstack.setupOpenstackVirtualenv(openstackEnv, openstackVersion)
68 openstackCloud = openstack.createOpenstackEnv(OPENSTACK_API_URL, OPENSTACK_API_CREDENTIALS, OPENSTACK_API_PROJECT)
69 openstack.getKeystoneToken(openstackCloud, openstackEnv)
70
71 // launch stack
72 if (HEAT_STACK_REUSE == 'false') {
73 stage('Launch new Heat stack') {
74 // create stack
75 envParams = [
76 'instance_zone': HEAT_STACK_ZONE,
77 'public_net': HEAT_STACK_PUBLIC_NET
78 ]
79 openstack.createHeatStack(openstackCloud, HEAT_STACK_NAME, HEAT_STACK_TEMPLATE, envParams, HEAT_STACK_ENVIRONMENT, openstackEnv)
80 }
81 }
82
83 // get SALT_MASTER_URL
84 saltMasterHost = openstack.getHeatStackOutputParam(openstackCloud, HEAT_STACK_NAME, 'salt_master_ip', openstackEnv)
85 SALT_MASTER_URL = "http://${saltMasterHost}:8088"
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010086 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010087 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010088
Tomáš Kukrála18de112017-03-02 13:57:47 +010089 //
90 // Connect to Salt master
91 //
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010092
Tomáš Kukrála18de112017-03-02 13:57:47 +010093 def saltMaster
94 stage('Connect to Salt API') {
95 saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
96 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +010097
Tomáš Kukrála18de112017-03-02 13:57:47 +010098 //
99 // Install
100 //
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100101
Tomáš Kukrála18de112017-03-02 13:57:47 +0100102 if (INSTALL.toLowerCase().contains('core')) {
103 stage('Install core infrastructure') {
104 // salt.master, reclass
105 // refresh_pillar
106 // sync_all
107 // linux,openssh,salt.minion.ntp
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100108
Tomáš Kukrála18de112017-03-02 13:57:47 +0100109 //orchestrate.installFoundationInfra(saltMaster)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100110 salt.enforceState(saltMaster, 'I@salt:master', ['salt.master', 'reclass'], true)
111 salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.refresh_pillar', null, true)
112 salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.sync_all', null, true)
113 salt.enforceState(saltMaster, 'I@linux:system', ['linux', 'openssh', 'salt.minion', 'ntp'], true)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100114
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100115
Tomáš Kukrála18de112017-03-02 13:57:47 +0100116 if (INSTALL.toLowerCase().contains('kvm')) {
117 //orchestrate.installInfraKvm(saltMaster)
118 salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.refresh_pillar')
119 salt.runSaltProcessStep(saltMaster, 'I@linux:system', 'saltutil.sync_all')
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100120
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100121 salt.enforceState(saltMaster, 'I@salt:control', ['salt.minion', 'linux.system', 'linux.network', 'ntp'], true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100122 salt.enforceState(saltMaster, 'I@salt:control', 'libvirt', true)
123 salt.enforceState(saltMaster, 'I@salt:control', 'salt.control', true)
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100124
Tomáš Kukrála18de112017-03-02 13:57:47 +0100125 sleep(300)
126
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100127 salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'saltutil.refresh_pillar', null, true)
128 salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'saltutil.sync_all', null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100129
130 // workaround - install apt-transport-https
131 salt.runSaltProcessStep(saltMaster, '* and not kvm*', 'pkg.install', ['apt-transport-https refresh=True'])
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100132 salt.enforceState(saltMaster, 'I@linux:system', ['linux', 'openssh', 'salt.minion', 'ntp'], true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100133 }
134
135 //orchestrate.validateFoundationInfra(saltMaster)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100136 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'cmd.run', ['salt-key'], null, true)
137 salt.runSaltProcessStep(saltMaster, 'I@salt:minion', 'test.version', null, true)
138 salt.runSaltProcessStep(saltMaster, 'I@salt:master', 'cmd.run', ['reclass-salt --top'], null, true)
139 salt.runSaltProcessStep(saltMaster, 'I@reclass:storage', 'reclass.inventory', null, true)
140 salt.runSaltProcessStep(saltMaster, 'I@salt:minion', 'state.show_top', null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100141 }
142 }
143
144 // install k8s
145 if (INSTALL.toLowerCase().contains('k8s')) {
146 stage('Install Kubernetes infra') {
147 //orchestrate.installOpenstackMcpInfra(saltMaster)
148
149 // Comment nameserver
150 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'cmd.run', ["sed -i 's/nameserver 10.254.0.10/#nameserver 10.254.0.10/g' /etc/resolv.conf"])
151
152 // Install glusterfs
153 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.service'])
154
155 // Install keepalived
156 salt.runSaltProcessStep(saltMaster, 'ctl01*', 'state.sls', ['keepalived'])
157 salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'state.sls', ['keepalived'])
158
159 // Check the keepalived VIPs
160 salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
161
162 // Setup glusterfs
163 salt.runSaltProcessStep(saltMaster, 'ctl01*', 'state.sls', ['glusterfs.server.setup'])
164 salt.runSaltProcessStep(saltMaster, 'ctl02*', 'state.sls', ['glusterfs.server.setup'])
165 salt.runSaltProcessStep(saltMaster, 'ctl03*', 'state.sls', ['glusterfs.server.setup'])
166 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'])
167 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'])
168
169 // Install haproxy
170 salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'state.sls', ['haproxy'])
171 salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.status', ['haproxy'])
172
173 // Install docker
174 salt.runSaltProcessStep(saltMaster, 'I@docker:host', 'state.sls', ['docker.host'])
175 salt.runSaltProcessStep(saltMaster, 'I@docker:host', 'cmd.run', ['docker ps'])
176
177 // Install bird
178 salt.runSaltProcessStep(saltMaster, 'I@bird:server', 'state.sls', ['bird'])
179
180 // Install etcd
181 salt.runSaltProcessStep(saltMaster, 'I@etcd:server', 'state.sls', ['etcd.server.service'])
182 salt.runSaltProcessStep(saltMaster, 'I@etcd:server', 'cmd.run', ['etcdctl cluster-health'])
183
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100184 }
185
Tomáš Kukrála18de112017-03-02 13:57:47 +0100186 stage('Install Kubernetes control') {
187 //orchestrate.installOpenstackMcpControl(saltMaster)
Tomáš Kukrál06c27a92017-03-01 16:21:46 +0100188
Tomáš Kukrála18de112017-03-02 13:57:47 +0100189 // Install Kubernetes pool and Calico
190 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'state.sls', ['kubernetes.pool'])
191 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'cmd.run', ['calicoctl node status'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100192
Tomáš Kukrála18de112017-03-02 13:57:47 +0100193 // Setup etcd server
194 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'state.sls', ['etcd.server.setup'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100195
Tomáš Kukrála18de112017-03-02 13:57:47 +0100196 // Run k8s without master.setup
197 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'state.sls', ['kubernetes', 'exclude=kubernetes.master.setup'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100198
Tomáš Kukrála18de112017-03-02 13:57:47 +0100199 // Run k8s master setup
200 salt.runSaltProcessStep(saltMaster, 'ctl01*', 'state.sls', ['kubernetes.master.setup'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100201
Tomáš Kukrála18de112017-03-02 13:57:47 +0100202 // Revert comment nameserver
203 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:master', 'cmd.run', ["sed -i 's/nameserver 10.254.0.10/#nameserver 10.254.0.10/g' /etc/resolv.conf"])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100204
Tomáš Kukrála18de112017-03-02 13:57:47 +0100205 // Set route
206 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'cmd.run', ['ip r a 10.254.0.0/16 dev ens4'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100207
Tomáš Kukrála18de112017-03-02 13:57:47 +0100208 // Restart kubelet
209 salt.runSaltProcessStep(saltMaster, 'I@kubernetes:pool', 'service.restart', ['kubelet'])
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100210 }
211
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100212 }
213
Tomáš Kukrála18de112017-03-02 13:57:47 +0100214 // install openstack
215 if (INSTALL.toLowerCase().contains('openstack')) {
216 // install Infra and control, tests, ...
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100217
Tomáš Kukrála18de112017-03-02 13:57:47 +0100218 stage('Install OpenStack infra') {
219 //orchestrate.installOpenstackMkInfra(saltMaster, physical)
220
221 // Install keepaliveds
222 //runSaltProcessStep(master, 'I@keepalived:cluster', 'state.sls', ['keepalived'], 1)
223 salt.enforceState(saltMaster, 'ctl01*', 'keepalived', true)
224 salt.enforceState(saltMaster, 'I@keepalived:cluster', 'keepalived', true)
225
226 // Check the keepalived VIPs
227 salt.runSaltProcessStep(saltMaster, 'I@keepalived:cluster', 'cmd.run', ['ip a | grep 172.16.10.2'])
228
229 // Install glusterfs
230 salt.enforceState(saltMaster, 'I@glusterfs:server', 'glusterfs.server.service', true)
231
232 //runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'state.sls', ['glusterfs.server.setup'], 1)
233 if (INSTALL.toLowerCase().contains('kvm')) {
Tomáš Kukrála18de112017-03-02 13:57:47 +0100234 salt.enforceState(saltMaster, 'kvm01*', 'glusterfs.server.setup', true)
235 salt.enforceState(saltMaster, 'kvm02*', 'glusterfs.server.setup', true)
236 salt.enforceState(saltMaster, 'kvm03*', 'glusterfs.server.setup', true)
Tomáš Kukrálbad54bb2017-03-02 15:46:20 +0100237 } else {
238 salt.enforceState(saltMaster, 'ctl01*', 'glusterfs.server.setup', true)
239 salt.enforceState(saltMaster, 'ctl02*', 'glusterfs.server.setup', true)
240 salt.enforceState(saltMaster, 'ctl03*', 'glusterfs.server.setup', true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100241 }
242
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100243 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster peer status'], null, true)
244 salt.runSaltProcessStep(saltMaster, 'I@glusterfs:server', 'cmd.run', ['gluster volume status'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100245
246 // Install rabbitmq
247 salt.enforceState(saltMaster, 'I@rabbitmq:server', 'rabbitmq', true)
248
249 // Check the rabbitmq status
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100250 salt.runSaltProcessStep(saltMaster, 'I@rabbitmq:server', 'cmd.run', ['rabbitmqctl cluster_status'], null, ture)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100251
252 // Install galera
253 salt.enforceState(saltMaster, 'I@galera:master', 'galera', true)
254 salt.enforceState(saltMaster, 'I@galera:slave', 'galera', true)
255
256 // Check galera status
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100257 salt.runSaltProcessStep(saltMaster, 'I@galera:master', 'mysql.status', null, true)
258 salt.runSaltProcessStep(saltMaster, 'I@galera:slave', 'mysql.status', null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100259
260 // Install haproxy
261 salt.enforceState(saltMaster, 'I@haproxy:proxy', 'haproxy', true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100262 salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.status', ['haproxy'], null, true)
263 salt.runSaltProcessStep(saltMaster, 'I@haproxy:proxy', 'service.restart', ['rsyslog'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100264
265 // Install memcached
266 salt.enforceState(saltMaster, 'I@memcached:server', 'memcached', true)
267
Tomáš Kukrálc265e352017-03-02 11:45:11 +0100268 }
269
Tomáš Kukrála18de112017-03-02 13:57:47 +0100270 stage('Install OpenStack control') {
271 //orchestrate.installOpenstackMkControl(saltMaster)
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100272
Tomáš Kukrála18de112017-03-02 13:57:47 +0100273 // setup keystone service
274 //runSaltProcessStep(saltMaster, 'I@keystone:server', 'state.sls', ['keystone.server'], 1)
275 salt.enforceState(saltMaster, 'ctl01*', 'keystone.server', true)
276 salt.enforceState(saltMaster, 'I@keystone:server', 'keystone.server', true)
277 // populate keystone services/tenants/roles/users
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100278
Tomáš Kukrála18de112017-03-02 13:57:47 +0100279 // keystone:client must be called locally
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100280 salt.runSaltProcessStep(saltMaster, 'I@keystone:client', 'cmd.run', ['salt-call state.sls keystone.client'], null, true)
281 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; keystone service-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100282
283 // Install glance and ensure glusterfs clusters
284 //runSaltProcessStep(saltMaster, 'I@glance:server', 'state.sls', ['glance.server'], 1)
285 salt.enforceState(saltMaster, 'ctl01*', 'glance.server', true)
286 salt.enforceState(saltMaster, 'I@glance:server', 'glance.server', true)
287 salt.enforceState(saltMaster, 'I@glance:server', 'glusterfs.client', true)
288
289 // Update fernet tokens before doing request on keystone server
290 salt.enforceState(saltMaster, 'I@keystone:server', 'keystone.server', true)
291
292 // Check glance service
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100293 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; glance image-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100294
295 // Install and check nova service
296 //runSaltProcessStep(saltMaster, 'I@nova:controller', 'state.sls', ['nova'], 1)
297 salt.enforceState(saltMaster, 'ctl01*', 'nova', true)
298 salt.enforceState(saltMaster, 'I@nova:controller', 'nova', true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100299 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova service-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100300
301 // Install and check cinder service
302 //runSaltProcessStep(saltMaster, 'I@cinder:controller', 'state.sls', ['cinder'], 1)
303 salt.enforceState(saltMaster, 'ctl01*', 'cinder', true)
304 salt.enforceState(saltMaster, 'I@cinder:controller', 'cinder', true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100305 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; cinder list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100306
307 // Install neutron service
308 //runSaltProcessStep(saltMaster, 'I@neutron:server', 'state.sls', ['neutron'], 1)
309 salt.enforceState(saltMaster, 'ctl01*', 'neutron', true)
310 salt.enforceState(saltMaster, 'I@neutron:server', 'neutron', true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100311 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron agent-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100312
313 // Install heat service
314 //runSaltProcessStep(saltMaster, 'I@heat:server', 'state.sls', ['heat'], 1)
315 salt.enforceState(saltMaster, 'ctl01*', 'heat', true)
316 salt.enforceState(saltMaster, 'I@heat:server', 'heat', true)
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100317 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; heat resource-type-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100318
319 // Install horizon dashboard
320 salt.enforceState(saltMaster, 'I@horizon:server', 'horizon', true)
321 salt.enforceState(saltMaster, 'I@nginx:server', 'nginx', true)
322
323 }
324
325 stage('Install OpenStack network') {
326 //orchestrate.installOpenstackMkNetwork(saltMaster, physical)
327
328 // Install opencontrail database services
329 //runSaltProcessStep(saltMaster, 'I@opencontrail:database', 'state.sls', ['opencontrail.database'], 1)
330 salt.enforceState(saltMaster, 'ntw01*', 'opencontrail.database', true)
331 salt.enforceState(saltMaster, 'I@opencontrail:database', 'opencontrail.database', true)
332
333 // Install opencontrail control services
334 //runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'state.sls', ['opencontrail'], 1)
335 salt.enforceState(saltMaster, 'ntw01*', 'opencontrail', true)
336 salt.enforceState(saltMaster, 'I@opencontrail:control', 'opencontrail', true)
337
338 // Provision opencontrail control services
339 if (INSTALL.toLowerCase().contains('kvm')) {
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100340 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 172.16.10.254 --api_server_port 8082 --host_name ctl01 --host_ip 172.16.10.101 --router_asn 64512 --admin_password workshop --admin_user admin --admin_tenant_name admin --oper add'], null, true)
341 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 172.16.10.254 --api_server_port 8082 --host_name ctl02 --host_ip 172.16.10.102 --router_asn 64512 --admin_password workshop --admin_user admin --admin_tenant_name admin --oper add'], null, true)
342 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_control.py --api_server_ip 172.16.10.254 --api_server_port 8082 --host_name ctl03 --host_ip 172.16.10.103 --router_asn 64512 --admin_password workshop --admin_user admin --admin_tenant_name admin --oper add'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100343 }
344
345 // Test opencontrail
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100346 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control', 'cmd.run', ['contrail-status'], null, true)
347 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; neutron net-list'], null, true)
348 salt.runSaltProcessStep(saltMaster, 'I@keystone:server', 'cmd.run', ['. /root/keystonerc; nova net-list'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100349 }
350
351 stage('Install OpenStack compute') {
352 //orchestrate.installOpenstackMkCompute(saltMaster, physical)
353 // Configure compute nodes
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100354 salt.runSaltProcessStep(saltMaster, 'I@nova:compute', 'state.apply', null, true)
355 salt.runSaltProcessStep(saltMaster, 'I@nova:compute', 'state.apply', null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100356
357 // Provision opencontrail virtual routers
358 if (INSTALL.toLowerCase().contains('kvm')) {
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100359 salt.runSaltProcessStep(saltMaster, 'I@opencontrail:control:id:1', 'cmd.run', ['/usr/share/contrail-utils/provision_vrouter.py --host_name cmp01 --host_ip 172.16.10.105 --api_server_ip 172.16.10.254 --oper add --admin_user admin --admin_password workshop --admin_tenant_name admin'], null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100360 }
361
Tomáš Kukrálcbdb1d02017-03-02 16:08:51 +0100362 salt.runSaltProcessStep(saltMaster, 'I@nova:compute', 'system.reboot', null, true)
Tomáš Kukrála18de112017-03-02 13:57:47 +0100363 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100364 }
365
Tomáš Kukrála18de112017-03-02 13:57:47 +0100366 //
367 // Test
368 //
369
370 if (TEST.toLowerCase().contains('k8s')) {
371 stage('Run k8s bootstrap tests') {
372 orchestrate.runConformanceTests(saltMaster, K8S_API_SERVER, 'tomkukral/k8s-scripts')
373 }
374
375 stage('Run k8s conformance e2e tests') {
376 orchestrate.runConformanceTests(saltMaster, K8S_API_SERVER, K8S_CONFORMANCE_IMAGE)
377 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100378 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100379
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100380
Tomáš Kukrála18de112017-03-02 13:57:47 +0100381 } catch (Throwable e) {
382 currentBuild.result = 'FAILURE'
383 throw e
Tomáš Kukrál65fb5fd2017-03-02 14:56:49 +0100384 } finally {
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100385
Tomáš Kukrála18de112017-03-02 13:57:47 +0100386 //
387 // Clean
388 //
389
390 if (HEAT_STACK_DELETE == 'true' && STACK_TYPE == 'heat') {
391 stage('Trigger cleanup job') {
392 build job: 'deploy_heat_cleanup', parameters: [[$class: 'StringParameterValue', name: 'HEAT_STACK_NAME', value: HEAT_STACK_NAME]]
393 }
Tomáš Kukrál9e0fb732017-03-02 10:12:05 +0100394 }
Tomáš Kukrálb9957b32017-02-28 14:49:00 +0100395 }
396 }
397}