blob: 8e3dff76ad180774b68b09d5312d93b59828d926 [file] [log] [blame]
Kailash Khalasi479a9472018-11-12 13:39:13 -08001// 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
15node ("${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}"
Kailashdb564812018-11-13 09:20:02 -080020 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yml"
Kailash Khalasi479a9472018-11-12 13:39:13 -080021 }
Kailashc8f78412018-11-13 14:44:13 -080022 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 Khalasi479a9472018-11-12 13:39:13 -080052 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 Wang462c5b42018-11-28 16:50:07 -080057 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 Khalasi479a9472018-11-12 13:39:13 -080058 """
59 }
60 }
61 }
62 }
63}
64