blob: 8e3dff76ad180774b68b09d5312d93b59828d926 [file] [log] [blame]
// Copyright 2017-present Open Networking Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
node ("${TestNodeName}") {
timeout (100) {
stage ("Parse deployment configuration file") {
sh returnStdout: true, script: "rm -rf ${configBaseDir}"
sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yml"
}
stage('Clean up') {
timeout(10) {
sh returnStdout: true, script: """
export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
do
echo "Purging chart: \${hchart}"
helm delete --purge "\${hchart}"
done
"""
timeout(5) {
waitUntil {
helm_deleted = sh returnStdout: true, script: """
export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
"""
return helm_deleted.toInteger() == 0
}
}
timeout(5) {
waitUntil {
kubectl_deleted = sh returnStdout: true, script: """
export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
"""
return kubectl_deleted.toInteger() == 0
}
}
}
}
stage('Restart Fabric Switch processes') {
for(int i=0; i < deployment_config.fabric_switches.size(); i++) {
timeout(5) {
sh returnStdout: true, script: """
ssh-keyscan -H ${deployment_config.fabric_switches[i].ip} >> ~/.ssh/known_hosts
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
"""
}
}
}
}
}