Kailash Khalasi | d4825e5 | 2018-07-11 12:32:25 -0700 | [diff] [blame] | 1 | /*re-deploy node then use mcord-in-a-box.sh to deploy MCORD and then E2E TEST*/ |
| 2 | |
| 3 | pipeline { |
| 4 | |
| 5 | /* no label, executor is determined by JJB */ |
| 6 | agent { |
Zack Williams | b329208 | 2019-10-11 17:15:18 -0700 | [diff] [blame] | 7 | label "${params.buildNode}" |
Kailash Khalasi | d4825e5 | 2018-07-11 12:32:25 -0700 | [diff] [blame] | 8 | } |
| 9 | |
| 10 | stages { |
| 11 | |
| 12 | stage ("Parse deployment configuration file") { |
| 13 | steps { |
| 14 | sh returnStdout: true, script: 'rm -rf ${configRepoBaseDir}' |
| 15 | sh returnStdout: true, script: 'git clone -b ${branch} ${configRepoUrl}' |
| 16 | script { deployment_config = readYaml file: "${configRepoBaseDir}${configRepoFile}" } |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | stage ('Re-Deploy Node') { |
| 21 | steps { |
| 22 | sh "maas login maas http://${deployment_config.maas.ip}/MAAS/api/2.0 ${deployment_config.maas.api_key}" |
| 23 | sh "maas maas machine release ${deployment_config.maas.head_system_id}" |
| 24 | |
| 25 | timeout(time:15) { |
| 26 | waitUntil { |
| 27 | script { |
| 28 | try { |
| 29 | sh "maas maas machine read ${deployment_config.maas.head_system_id} | grep Ready" |
| 30 | return true |
| 31 | } catch (exception) { |
| 32 | return false |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | sh "maas maas machines allocate" |
| 39 | sh "maas maas machine deploy ${deployment_config.maas.head_system_id}" |
| 40 | |
| 41 | timeout(time:15) { |
| 42 | waitUntil { |
| 43 | script { |
| 44 | try { |
| 45 | sh "maas maas machine read ${deployment_config.maas.head_system_id} | grep Deployed" |
| 46 | return true |
| 47 | } catch (exception) { |
| 48 | return false |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | stage ('Get Node IP') { |
| 56 | steps { |
| 57 | sh "maas login maas http://${deployment_config.maas.ip}/MAAS/api/2.0 ${deployment_config.maas.api_key}" |
| 58 | timeout(time:15) { |
| 59 | waitUntil { |
| 60 | script { |
| 61 | try { |
| 62 | node_ip = sh (script: "maas maas machine read ${deployment_config.maas.head_system_id} | grep ip_address | head -n1 | grep -oE '\\b([0-9]{1,3}\\.){3}[0-9]{1,3}\\b'", returnStdout: true).toString().trim() |
| 63 | return true |
| 64 | } catch (exception) { |
| 65 | return false |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | sh "echo ${node_ip}" |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | stage ('Checkout Automation-Tools Repo') { |
| 75 | steps { |
| 76 | script { |
| 77 | sh (script: "ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'mkdir ~/cord; cd ~/cord/; git clone https://gerrit.opencord.org/automation-tools'", returnStdout: true) |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | stage ('Install MCORD') { |
| 83 | options { |
| 84 | timeout(time: 3, unit: 'HOURS') |
| 85 | } |
| 86 | steps { |
| 87 | script { |
| 88 | sh "sleep 120" |
| 89 | sh "ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'cd ~/cord/; ./automation-tools/mcord/mcord-in-a-box.sh 1>&2'" |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | stage ('Configure K8 Compute Node DNS') { |
| 95 | steps { |
| 96 | sh """ |
| 97 | COMPUTEHOSTNAME=\$(ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'cat /etc/hostname') |
| 98 | IPADDRESS=\$(ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} "ip route get 8.8.8.8 | head -1 | cut -d' ' -f8") |
| 99 | cat <<EOF > /tmp/\$COMPUTEHOSTNAME-dns.yaml |
| 100 | kind: Service |
| 101 | apiVersion: v1 |
| 102 | metadata: |
| 103 | name: \$COMPUTEHOSTNAME |
| 104 | namespace: default |
| 105 | spec: |
| 106 | type: ExternalName |
| 107 | externalName: \$IPADDRESS |
| 108 | EOF |
| 109 | cat /tmp/\$COMPUTEHOSTNAME-dns.yaml | ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} "cat > /tmp/\$COMPUTEHOSTNAME-dns.yaml" |
| 110 | ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} "kubectl create -f /tmp/\$COMPUTEHOSTNAME-dns.yaml 1>&2" |
| 111 | """ |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | stage ('Test MCORD') { |
| 116 | steps { |
| 117 | script { |
| 118 | sh "ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'cd ~/cord/; git clone https://gerrit.opencord.org/mcord; cd mcord/test; ansible-playbook -i localhost, -c local mcord-cavium-test-playbook.yml 1>&2'" |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | } |
| 124 | |
| 125 | post { |
| 126 | always { |
| 127 | script { |
Kailash Khalasi | fa36bcc | 2018-07-11 12:45:43 -0700 | [diff] [blame] | 128 | sh (script: "ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'helm ls 1>&2'", returnStdout: true) |
| 129 | sh (script: "ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'kubectl get pods --all-namespaces 1>&2'", returnStdout: true) |
| 130 | sh (script: "ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'export OS_CLOUD=openstack_helm; openstack image list 1>&2'", returnStdout: true) |
| 131 | sh (script: "ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'export OS_CLOUD=openstack_helm; openstack network list 1>&2'", returnStdout: true) |
| 132 | sh (script: "ssh -oStrictHostKeyChecking=no -i ~/.ssh/cord ubuntu@${node_ip} 'export OS_CLOUD=openstack_helm; openstack server list --all-projects 1>&2'", returnStdout: true) |
| 133 | |
Kailash Khalasi | d4825e5 | 2018-07-11 12:32:25 -0700 | [diff] [blame] | 134 | } |
| 135 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false]) |
| 136 | } |
| 137 | } |
| 138 | } |