// 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) {
        try {
            stage ("Parse deployment configuration file") {
                sh returnStdout: true, script: "rm -rf helm-charts helm-repo-tools ${configBaseDir}"
                sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-repo-tools"
                sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/helm-charts"
                sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
                deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
            }
            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) {
                        dir ("helm-charts") {
                            stage("Cleanup SR-IOV CNI and SR-IOV Network Device Plugin") {
                                sh returnStdout: true, script: """
                                export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                                kubectl delete -f mcord/cni-config/05-sriov-device-plugin.yaml
                                kubectl delete -f mcord/cni-config/04-sriov-device-plugin-configmap.yaml
                                kubectl delete -f mcord/cni-config/03-network-definition.yaml
                                kubectl delete -f mcord/cni-config/02-network-crd.yaml
                                kubectl delete -f mcord/cni-config/01-cni-service-account.yaml
                                """
                            }
                        }
                    }
                    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('Add Helm repositories') {
                sh returnStdout: true, script: """
                export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                helm repo add cord https://charts.opencord.org
                helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
                helm repo update
                """
                timeout(1) {
                    waitUntil {
                        cord_repo_present = sh returnStdout: true, script: """
                        export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
                        helm repo list | grep cord | wc -l
                        """
                        return cord_repo_present.toInteger() == 1
                    }
                }
            }
            dir ("helm-charts") {
                stage('Install SR-IOV CNI and SR-IOV Network Device Plugin') {
                    sh returnStdout: true, script: """
                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                    kubectl apply -f mcord/cni-config/02-network-crd.yaml
                    kubectl apply -f mcord/cni-config/
                    """
                }
            }

            stage("Install M-CORD Control Plane Services") {
                sh returnStdout: true, script: """
                export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                helm install -n mcord-control-plane -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/mcord-control-plane
                """
            }
            
            stage("Install M-CORD Data Plane Services") {
                sh returnStdout: true, script: """
                export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                helm install -n mcord-data-plane -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/mcord-data-plane
                """
            }

            // stage('Install CORD Kafka') {
            //     timeout(10) {
            //         sh returnStdout: true, script: """
            //         export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
            //         helm install --version 0.8.8 --set configurationOverrides."offsets\\.topic\\.replication\\.factor"=1 --set configurationOverrides."log\\.retention\\.hours"=4 --set configurationOverrides."log\\.message\\.timestamp\\.type"="LogAppendTime" --set replicas=1 --set persistence.enabled=false --set zookeeper.replicaCount=1 --set zookeeper.persistence.enabled=false -n cord-kafka incubator/kafka
            //         """
            //     }
            //     timeout(10) {
            //         waitUntil {
            //             kafka_instances_running = sh returnStdout: true, script: """
            //             export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
            //             kubectl get pods | grep cord-kafka | grep -i running | grep 1/1 | wc -l
            //             """
            //             return kafka_instances_running.toInteger() == 2
            //         }
            //     }
            // }
            // stage('Install Logging Infrastructure') {
            //     timeout(10) {
            //         sh returnStdout: true, script: """
            //         export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
            //         helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set elasticsearch.cluster.env.MINIMUM_MASTER_NODES="1" --set elasticsearch.client.replicas=1 --set elasticsearch.master.replicas=2 --set elasticsearch.master.persistence.enabled=false --set elasticsearch.data.replicas=1 --set elasticsearch.data.persistence.enabled=false -n logging cord/logging
            //         helm-repo-tools/wait_for_pods.sh
            //         """
            //     }
            // }
            // stage('Install Monitoring Infrastructure') {
            //     timeout(10) {
            //         sh returnStdout: true, script: """
            //         export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
            //         helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n nem-monitoring cord/nem-monitoring
            //         helm-repo-tools/wait_for_pods.sh
            //         """
            //     }
            // }
            // stage('Install ONOS') {
            //     timeout(10) {
            //         sh returnStdout: true, script: """
            //         export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
            //         helm install -n onos -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos
            //         """
            //     }
            //     timeout(10) {
            //         waitUntil {
            //             onos_completed = sh returnStdout: true, script: """
            //             export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
            //             kubectl get pods | grep -i onos | grep -i running | grep 2/2 | wc -l
            //             """
            //             return onos_completed.toInteger() == 1
            //         }
            //     }
            // }
            // stage('Install xos-core') {
            //     timeout(10) {
            //         sh returnStdout: true, script: """
            //         export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
            //         helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n xos-core cord/xos-core
            //         """
            //     }
            //     timeout(10) {
            //         waitUntil {
            //             xos_core_completed = sh returnStdout: true, script: """
            //             export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
            //             kubectl get pods | grep -i xos | grep -i running | grep 1/1 | wc -l
            //             """
            //             return xos_core_completed.toInteger() == 6
            //         }
            //     }
            // }

            if ( params.configurePod ) {
                dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
                    stage('Configure R-CORD - Fabric and whitelist') {
                        timeout(1) {
                            waitUntil {
                                out_fabric = sh returnStdout: true, script: """
                                curl -s -H "xos-username:admin@opencord.org" -H "xos-password:letmein" -X POST --data-binary @${configFileName}-fabric.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l
                                """
                                return out_fabric.toInteger() == 1
                            }
                        }
                    }
                    stage('Configure R-CORD - Subscriber') {
                        timeout(1) {
                            waitUntil {
                                out_subscriber = sh returnStdout: true, script: """
                                curl -s -H 'xos-username:admin@opencord.org' -H 'xos-password:letmein' -X POST --data-binary @${configFileName}-subscriber.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l
                                """
                                return out_subscriber.toInteger() == 1
                            }
                        }
                    }
                    stage('Configure R-CORD - OLT') {
                        timeout(1) {
                            waitUntil {
                                out_olt = sh returnStdout: true, script: """
                                curl -H 'xos-username:admin@opencord.org' -H 'xos-password:letmein' -X POST --data-binary @${configFileName}-olt.yaml http://${deployment_config.nodes[0].ip}:30007/run | grep -i "created models" | wc -l
                                """
                                return out_olt.toInteger() == 1
                            }
                        }
                    }
                }
            }
            currentBuild.result = 'SUCCESS'
        } catch (err) {
            currentBuild.result = 'FAILURE'
            step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
        }
        echo "RESULT: ${currentBuild.result}"
    }
}
