Kailash Khalasi | 479a947 | 2018-11-12 13:39:13 -0800 | [diff] [blame] | 1 | // Copyright 2017-present Open Networking Foundation |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | node ("${TestNodeName}") { |
| 16 | timeout (100) { |
| 17 | stage ("Parse deployment configuration file") { |
| 18 | sh returnStdout: true, script: "rm -rf ${configBaseDir}" |
| 19 | sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}" |
Kailash | db56481 | 2018-11-13 09:20:02 -0800 | [diff] [blame] | 20 | deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yml" |
Kailash Khalasi | 479a947 | 2018-11-12 13:39:13 -0800 | [diff] [blame] | 21 | } |
Kailash | c8f7841 | 2018-11-13 14:44:13 -0800 | [diff] [blame] | 22 | stage('Clean up') { |
| 23 | timeout(10) { |
| 24 | sh returnStdout: true, script: """ |
| 25 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf |
| 26 | for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet'); |
| 27 | do |
| 28 | echo "Purging chart: \${hchart}" |
| 29 | helm delete --purge "\${hchart}" |
| 30 | done |
| 31 | """ |
| 32 | timeout(5) { |
| 33 | waitUntil { |
| 34 | helm_deleted = sh returnStdout: true, script: """ |
| 35 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 36 | helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l |
| 37 | """ |
| 38 | return helm_deleted.toInteger() == 0 |
| 39 | } |
| 40 | } |
| 41 | timeout(5) { |
| 42 | waitUntil { |
| 43 | kubectl_deleted = sh returnStdout: true, script: """ |
| 44 | export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf && |
| 45 | kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l |
| 46 | """ |
| 47 | return kubectl_deleted.toInteger() == 0 |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | } |
Kailash Khalasi | 479a947 | 2018-11-12 13:39:13 -0800 | [diff] [blame] | 52 | stage('Restart Fabric Switch processes') { |
| 53 | for(int i=0; i < deployment_config.fabric_switches.size(); i++) { |
| 54 | timeout(5) { |
| 55 | sh returnStdout: true, script: """ |
| 56 | ssh-keyscan -H ${deployment_config.fabric_switches[i].ip} >> ~/.ssh/known_hosts |
You Wang | 462c5b4 | 2018-11-28 16:50:07 -0800 | [diff] [blame] | 57 | sshpass -p ${deployment_config.fabric_switches[i].pass} ssh -l ${deployment_config.fabric_switches[i].user} ${deployment_config.fabric_switches[i].ip} 'sudo reboot' || true |
Kailash Khalasi | 479a947 | 2018-11-12 13:39:13 -0800 | [diff] [blame] | 58 | """ |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |