Merge "[EDGEPOD-210]: Add COMAC-in-a-box automation to CORD Jenkins Job"
diff --git a/jjb/cord-test/voltha.yaml b/jjb/cord-test/voltha.yaml
index b725d38..c461759 100644
--- a/jjb/cord-test/voltha.yaml
+++ b/jjb/cord-test/voltha.yaml
@@ -268,7 +268,7 @@
           branch: 'master'
           test-repo: 'voltha-system-tests'
           Jenkinsfile: 'Jenkinsfile-voltha-build'
-          oltDebVersion: 'openolt_asfvolt16_bal3.2.deb'
+          oltDebVersion: 'openolt_asfvolt16-2.3.0-bc6e0853e0e8bf6bd7e4223d4a7ee0dd35ce634d.deb'
           configurePod: true
           profile: 'Default'
 
@@ -289,7 +289,7 @@
           branch: 'master'
           test-repo: 'voltha-system-tests'
           Jenkinsfile: 'Jenkinsfile-voltha-build'
-          oltDebVersion: 'openolt_asfvolt16.deb'
+          oltDebVersion: 'openolt_asfvolt16-2.3.0-bc6e0853e0e8bf6bd7e4223d4a7ee0dd35ce634d.deb'
           configurePod: true
           profile: 'Default'
           time: '10'
@@ -311,7 +311,7 @@
           branch: 'voltha-2.3'
           test-repo: 'voltha-system-tests'
           Jenkinsfile: 'Jenkinsfile-voltha-build'
-          oltDebVersion: 'openolt_asfvolt16.deb'
+          oltDebVersion: 'openolt_asfvolt16-2.3.0-bc6e0853e0e8bf6bd7e4223d4a7ee0dd35ce634d.deb'
           configurePod: true
           profile: 'Default'
           time: '12'
diff --git a/jjb/omec-ci.yaml b/jjb/omec-ci.yaml
index a5c0092..2561303 100644
--- a/jjb/omec-ci.yaml
+++ b/jjb/omec-ci.yaml
@@ -467,7 +467,7 @@
     description: |
       Automated build on AMI executor using pipeline/omec-deploy-staging.groovy. <br /><br />
       Created from job-template {id} from ci-management/jjb/charts.yaml <br />
-      Created by Jeremy Ronquillo, jeremyr@opennetworking.org <br />
+      Created by Jeremy Ronquillo - jeremyr@opennetworking.org <br />
       Copyright (c) 2020 Open Networking Foundation (ONF)
 
     properties:
@@ -485,10 +485,14 @@
           name: buildNode
           default: 'omec-staging'
           description: 'Name of the Jenkins executor node to run the job on.'
+      - bool:
+          name: useProductionCluster
+          default: false
+          description: 'Check this option to use the production cluster instead of the staging cluster. <b>Use with caution.</b>'
       - string:
           name: registry
           default: 'omecproject'
-          description: 'Registry for all images.'
+          description: 'Registry for all images that will be changed.'
       - string:
           name: hssdb_tag
           default: ''
diff --git a/jjb/pipeline/omec-deploy-staging.groovy b/jjb/pipeline/omec-deploy-staging.groovy
index 2b48fed..87f8aa3 100644
--- a/jjb/pipeline/omec-deploy-staging.groovy
+++ b/jjb/pipeline/omec-deploy-staging.groovy
@@ -15,6 +15,13 @@
 // Jenkinsfile-omec-deploy-staging.groovy: Changes staging images in
 // omec-cp.yaml and omec-dp.yaml based on params and deploys omec staging.
 // Mainly triggered from omec-postmerge after publishing docker images.
+// Can deploy in production (manual trigger only).
+
+dp_context = ""
+omec_cp = ""
+omec_dp = ""
+accelleran_cbrs_common = ""
+accelleran_cbrs_cu = ""
 
 pipeline {
 
@@ -23,22 +30,55 @@
     label "${params.buildNode}"
   }
 
-  /* locations of omec-cp.yaml and omec-dp.yaml */
   environment {
-    omec_cp = "~/pod-configs/deployment-configs/aether/apps/gcp-stg/omec-cp.yaml"
-    omec_dp = "~/pod-configs/deployment-configs/aether/apps/menlo-stg/omec-dp.yaml"
+      vm = "comac@192.168.122.57"
   }
 
   stages {
+    stage('Environment Setup') {
+        steps {
+            script {
+                if (params.useProductionCluster) {
+                    dp_context = "production-edge-demo"
+                    omec_cp = "~/pod-configs/deployment-configs/aether/apps/gcp-prd/omec-cp.yaml"
+                    omec_dp = "~/pod-configs/deployment-configs/aether/apps/menlo-demo/omec-dp-cbrs.yaml"
+                    accelleran_cbrs_common = "~/pod-configs/deployment-configs/aether/apps/menlo-demo/accelleran-cbrs-common.yaml"
+                    accelleran_cbrs_cu = "~/pod-configs/deployment-configs/aether/apps/menlo-demo/accelleran-cbrs-cu.yaml"
+                    sh script: "ssh ${env.vm} 'cp ~/.kube/omec_production_config ~/.kube/config'"
+                    println "Using PRODUCTION cluster."
+                } else {
+                    dp_context = "staging-edge-onf-menlo"
+                    omec_cp = "~/pod-configs/deployment-configs/aether/apps/gcp-stg/omec-cp.yaml"
+                    omec_dp = "~/pod-configs/deployment-configs/aether/apps/menlo-stg/omec-dp.yaml"
+                    accelleran_cbrs_common = "~/pod-configs/deployment-configs/aether/apps/menlo-stg/accelleran-cbrs-common.yaml"
+                    accelleran_cbrs_cu = "~/pod-configs/deployment-configs/aether/apps/menlo-stg/accelleran-cbrs-cu.yaml"
+                    sh script: "ssh ${env.vm} 'cp ~/.kube/omec_staging_config ~/.kube/config'"
+                    println "Using STAGING cluster."
+                }
+            }
+        }
+    }
+    stage('Reset Staging') {
+      steps {
+        sh label: 'Reset Deployment', script: """
+          ssh ${env.vm} '
+            helm delete --purge --kube-context staging-edge-onf-menlo accelleran-cbrs-cu | true
+            helm delete --purge --kube-context staging-edge-onf-menlo accelleran-cbrs-common | true
+            helm delete --purge --kube-context staging-edge-onf-menlo omec-data-plane | true
+            helm delete --purge --kube-context staging-central-gcp omec-control-plane | true
+          '
+        """
+      }
+    }
     stage('Change Staging Images Config') {
       steps {
         sh label: 'Change Staging Images Config', script: """
-          ssh comac@192.168.122.57 '
+          ssh ${env.vm} '
 
             # if hssdb tag is provided, change hssdb tag in omec_cp.yaml.
             if [ ! -z "${params.hssdb_tag}" ]
             then
-              sed -i "s;hssdb: .*;hssdb: \\"${params.registry}/c3po-hssdb:${params.hssdb_tag}\\";" ${env.omec_cp}
+              sed -i "s;hssdb: .*;hssdb: \\"${params.registry}/c3po-hssdb:${params.hssdb_tag}\\";" ${omec_cp}
               echo "Changed hssdb tag."
             else
               echo "hssdb tag not provided. Not changing."
@@ -47,7 +87,7 @@
             # if hss tag is provided, change hss tag in omec_cp.yaml.
             if [ ! -z "${params.hss_tag}" ]
             then
-              sed -i "s;hss: .*;hss: \\"${params.registry}/c3po-hss:${params.hss_tag}\\";" ${env.omec_cp}
+              sed -i "s;hss: .*;hss: \\"${params.registry}/c3po-hss:${params.hss_tag}\\";" ${omec_cp}
               echo "Changed hss tag."
             else
               echo "hss tag not provided. Not changing."
@@ -56,7 +96,7 @@
             # if mme tag is provided, change mme tag in omec_cp.yaml.
             if [ ! -z "${params.mme_tag}" ]
             then
-              sed -i "s;mme: .*;mme: \\"${params.registry}/openmme:${params.mme_tag}\\";" ${env.omec_cp}
+              sed -i "s;mme: .*;mme: \\"${params.registry}/openmme:${params.mme_tag}\\";" ${omec_cp}
               echo "Changed mme tag."
             else
               echo "mme tag not provided. Not changing."
@@ -65,7 +105,7 @@
             # if mmeExporter tag is provided, change mmeExporter tag in omec_cp.yaml.
             if [ ! -z "${params.mmeExporter_tag}" ]
             then
-              sed -i "s;mmeExporter: .*;mmeExporter: \\"${params.registry}/mme-exporter:${params.mmeExporter_tag}\\";" ${env.omec_cp}
+              sed -i "s;mmeExporter: .*;mmeExporter: \\"${params.registry}/mme-exporter:${params.mmeExporter_tag}\\";" ${omec_cp}
               echo "Changed mmeExporter tag."
             else
               echo "mmeExporter tag not provided. Not changing."
@@ -74,7 +114,7 @@
             # if spgwc tag is provided, change spgwc tag in omec_cp.yaml.
             if [ ! -z "${params.spgwc_tag}" ]
             then
-              sed -i "s;spgwc: .*;spgwc: \\"${params.registry}/ngic-cp:${params.spgwc_tag}\\";" ${env.omec_cp}
+              sed -i "s;spgwc: .*;spgwc: \\"${params.registry}/ngic-cp:${params.spgwc_tag}\\";" ${omec_cp}
               echo "Changed spgwc tag."
             else
               echo "spgwc tag not provided. Not changing."
@@ -83,7 +123,7 @@
             # if spgwu tag is provided, change spgwu tag in omec_dp.yaml.
             if [ ! -z "${params.spgwu_tag}" ]
             then
-              sed -i "s;spgwu: .*;spgwu: \\"${params.registry}/ngic-dp:${params.spgwu_tag}\\";" ${env.omec_dp}
+              sed -i "s;spgwu: .*;spgwu: \\"${params.registry}/ngic-dp:${params.spgwu_tag}\\";" ${omec_dp}
               echo "Changed spgwu tag."
             else
               echo "spgwu tag not provided. Not changing."
@@ -91,20 +131,20 @@
 
             # display omec-cp.yaml
             echo "omec_cp:"
-            cat ${env.omec_cp}
+            cat ${omec_cp}
 
             # display omec-dp.yaml
             echo "omec_dp:"
-            cat ${env.omec_dp}
+            cat ${omec_dp}
             '
           """
       }
     }
 
-    stage('Deploy: staging-central-gcp') {
+    stage('Deploy Control Plane') {
       steps {
-        sh label: 'staging-central-gcp', script: '''
-          ssh comac@192.168.122.57 '
+        sh label: 'staging-central-gcp', script: """
+          ssh ${env.vm} '
             kubectl config use-context staging-central-gcp
 
             helm del --purge omec-control-plane | true
@@ -112,7 +152,7 @@
             helm install --kube-context staging-central-gcp \
                          --name omec-control-plane \
                          --namespace omec \
-                         --values pod-configs/deployment-configs/aether/apps/gcp-stg/omec-cp.yaml \
+                         --values ${omec_cp} \
                          cord/omec-control-plane
 
             kubectl --context staging-central-gcp -n omec wait \
@@ -120,60 +160,60 @@
                          --timeout=300s \
                          pod -l app=spgwc
             '
-          '''
+          """
       }
     }
 
-    stage('Deploy: omec-data-plane') {
+    stage('Deploy Data Plane') {
       steps {
-        sh label: 'staging-edge-onf-menlo', script: '''
-          ssh comac@192.168.122.57 '
-            kubectl config use-context staging-edge-onf-menlo
+        sh label: 'dp_context', script: """
+          ssh ${env.vm} '
+            kubectl config use-context ${dp_context}
 
             helm del --purge omec-data-plane | true
 
-            helm install --kube-context staging-edge-onf-menlo \
+            helm install --kube-context ${dp_context} \
                          --name omec-data-plane \
                          --namespace omec \
-                         --values pod-configs/deployment-configs/aether/apps/menlo-stg/omec-dp.yaml \
+                         --values ${omec_dp} \
                          cord/omec-data-plane
 
-            kubectl --context staging-edge-onf-menlo -n omec wait \
+            kubectl --context ${dp_context} -n omec wait \
                          --for=condition=Ready \
                          --timeout=300s \
                          pod -l app=spgwu
             '
-          '''
+          """
       }
     }
 
-    stage('Deploy: accelleran-cbrs') {
+    stage('Deploy Accelleran CBRS') {
       steps {
-        sh label: 'accelleran-cbrs-common', script: '''
-          ssh comac@192.168.122.57 '
-            kubectl config use-context staging-edge-onf-menlo
+        sh label: 'accelleran-cbrs-common', script: """
+          ssh ${env.vm} '
+            kubectl config use-context ${dp_context}
 
             helm del --purge accelleran-cbrs-common | true
             helm del --purge accelleran-cbrs-cu | true
 
-            helm install --kube-context staging-edge-onf-menlo \
+            helm install --kube-context ${dp_context} \
                          --name accelleran-cbrs-common \
                          --namespace omec \
-                         --values pod-configs/deployment-configs/aether/apps/menlo-stg/accelleran-cbrs-common.yaml \
+                         --values ${accelleran_cbrs_common} \
                          cord/accelleran-cbrs-common
 
-            helm install --kube-context staging-edge-onf-menlo \
+            helm install --kube-context ${dp_context} \
                          --name accelleran-cbrs-cu \
                          --namespace omec \
-                         --values pod-configs/deployment-configs/aether/apps/menlo-stg/accelleran-cbrs-cu.yaml \
+                         --values ${accelleran_cbrs_cu} \
                          cord/accelleran-cbrs-cu
 
-            kubectl --context staging-edge-onf-menlo -n omec wait \
+            kubectl --context ${dp_context} -n omec wait \
                          --for=condition=Ready \
                          --timeout=300s \
                          pod -l app=accelleran-cbrs-cu
             '
-          '''
+          """
       }
     }
   }
diff --git a/jjb/pipeline/omec-postmerge.groovy b/jjb/pipeline/omec-postmerge.groovy
index 9df3600..f64757d 100644
--- a/jjb/pipeline/omec-postmerge.groovy
+++ b/jjb/pipeline/omec-postmerge.groovy
@@ -77,8 +77,8 @@
         }
         build job: "omec-deploy-staging", parameters: [
               string(name: 'hssdb_tag', value: "${hssdb_tag}"),
-              string(name: 'mme_tag', value: "${hss_tag}"),
-              string(name: 'hss_tag', value: "${mme_tag}"),
+              string(name: 'hss_tag', value: "${hss_tag}"),
+              string(name: 'mme_tag', value: "${mme_tag}"),
               string(name: 'spgwc_tag', value: "${spgwc_tag}"),
               string(name: 'spgwu_tag', value: "${spgwu_tag}"),
             ], quietPeriod: quietPeriodTime
diff --git a/jjb/pipeline/voltha-scale-measurements.groovy b/jjb/pipeline/voltha-scale-measurements.groovy
index 616115b..9930f82 100644
--- a/jjb/pipeline/voltha-scale-measurements.groovy
+++ b/jjb/pipeline/voltha-scale-measurements.groovy
@@ -206,8 +206,8 @@
         cat ports.txt >> onos-ports-count.txt
       '''
       sh '''
-        kubectl get pods -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.image}{'\\n'}" | sort | uniq
-        kubectl get pods -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq
+        kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
+        kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
       '''
       sh '''
         voltctl device list -o json > device-list.json
diff --git a/jjb/voltha-scale.yaml b/jjb/voltha-scale.yaml
index 8e0eb1c..1a654b1 100644
--- a/jjb/voltha-scale.yaml
+++ b/jjb/voltha-scale.yaml
@@ -80,11 +80,7 @@
           ponPorts: 16
           expectedOnus: 512
           BBSIMdelay: 200
-          # multi-adapter-tmp-changes
-          volthaImg: "matteoscandolo/voltha-rw-core:replica"
-          openoltAdapterImg: "matteoscandolo/voltha-openolt-adapter:replica"
-          openonuAdapterImg: "matteoscandolo/voltha-openonu-adapter:replica"
-          openonuAdapterChart: "/home/cord/voltha-helm-charts/voltha-adapter-openonu"
+          # multi-adapter
           extraHelmFlags: "--set replicas.adapter_open_onu=8"
       - 'voltha-scale-measurements-periodic':
           name: 'voltha-scale-measurements-periodic-16-64-200ms'
@@ -94,11 +90,7 @@
           ponPorts: 16
           expectedOnus: 1024
           BBSIMdelay: 200
-          # multi-adapter-tmp-changes
-          volthaImg: "matteoscandolo/voltha-rw-core:replica"
-          openoltAdapterImg: "matteoscandolo/voltha-openolt-adapter:replica"
-          openonuAdapterImg: "matteoscandolo/voltha-openonu-adapter:replica"
-          openonuAdapterChart: "/home/cord/voltha-helm-charts/voltha-adapter-openonu"
+          # multi-adapter
           extraHelmFlags: "--set replicas.adapter_open_onu=8"
       - 'voltha-scale-measurements-periodic':
           name: 'voltha-scale-measurements-periodic-4-64-200ms'