Merge "[VOL-3352] fix log collection from olt"
diff --git a/jjb/defaults.yaml b/jjb/defaults.yaml
index 7640c80..e110a5b 100644
--- a/jjb/defaults.yaml
+++ b/jjb/defaults.yaml
@@ -199,3 +199,7 @@
     # maintainers
     # Used to notify users in supported tests
     maintainers: 'zdw@opennetworking.org'
+
+    # karaf-home
+    # Use to grab the logs or onos-diagnostics
+    karaf-home: 'apache-karaf-4.2.9'
diff --git a/jjb/pipeline/voltha-go-tests.groovy b/jjb/pipeline/voltha-go-tests.groovy
index 259b698..f8fac10 100644
--- a/jjb/pipeline/voltha-go-tests.groovy
+++ b/jjb/pipeline/voltha-go-tests.groovy
@@ -38,6 +38,8 @@
     VOLTHA_LOG_LEVEL="DEBUG"
     CONFIG_SADIS="no"
     ROBOT_MISC_ARGS="${params.extraRobotArgs} -d $WORKSPACE/RobotLogs -e PowerSwitch"
+    KARAF_HOME="${params.karafHome}"
+    DIAGS_PROFILE="VOLTHA_PROFILE"
   }
   stages {
 
@@ -159,8 +161,8 @@
          wget https://raw.githubusercontent.com/opennetworkinglab/onos/master/tools/package/runtime/bin/onos-diagnostics-k8s
          wget https://raw.githubusercontent.com/opennetworkinglab/onos/master/tools/package/runtime/bin/onos-diagnostics-profile
          chmod 755 onos-diagnostics-k8s
-         pod_name=$(kubectl get pods -lapp=onos-onos-classic -o name | cut -d '/' -f2 | tr '\n' ' ')
-         ./onos-diagnostics-k8s -k karaf ${pod_names}
+         pod_names=$(kubectl get pods -lapp=onos-onos-classic -o name | cut -d '/' -f2 | tr '\n' ' ')
+         ./onos-diagnostics-k8s ${pod_names}
          cp /tmp/onos-diags.tar.gz $WORKSPACE/onos-diags.tar.gz
 
          ## shut down voltha but leave kind-voltha cluster
diff --git a/jjb/pipeline/voltha-nightly-tests-bbsim.groovy b/jjb/pipeline/voltha-nightly-tests-bbsim.groovy
index 90810dd..843d915 100644
--- a/jjb/pipeline/voltha-nightly-tests-bbsim.groovy
+++ b/jjb/pipeline/voltha-nightly-tests-bbsim.groovy
@@ -38,6 +38,8 @@
     VOLTHA_LOG_LEVEL="DEBUG"
     CONFIG_SADIS="no"
     ROBOT_MISC_ARGS="-e PowerSwitch ${params.extraRobotArgs}"
+    KARAF_HOME="${params.karafHome}"
+    DIAGS_PROFILE="VOLTHA_PROFILE"
   }
   stages {
 
@@ -200,8 +202,8 @@
          wget https://raw.githubusercontent.com/opennetworkinglab/onos/master/tools/package/runtime/bin/onos-diagnostics-k8s
          wget https://raw.githubusercontent.com/opennetworkinglab/onos/master/tools/package/runtime/bin/onos-diagnostics-profile
          chmod 755 onos-diagnostics-k8s
-         pod_name=$(kubectl get pods -lapp=onos-onos-classic -o name | cut -d '/' -f2 | tr '\n' ' ')
-         ./onos-diagnostics-k8s -k karaf ${pod_names}
+         pod_names=$(kubectl get pods -lapp=onos-onos-classic -o name | cut -d '/' -f2 | tr '\n' ' ')
+         ./onos-diagnostics-k8s ${pod_names}
          cp /tmp/onos-diags.tar.gz $WORKSPACE/onos-diags.tar.gz
 
          ## shut down voltha but leave kind-voltha cluster
diff --git a/jjb/pipeline/voltha-scale-test.groovy b/jjb/pipeline/voltha-scale-test.groovy
index b3eb53e..3d3a3c6 100644
--- a/jjb/pipeline/voltha-scale-test.groovy
+++ b/jjb/pipeline/voltha-scale-test.groovy
@@ -419,6 +419,9 @@
         LOG_FOLDER=$WORKSPACE/logs
         mkdir -p $LOG_FOLDER
 
+        # store information on running charts
+        helm ls > $LOG_FOLDER/helm-list.txt
+
         # store information on the running pods
         kubectl get pods -o wide > $LOG_FOLDER/pods.txt
         kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq | tee $LOG_FOLDER/pod-images.txt
@@ -437,7 +440,8 @@
         done
 
         # copy the ONOS logs directly from the container to avoid the color codes
-        printf '%s\n' $(kubectl get pods -l app=onos-onos-classic -o=jsonpath="{.items[*]['metadata.name']}") | xargs -I@ bash -c "kubectl cp @:apache-karaf-4.2.9/data/log/karaf.log $LOG_FOLDER/@.log"
+        # TODO remove hardcoded karaf version
+        printf '%s\n' $(kubectl get pods -l app=onos-onos-classic -o=jsonpath="{.items[*]['metadata.name']}") | xargs -I@ bash -c "kubectl cp @:${karafHome}/data/log/karaf.log $LOG_FOLDER/@.log"
       '''
       // dump all the BBSim(s) ONU information
       sh '''
@@ -452,6 +456,7 @@
       // get ONOS debug infos
       sh '''
         sshpass -e ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@127.0.0.1 ports > $WORKSPACE/logs/onos-ports-list.txt
+        sshpass -e ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@127.0.0.1 volt-olts > $WORKSPACE/logs/onos-olt-list.txt
 
         if [ ${withFlows} = true ] ; then
           sshpass -e ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@127.0.0.1 flows -s > $WORKSPACE/logs/onos-flows-list.txt
@@ -483,10 +488,10 @@
       script {
         try {
           sh '''
-          voltctl device list -o json > $WORKSPACE/logs/device-list.json
+          voltctl -m 8MB device list -o json > $WORKSPACE/logs/device-list.json
           python -m json.tool $WORKSPACE/logs/device-list.json > $WORKSPACE/logs/voltha-devices-list.json
           rm $WORKSPACE/logs/device-list.json
-          voltctl device list > $WORKSPACE/logs/voltha-devices-list.txt
+          voltctl -m 8MB device list > $WORKSPACE/logs/voltha-devices-list.txt
 
           printf '%s\n' $(voltctl -m 8MB device list | grep olt | awk '{print $1}') | xargs -I@ bash -c "voltctl -m 8MB device flows @ > $WORKSPACE/logs/voltha-device-flows-@.txt"
           printf '%s\n' $(voltctl -m 8MB device list | grep olt | awk '{print $1}') | xargs -I@ bash -c "voltctl -m 8MB device port list --format 'table{{.PortNo}}\t{{.Label}}\t{{.Type}}\t{{.AdminState}}\t{{.OperStatus}}' @ > $WORKSPACE/logs/voltha-device-ports-@.txt"
diff --git a/jjb/voltha-e2e.yaml b/jjb/voltha-e2e.yaml
index 23e3a7d..48298ad 100644
--- a/jjb/voltha-e2e.yaml
+++ b/jjb/voltha-e2e.yaml
@@ -27,6 +27,7 @@
           onus: 2
           pons: 2
           time-trigger: "H H/12 * * *"
+          karaf-home: 'apache-karaf-4.2.8'
 
       - 'voltha-periodic-test':
           name: 'periodic-voltha-etcd-test'
@@ -191,6 +192,11 @@
           default: '{work-flow}'
           description: 'Workflow for testcase'
 
+      - string:
+          name: karafHome
+          default: '{karaf-home}'
+          description: 'Karaf home'
+
     project-type: pipeline
     concurrent: true
 
diff --git a/jjb/voltha-scale.yaml b/jjb/voltha-scale.yaml
index a55d91f..56d9c44 100644
--- a/jjb/voltha-scale.yaml
+++ b/jjb/voltha-scale.yaml
@@ -254,6 +254,7 @@
           atomixReplicas: 3
           extraHelmFlags: '--set defaults.rw_core.timeout=30s'
           release: voltha-2.4
+          karafHome: apache-karaf-4.2.8
 
       - 'voltha-scale-measurements':
           name: 'voltha-scale-measurements-voltha-2.4-2-16-32-dt-subscribers'
@@ -273,6 +274,7 @@
           atomixReplicas: 3
           extraHelmFlags: '--set defaults.rw_core.timeout=30s'
           release: voltha-2.4
+          karafHome: apache-karaf-4.2.8
 
       # development pipeline
       - 'voltha-scale-measurements-dev':
@@ -515,6 +517,11 @@
           default: '{inMemoryEtcdStorage}'
           description: 'Whether to write ETCD keys on disk or keep them in memory (true=inMemory)'
 
+      - string:
+          name: karafHome
+          default: '{karaf-home}'
+          description: 'Karaf home'
+
     project-type: pipeline
     concurrent: false
 
@@ -721,6 +728,11 @@
           default: ''
           description: 'Download a change for gerrit in the kind-voltha repo, example value: "refs/changes/32/19132/1"'
 
+      - string:
+          name: karafHome
+          default: '{karaf-home}'
+          description: 'Karaf home'
+
     project-type: pipeline
     concurrent: false