[CORD-2219] Added onos-fabric to collect-diag

Change-Id: Idee5a347bda46c5aab2ca0bc236da3eaf5860967
(cherry picked from commit d420e68b555fb40e7699319d53eb618d15348f4e)
diff --git a/roles/head-diag/tasks/main.yml b/roles/head-diag/tasks/main.yml
index 7a920d5..c6d847d 100644
--- a/roles/head-diag/tasks/main.yml
+++ b/roles/head-diag/tasks/main.yml
@@ -26,6 +26,7 @@
   - juju
   - openstack
   - onos
+  - onos_fabric
   - docker
 
 - name: Head node diag collection
@@ -103,6 +104,29 @@
    - "ports"
    - "summary"
 
+- name: ONOS_FABRIC diag collection - REST API
+  shell: "curl -X GET -u karaf:karaf http://onos-fabric:8182/onos/v1/{{ item }} | python -m json.tool > ~/{{ diag_dir }}/onos_fabric/rest_{{ item | regex_replace('[^\\w-]', '_') }}"
+  ignore_errors: yes
+  args:
+    creates: "~/{{ diag_dir }}/onos_fabric/rest_{{ item | regex_replace('[^\\w-]', '_')}}"
+    warn: False # get_url or uri can't easily redirect to a file
+  with_items:
+   - "hosts"
+
+- name: ONOS_FABRIC diag collection - ONOS CLI
+  shell: "sshpass -p 'karaf' ssh -p 8101 karaf@onos-fabric {{ item }} > ~/{{ diag_dir }}/onos_fabric/{{ item | regex_replace('[^\\w-]', '_') }}"
+  ignore_errors: yes
+  args:
+    creates: "~/{{ diag_dir }}/onos_fabric/{{ item | regex_replace('[^\\w-]', '_')}}"
+  with_items:
+   - "apps -s -a"
+   - "bundle:list"
+   - "hosts"
+   - "log:display"
+   - "netcfg"
+   - "ports"
+   - "summary"
+
 - name: Docker diag collection - Find names for all running Docker containers
   command: sudo docker ps --format '{{'{{'}} .Names {{'}}'}}'
   ignore_errors: yes