alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 1 | node ('build') { |
alshabib | a5d3a61 | 2016-09-09 11:02:05 -0700 | [diff] [blame] | 2 | stage 'Checkout cord repo' |
| 3 | checkout changelog: false, poll: false, scm: [$class: 'RepoScm', currentBranch: true, manifestRepositoryUrl: 'https://gerrit.opencord.org/manifest', quiet: true] |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 4 | dir('build') { |
alshabib | ef06994 | 2016-09-09 17:08:36 -0700 | [diff] [blame] | 5 | stage 'Redeploy head node and Build Vagrant box' |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 6 | try { |
alshabib | 4e1c96e | 2016-09-28 16:26:24 -0700 | [diff] [blame] | 7 | parallel( |
alshabib | ef06994 | 2016-09-09 17:08:36 -0700 | [diff] [blame] | 8 | maasOps: { |
| 9 | sh "maas login maas http://10.90.0.2/MAAS/api/2.0 ${apiKey}" |
| 10 | sh "maas maas machine release ${systemId}" |
alshabib | 4e1c96e | 2016-09-28 16:26:24 -0700 | [diff] [blame] | 11 | |
alshabib | ef06994 | 2016-09-09 17:08:36 -0700 | [diff] [blame] | 12 | timeout(time: 15) { |
| 13 | waitUntil { |
| 14 | try { |
| 15 | sh "maas maas machine read ${systemId} | grep Ready" |
| 16 | return true |
| 17 | } catch (exception) { |
| 18 | return false |
| 19 | } |
| 20 | } |
| 21 | } |
alshabib | 4e1c96e | 2016-09-28 16:26:24 -0700 | [diff] [blame] | 22 | |
alshabib | ef06994 | 2016-09-09 17:08:36 -0700 | [diff] [blame] | 23 | sh 'maas maas machines allocate' |
| 24 | sh "maas maas machine deploy ${systemId}" |
alshabib | 4e1c96e | 2016-09-28 16:26:24 -0700 | [diff] [blame] | 25 | |
alshabib | ef06994 | 2016-09-09 17:08:36 -0700 | [diff] [blame] | 26 | timeout(time: 30) { |
| 27 | waitUntil { |
| 28 | try { |
| 29 | sh "maas maas machine read ${systemId} | grep Deployed" |
| 30 | return true |
| 31 | } catch (exception) { |
| 32 | return false |
| 33 | } |
| 34 | } |
| 35 | } |
alshabib | 4e1c96e | 2016-09-28 16:26:24 -0700 | [diff] [blame] | 36 | |
alshabib | ef06994 | 2016-09-09 17:08:36 -0700 | [diff] [blame] | 37 | }, vagrantOps: { |
| 38 | sh 'vagrant up corddev' |
| 39 | }, failFast : true |
| 40 | ) |
alshabib | 4e1c96e | 2016-09-28 16:26:24 -0700 | [diff] [blame] | 41 | |
alshabib | ef06994 | 2016-09-09 17:08:36 -0700 | [diff] [blame] | 42 | stage 'Fetch CORD packages' |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 43 | sh 'vagrant ssh -c "cd /cord/build; ./gradlew fetch" corddev' |
alshabib | 4e1c96e | 2016-09-28 16:26:24 -0700 | [diff] [blame] | 44 | |
alshabib | ef06994 | 2016-09-09 17:08:36 -0700 | [diff] [blame] | 45 | stage 'Build CORD Images' |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 46 | sh 'vagrant ssh -c "cd /cord/build; ./gradlew buildImages" corddev' |
alshabib | 61509fb | 2016-09-09 02:43:20 -0700 | [diff] [blame] | 47 | |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 48 | stage 'Publish to headnode' |
| 49 | sh 'vagrant ssh -c "cd /cord/build; ./gradlew -PtargetReg=10.90.0.251:5000 -PdeployConfig=config/onlab_develop_pod.yml publish" corddev' |
alshabib | 61509fb | 2016-09-09 02:43:20 -0700 | [diff] [blame] | 50 | |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 51 | stage 'Deploy' |
| 52 | sh 'vagrant ssh -c "cd /cord/build; ./gradlew -PtargetReg=10.90.0.251:5000 -PdeployConfig=config/onlab_develop_pod.yml deploy" corddev' |
alshabib | 4e1c96e | 2016-09-28 16:26:24 -0700 | [diff] [blame] | 53 | |
alshabib | 7f3be8d | 2016-09-27 18:04:56 -0700 | [diff] [blame] | 54 | stage 'Power cycle compute nodes' |
| 55 | parallel( |
| 56 | compute_1: { |
alshabib | 6bbce23 | 2016-09-27 21:53:06 -0700 | [diff] [blame] | 57 | sh 'ipmitool -U admin -P admin -H 10.90.0.10 power cycle' |
alshabib | 7f3be8d | 2016-09-27 18:04:56 -0700 | [diff] [blame] | 58 | }, compute_2: { |
alshabib | 6bbce23 | 2016-09-27 21:53:06 -0700 | [diff] [blame] | 59 | sh 'ipmitool -U admin -P admin -H 10.90.0.11 power cycle' |
| 60 | }, failFast : true |
alshabib | 7f3be8d | 2016-09-27 18:04:56 -0700 | [diff] [blame] | 61 | ) |
| 62 | |
| 63 | stage 'Wait for compute nodes to get deployed' |
alshabib | 6bbce23 | 2016-09-27 21:53:06 -0700 | [diff] [blame] | 64 | sh 'ssh-keygen -f "/home/ubuntu/.ssh/known_hosts" -R 10.90.0.251' |
| 65 | def cordapikey = sh(returnStdout: true, script: "sshpass -p ${headnodepass} ssh -oStrictHostKeyChecking=no -l ${headnodeuser} 10.90.0.251 sudo maas-region-admin apikey --username cord") |
| 66 | sh "sshpass -p ${headnodepass} ssh -oStrictHostKeyChecking=no -l ${headnodeuser} 10.90.0.251 maas login pod-maas http://10.90.0.251/MAAS/api/1.0 $cordapikey" |
alshabib | 4e1c96e | 2016-09-28 16:26:24 -0700 | [diff] [blame] | 67 | timeout(time: 45) { |
alshabib | 7f3be8d | 2016-09-27 18:04:56 -0700 | [diff] [blame] | 68 | waitUntil { |
| 69 | try { |
alshabib | 4e1c96e | 2016-09-28 16:26:24 -0700 | [diff] [blame] | 70 | num = sh(returnStdout: true, script: "sshpass -p ${headnodepass} ssh -l ${headnodeuser} 10.90.0.251 maas pod-maas nodes list | grep Deployed | wc -l").trim() |
| 71 | return num == '2' |
| 72 | } catch (exception) { |
| 73 | return false |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | stage 'Wait for computes nodes to be provisioned' |
| 79 | ip = sh (returnStdout: true, script:"sshpass -p ${headnodepass} ssh -oStrictHostKeyChecking=no -l ${headnodeuser} 10.90.0.251 docker inspect --format '{{.NetworkSettings.Networks.maas_default.IPAddress}}' provisioner").trim() |
| 80 | timeout(time:45) { |
| 81 | waitUntil { |
| 82 | try { |
alshabib | 0c9e663 | 2016-09-28 21:37:15 -0700 | [diff] [blame] | 83 | out = sh (returnStdout: true, script:"sshpass -p ${headnodepass} ssh -oStrictHostKeyChecking=no -l ${headnodeuser} 10.90.0.251 curl -sS http://$ip:4243/provision/ | jq -c '.[] | select(.status | contains(2))'").trim() |
alshabib | 4e1c96e | 2016-09-28 16:26:24 -0700 | [diff] [blame] | 84 | return out != "" |
alshabib | 7f3be8d | 2016-09-27 18:04:56 -0700 | [diff] [blame] | 85 | } catch (exception) { |
| 86 | return false |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 91 | currentBuild.result = 'SUCCESS' |
| 92 | } catch (err) { |
| 93 | currentBuild.result = 'FAILURE' |
alshabib | 81048bd | 2016-09-09 18:08:07 -0700 | [diff] [blame] | 94 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'cord-dev@opencord.org', sendToIndividuals: false]) |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 95 | } finally { |
| 96 | sh 'vagrant destroy -f corddev' |
| 97 | } |
| 98 | echo "RESULT: ${currentBuild.result}" |
| 99 | } |
alshabib | 61509fb | 2016-09-09 02:43:20 -0700 | [diff] [blame] | 100 | |
alshabib | 152823c | 2016-09-07 23:49:12 -0700 | [diff] [blame] | 101 | } |