def filename = 'manifest-' + ${branch} + '.xml'

timeout (time: 240) {
    node ('build') {
       stage 'Checkout cord repo'
       checkout changelog: false, poll: false, scm: [$class: 'RepoScm', currentBranch: true, manifestBranch: ${branch}, manifestRepositoryUrl: 'https://gerrit.opencord.org/manifest', quiet: true]

       stage 'Generate and Copy Manifest file'
       sh returnStdout: true, script: 'repo manifest -r -o ' + filename 
       sh returnStdout: true, script: 'cp ' + filename + ' ' + env.JENKINS_HOME + '/tmp'

       dir('build') {
            stage 'Redeploy head node and Build Vagrant box'
            try {
                parallel(
                    maasOps: {
                        sh "maas login maas http://10.90.0.2/MAAS/api/2.0 ${apiKey}"
                        sh "maas maas machine release ${systemId}"

                        timeout(time: 15) {
                            waitUntil {
                               try {
                                    sh "maas maas machine read ${systemId} | grep Ready"
                                    return true
                                } catch (exception) {
                                    return false
                                }
                            }
                        }

                        sh 'maas maas machines allocate'
                        sh "maas maas machine deploy ${systemId}"

                        timeout(time: 30) {
                            waitUntil {
                               try {
                                    sh "maas maas machine read ${systemId} | grep Deployed"
                                    return true
                                } catch (exception) {
                                    return false
                                }
                            }
                        }

                    }, vagrantOps: {
                        sh 'vagrant up corddev'
                    }, failFast : true
                )

                stage 'Fetch CORD packages'
                sh 'vagrant ssh -c "cd /cord/build; ./gradlew fetch" corddev'

                stage 'Build CORD Images'
                sh 'vagrant ssh -c "cd /cord/build; ./gradlew buildImages" corddev'

                stage 'Publish to headnode'
                sh 'vagrant ssh -c "cd /cord/build; ./gradlew -PtargetReg=10.90.0.251:5000 -PdeployConfig=config/onlab_develop_pod.yml publish" corddev'

                stage 'Deploy'
                sh 'vagrant ssh -c "cd /cord/build; ./gradlew -PtargetReg=10.90.0.251:5000 -PdeployConfig=config/onlab_develop_pod.yml deploy" corddev'

                stage 'Power cycle compute nodes'
                parallel(
                    compute_1: {
                        sh 'ipmitool -U admin -P admin -H 10.90.0.10 power cycle'
                    }, compute_2: {
                        sh 'ipmitool -U admin -P admin -H 10.90.0.11 power cycle'
                    }, failFast : true
                )

                stage 'Wait for compute nodes to get deployed'
                sh 'ssh-keygen -f "/home/ubuntu/.ssh/known_hosts" -R 10.90.0.251'
                def cordapikey = sh(returnStdout: true, script: "sshpass -p ${headnodepass} ssh -oStrictHostKeyChecking=no -l ${headnodeuser} 10.90.0.251 sudo maas-region-admin apikey --username cord")
                sh "sshpass -p ${headnodepass} ssh -oStrictHostKeyChecking=no -l ${headnodeuser} 10.90.0.251 maas login pod-maas http://10.90.0.251/MAAS/api/1.0 $cordapikey"
                timeout(time: 45) {
                    waitUntil {
                        try {
                            num = sh(returnStdout: true, script: "sshpass -p ${headnodepass} ssh -l ${headnodeuser} 10.90.0.251  maas pod-maas nodes list | grep Deployed | wc -l").trim()
                            return num == '2'
                        } catch (exception) {
                            return false
                        }
                    }
                }

                stage 'Wait for computes nodes to be provisioned'
                ip = sh (returnStdout: true, script:"sshpass -p ${headnodepass} ssh -oStrictHostKeyChecking=no -l ${headnodeuser} 10.90.0.251 docker inspect --format '{{.NetworkSettings.Networks.maas_default.IPAddress}}'  provisioner").trim()
                timeout(time:45) {
                    waitUntil {
                        try {
                            out = sh (returnStdout: true, script:"sshpass -p ${headnodepass} ssh -oStrictHostKeyChecking=no -l ${headnodeuser} 10.90.0.251 curl -sS http://$ip:4243/provision/ | jq -c '.[] | select(.status | contains(2))'").trim()
                            return out != ""
                        } catch (exception) {
                            return false
                        }
                    }
                }

                stage 'Trigger Build'
                url = 'https://jenkins.opencord.org/job/release-build/job/' + env.BRANCH_NAME + '/build'
                httpRequest authentication: 'auto-release', httpMode: 'POST', url: url, validResponseCodes: '201'

                currentBuild.result = 'SUCCESS'
            } catch (err) {
                currentBuild.result = 'FAILURE'
                step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'cord-dev@opencord.org', sendToIndividuals: false])
            } finally {
                sh 'vagrant destroy -f corddev'
            }
            echo "RESULT: ${currentBuild.result}"
       }

    }
}
