fix diagnostic collector

Change-Id: Ia20230b66f8de12bc8ad846a0f72426a99e7113f
diff --git a/build.gradle b/build.gradle
index ebffc9c..25f70c5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -258,6 +258,13 @@
   args = ["-p", "$config.seedServer.ansible_ssh_port", "$config.seedServer.ansible_user@$config.seedServer.ip", ansible_cmd ]
 }
 
+task PIrunDiag (type: Exec) {
+  def ansible_cmd = "cd /opt/cord/build/platform-install; ansible-playbook -i inventory/head-localhost --extra-vars @/opt/cord/build/genconfig/config.yml cord-diag-playbook.yml"
+
+  executable = "ssh"
+  args = ["-p", "$config.seedServer.ansible_ssh_port", "$config.seedServer.ansible_user@$config.seedServer.ip", ansible_cmd ]
+}
+
 task postDeployTests (type: Exec) {
 
   def ansible_cmd = "cd /opt/cord/build/platform-install; ansible-playbook -i inventory/head-localhost --extra-vars @/opt/cord/build/genconfig/config.yml cord-post-deploy-playbook.yml"
diff --git a/scripts/cord-in-a-box.sh b/scripts/cord-in-a-box.sh
index bd9c997..5b72c4e 100755
--- a/scripts/cord-in-a-box.sh
+++ b/scripts/cord-in-a-box.sh
@@ -192,11 +192,7 @@
 }
 
 function run_diagnostics() {
-  echo "*** COLLECTING DIAGNOSTIC INFO NOT CURRENTLY IMPLEMENTED"
-  # Need to fix up inventory to collect info from compute nodes
-  # Using juju-ansible is one possibility
-  #echo "*** COLLECTING DIAGNOSTIC INFO - check ~/diag-* on the head node"
-  #ansible-playbook -i $INVENTORY cord-diag-playbook.yml
+  ssh corddev "cd /cord/build; ./gradlew -PdeployConfig=$VMDIR/$CONFIG PIrunDiag"
 }
 
 # Parse options
@@ -285,6 +281,13 @@
    add_compute_node compute-node-$i build_compute-node-$i
 done
 
+# run diagnostics both before/after the fabric/e2e tests
+if [[ $DIAGNOSTICS -eq 1 ]]
+then
+  run_diagnostics
+fi
+
+
 if [[ $FABRIC -ne 0 ]]
 then
   initialize_fabric