// 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}"
                //sh returnStdout: true, script: "cd ${configBaseDir}; git fetch https://gerrit.opencord.org/pod-configs refs/changes/02/12902/1 && git checkout FETCH_HEAD; cd -"
                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
                        }
                    }

                    // In Multi-cluster scenario, we only need to install SR-IOV on data plane cluster
                    if ( ! params.installEpcControlPlane ) {
                        timeout(5) {
                            dir ("helm-charts") {
                                stage("Cleanup SR-IOV Network Device Plugin Daemonset") {
                                    sh returnStdout: true, script: """
                                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                                    kubectl delete -f mcord/cni-config/05-sriov-device-plugin.yaml || true
                                    kubectl delete -f mcord/cni-config/04-sriov-device-plugin-configmap.yaml || true
                                    kubectl delete -f mcord/cni-config/03-network-definition.yaml || true
                                    kubectl delete -f mcord/cni-config/02-network-crd.yaml || true
                                    kubectl delete -f mcord/cni-config/01-cni-service-account.yaml || true
                                    """
                                }
                            }
                        }
                    }

                    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|test' | wc -l
                            """
                            return kubectl_deleted.toInteger() == 0
                        }
                    }
                }
            }

            // OLT Software START
            if ( params.reinstallOlt ) {
                stage('Reinstall OLT software') {
                    for(int i=0; i < deployment_config.olts.size(); i++) {
                        sh returnStdout: true, script: """
                        sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --remove asfvolt16 && dpkg --purge asfvolt16'
                        """
                        timeout(5) {
                            waitUntil {
                                olt_sw_present = sh returnStdout: true, script: """
                                sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --list | grep asfvolt16 | wc -l'
                                """
                                return olt_sw_present.toInteger() == 0
                            }
                        }
                        sh returnStdout: true, script: """
                        sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
                        """
                        timeout(5) {
                            waitUntil {
                                olt_sw_present = sh returnStdout: true, script: """
                                sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --list | grep asfvolt16 | wc -l'
                                """
                                return olt_sw_present.toInteger() == 1
                            }
                        }
                        // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
                        if ("${deployment_config.olts[i].fortygig}" != null && "${deployment_config.olts[i].fortygig}" == 'true') {
                            sh returnStdout: true, script: """
                            sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'echo "port ce128 sp=40000" >> /broadcom/qax.soc'
                            sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '/opt/bcm68620/svk_init.sh'
                            """
                        }
                    }
                }

                stage('Restart OLT processes') {
                    for(int i=0; i < deployment_config.olts.size(); i++) {
                        timeout(5) {
                            sh returnStdout: true, script: """
                            ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
                            sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist stop' || true
                            sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt stop' || true
                            sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/bal_core_dist.log'
                            sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} '> /var/log/openolt.log'
                            sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service bal_core_dist start &'
                            sleep 5
                            sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'service openolt start &'
                            """
                        }
                        timeout(15) {
                            waitUntil {
                                onu_discovered = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'cat /var/log/openolt.log | grep \"oper_state: up\" | wc -l'"
                                return onu_discovered.toInteger() > 0
                            }
                        }
                    }
                }
            }

            // Start to deploy etcd clusters and M-CORD Services
            stage('Add Helm repositories') {
                sh returnStdout: true, script: """
                export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                helm init --upgrade --force-upgrade
                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 {
                        tillerpod_running = sh returnStdout: true, script: """
                        export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
                        kubectl -n kube-system get pods | grep tiller-deploy | grep Running | wc -l
                        """
                        return tillerpod_running.toInteger() == 1
                    }
                }
                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
                    }
                }
            }
            stage('Install etcd-cluster') {
                timeout(10) {
                    sh returnStdout: true, script: """
                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                    helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --version 0.8.3 -n etcd-operator stable/etcd-operator
                    """
                }
                timeout(10) {
                    waitUntil {
                        etcd_operator_running = sh returnStdout: true, script: """
                        export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
                        kubectl get pods | grep etcd-operator | grep -i running | grep 1/1 | wc -l
                        """
                        return etcd_operator_running.toInteger() == 3
                    }
                }
                timeout(1) {
                    waitUntil {
                        etcd_operator_definition = sh returnStdout: true, script: """
                        export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                        kubectl get crd -o json | jq -r '.items[].spec | select(.group=="etcd.database.coreos.com").names.kind' | grep -E 'EtcdBackup|EtcdCluster|EtcdRestore' | wc -l
                        """
                        return etcd_operator_definition.toInteger() == 3
                    }

                }
                timeout(10) {
                    sh returnStdout: true, script: """
                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                    helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set etcdNodePort=32379 --set clusterSize=1 -n etcd cord/etcd-cluster
                    """
                }
                timeout(10) {
                    waitUntil {
                        etcd_cluster_running = sh returnStdout: true, script: """
                        export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
                        kubectl get pods | grep etcd-cluster | grep -i running | grep 1/1 | wc -l
                        """
                        return etcd_cluster_running.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
                    """

                    timeout(1) {
                        waitUntil {
                            network_crd_exist = sh returnStdout: true, script: """
                            export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                            kubectl get crd -o json | jq -r '.items[].spec | select(.group=="k8s.cni.cncf.io").names.kind' | grep -E 'NetworkAttachmentDefinition' | wc -l
                            """
                            return network_crd_exist.toInteger() == 1
                        }
                    }

                    sh returnStdout: true, script: """
                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                    kubectl apply -f mcord/cni-config/
                    """

                    // Because of SR-IOV daemonset will restart the kubelet and containerd, so we need to wait tiller up.
                    timeout(1) {
                        waitUntil {
                            tillerpod_running = sh returnStdout: true, script: """
                            export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                            kubectl -n kube-system get pods | grep tiller-deploy | grep Running | wc -l
                            """
                            return tillerpod_running.toInteger() == 1
                        }
                    }

                    // Sometimes tillerpod is up, but it's not ready to accept deployment yet, let's wait.
                    timeout(1) {
                        waitUntil {
                            helm_client_working = sh returnStatus: true, script: """
                            export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                            helm ls
                            """
                            return helm_client_working == 0
                        }
                    }
                }
            }

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

            stage("Install M-CORD BBU Services") {
                mcord_bbu_working = sh returnStdout: true, script: """
                export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                helm install -n mcord-bbu --namespace epc -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/mcord-bbu
                """
            }

            // if ( params.installEpcControlPlane ) {
            //     timeout(2) {
            //         waitUntil {
            //             mcord_bbu_running = sh returnStdout: true, script: """
            //             export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
            //             kubectl -n epc get pods | grep accelleran | grep -i running | grep 3/3 | wc -l
            //             """
            //             return mcord_bbu_running.toInteger() == 1
            //         }
            //     }
            //     stage("Install M-CORD Control Plane Services") {
            //         mcord_controlplane_working = sh returnStdout: true, script: """
            //         export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
            //         ngic_s1u_net_ip=\$(kubectl exec -n epc ngic-dp-0 ifconfig s1u-net | grep 'inet addr' | cut -d: -f2 | awk '{print \$1}')
            //         bbu_eth0=\$(kubectl -n epc get pods accelleran-0 --template={{.status.podIP}})
            //         helm install -n mcord-control-plane --namespace epc -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/mcord-control-plane --set accelleran_hostname=\$bbu_eth0 --set spgwu_s1u_ip=\$ngic_s1u_net_ip
            //         """
            //     }
            // }

            stage("Install CDN Local Services") {
                timeout(2) {
                    waitUntil {
                        ngic_dataplane_running = sh returnStdout: true, script: """
                        export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
                        kubectl -n epc get pods | grep ngic-dp | grep -i running | grep 1/1 | wc -l
                        """
                        return ngic_dataplane_running.toInteger() == 1
                    }
                }

                mcord_local_cdn_working =  sh returnStdout: true, script: """
                export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                ngic_sgi_net_ip=\$(kubectl exec -n epc ngic-dp-0 ifconfig sgi-net | grep 'inet addr' | cut -d: -f2 | awk '{print \$1}')
                helm install -n cdn-local --set remote_ip="10.90.0.152" --set spgwu_sgiip=\$ngic_sgi_net_ip --namespace epc cord/mcord-cdn-local
                """
            }

            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 --version 1.0.1
                    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 --version 1.1.0
                    """
                }
                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 1/1 | wc -l
                        """
                        return onos_completed.toInteger() == 1
                    }
                }
            }

            stage('Install ONOS progRAN') {
                timeout(10) {
                    sh returnStdout: true, script: """
                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                    echo \$(pwd)
                    helm install -n onos-progran -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/onos-progran
                    """
                }
                timeout(10) {
                    waitUntil {
                        onos_progran_completed = sh returnStdout: true, script: """
                        export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
                        kubectl get pods | grep -i onos-progran | grep -i running | grep 1/1 | wc -l
                        """
                        return onos_progran_completed.toInteger() == 1
                    }
                }
                timeout(2) {
                  sh returnStdout: true, script: """
                  sshpass -p karaf ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30116 -l karaf ${deployment_config.nodes[0].ip} 'app deactivate org.onosproject.progran'
                  sshpass -p karaf ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 30116 -l karaf ${deployment_config.nodes[0].ip} 'app activate org.onosproject.progran'
                  """
                }
            }

            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 --version 2.3.3
                    """
                }
                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
                    }
                }
            }
            stage('Install M-CORD Profile') {
                timeout(10) {
                    sh returnStdout: true, script: """
                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                    helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n mcord cord/mcord
                    """
                }
                timeout(10) {
                    waitUntil {
                        tosca_completed = sh returnStdout: true, script: """
                        export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
                        kubectl get pods | grep -i mcord-tosca-loader | grep -i completed | wc -l
                        """
                        return tosca_completed.toInteger() == 1
                    }
                }
            }

            // SEBA Begin
            stage('Install SEBA Profile') {
                timeout(10) {
                    sh returnStdout: true, script: """
                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                    helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n seba cord/seba-services --set fabric.enabled=false --set onos-service.enabled=false --version 1.0.5
                    """
                }
                timeout(10) {
                    waitUntil {
                        tosca_completed = sh returnStdout: true, script: """
                        export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
                        kubectl get pods | grep -i seba-services-tosca-loader | grep -i completed | wc -l
                        """
                        return tosca_completed.toInteger() == 1
                    }
                }
            }

            stage('Install base-kubernetes') {
                timeout(10) {
                    sh returnStdout: true, script: """
                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                    helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml -n base-kubernetes cord/base-kubernetes --version 1.0.2
                    """
                }
                timeout(10) {
                    waitUntil {
                        base_kubernetes_tosca_running = sh returnStdout: true, script: """
                        export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
                        kubectl get pods | grep -i base-kubernetes-tosca-loader | grep -i completed | wc -l
                        """
                        return base_kubernetes_tosca_running.toInteger() == 1
                    }
                }
            }

            stage('Install att workflow') {
                timeout(10) {
                    sh returnStdout: true, script: """
                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                    helm install -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml --set att-workflow-driver.kafkaService=cord-kafka -n att-workflow --version 1.0.2 cord/att-workflow
                    """
                }
                timeout(10) {
                    waitUntil {
                        att_workflow_tosca_completed = sh returnStdout: true, script: """
                        export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
                        kubectl get pods | grep -i att-workflow-tosca-loader | grep -i completed | wc -l
                        """
                        return att_workflow_tosca_completed.toInteger() == 1
                    }
                }
            }

            stage('Install voltha') {
                timeout(10) {
                    sh returnStdout: true, script: """
                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                    helm install -n voltha -f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.yml cord/voltha --set etcd.cluster.enabled=false --version 1.0.3
                    """
                }
                timeout(10) {
                    waitUntil {
                        voltha_completed = sh returnStdout: true, script: """
                        export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
                        kubectl get pods -n voltha | grep -i running | grep 1/1 | wc -l
                        """
                        return voltha_completed.toInteger() == 8
                    }
                }
            }
            // SEBA end

            if ( params.configurePod ) {
                dir ("${configBaseDir}/${configToscaDir}/mcord") {
                    stage('Configure MCORD - Fabric') {
                        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
                            }
                        }
                    }
                }
                dir ("${configBaseDir}/${configToscaDir}/att-workflow") {
                    stage('Configure SEBA - 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 SEBA - 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 SEBA - 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) {
            println err.message
            currentBuild.result = 'FAILURE'
            step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
        }
        echo "RESULT: ${currentBuild.result}"
    }
}
