Support for QCT switches

Change-Id: Iacb4720b2bdee2f26b0c4b228e52e5c75b7a070f
diff --git a/roles/fabric-switch/defaults/main.yml b/roles/fabric-switch/defaults/main.yml
index cf733fb..9526484 100644
--- a/roles/fabric-switch/defaults/main.yml
+++ b/roles/fabric-switch/defaults/main.yml
@@ -13,6 +13,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
+---
 pub_ssh_key_file_location: "{{ pub_ssh_key_location | default ('/etc/maas/.ssh') }}"
 pub_ssh_key: "{{ lookup('file', pub_ssh_key_file_location+'/cord_rsa.pub') }}"
+
+switch_ouis:
+  - accton:
+    - "cc37ab"
+    - "7072cf"
+    - "c4393a"
+    - "8cea1b"
+    - "a82bb5"
+    - "480fcf"
+  - qct:
+    - "2c600c"
+    - "54ab3a"
diff --git a/roles/fabric-switch/tasks/main.yml b/roles/fabric-switch/tasks/main.yml
index 97327bc..5d0f769 100644
--- a/roles/fabric-switch/tasks/main.yml
+++ b/roles/fabric-switch/tasks/main.yml
@@ -15,11 +15,16 @@
 
 ---
 - name: Generate DPID
-  shell: ifconfig ma1 | grep HWaddr | awk '{ print "0x0000"$5 }' | sed s/://g
+  shell: ifconfig | grep HWaddr | head -1 | awk '{ print "0x0000"$5 }' | sed s/://g
   register: dpid
   changed_when: false
 
-- name: Ensure ofdpa Config
+- name: Get switch OUI
+  shell: ifconfig | grep HWaddr | head -1 | awk '{ print $5 }' | sed s/://g | cut -c1-6
+  register: oui
+  changed_when: false
+
+- name: Ensure OFDPA Config
   set_fact:
     switch_id: "{{ dpid.stdout }}"
     controller_ip: "onos-fabric"
@@ -35,22 +40,26 @@
   changed_when: false
   when: ofdpa_exists.stdout != "0"
 
-# Note: This is the version number of OFDPA 3.0 EA4
-- name: Version 2.0.4.0 Openflow Agent
+- name: Install OFDPA commons steps
   include: ofdpa.yml
-  when: ofdpa_exists.stdout == "0" or ofdpa_version.stderr.find('version 2.0.4.0') == -1
+  when: ofdpa_exists.stdout == "0" or
+        (ofdpa_version.stdout.find('3.0.4.0') == -1 and ofdpa_version.stdout.find('3.0.5.0') == -1)
 
-- name: Utilities Scripts
-  template:
-    src: "{{ item }}"
-    dest: /root
-    owner: root
-    group: root
-    mode: "0755"
-  with_items:
-    - killit
-    - connect
-  register: utils
+- name: Install OFDPA for Accton switches
+  include: ofdpa-accton.yml lsb_stat="{{ lsb_stat }}" dist="{{ dist }}"
+  with_items: "{{ switch_ouis.accton|default([]) }}"
+  when:
+    - ofdpa_exists.stdout == "0" or ofdpa_version.stderr.find('3.0.4.0') == -1
+    # Accton related OUIs
+    - oui.stdout == item
+
+- name: Install OFDPA for QCT switches
+  include: ofdpa-qct.yml lsb_stat="{{ lsb_stat }}" dist="{{ dist }}"
+  with_items: "{{ switch_ouis.qct|default([]) }}"
+  when:
+    - ofdpa_exists.stdout == "0" or ofdpa_version.stderr.find('3.0.5.0') == -1
+    # Accton related OUIs
+    - oui.stdout == item
 
 - name: Authorize SSH Key
   become: yes
@@ -59,4 +68,3 @@
     user=root
     state=present
   register: sshkey
-
diff --git a/roles/fabric-switch/tasks/ofdpa-accton.yml b/roles/fabric-switch/tasks/ofdpa-accton.yml
new file mode 100644
index 0000000..598adcb
--- /dev/null
+++ b/roles/fabric-switch/tasks/ofdpa-accton.yml
@@ -0,0 +1,26 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+---
+- name: Openflow Accton Agent Debian Archive
+  get_url:
+    url: https://github.com/onfsdn/atrium-docs/blob/master/16A/ONOS/builds/ofdpa_3.0.4.0+accton1.0~1-1_amd64.deb?raw=true
+    validate_certs: false
+    checksum: "sha256:e0b10051b2032454132c6634a0896883e1548e0c39b847ff10933e559b95a729"
+    dest: /mnt/onl/data/ofdpa_3.0.4.0+accton1.0~1-1_amd64.deb
+
+- name: Openflow Agent Installed
+  apt: deb="/mnt/onl/data/ofdpa_3.0.4.0+accton1.0~1-1_amd64.deb" force=true
+  when: not lsb_stat.stat.exists or dist.stdout == "0"
diff --git a/roles/fabric-switch/tasks/ofdpa-qct.yml b/roles/fabric-switch/tasks/ofdpa-qct.yml
new file mode 100644
index 0000000..f4e78fe
--- /dev/null
+++ b/roles/fabric-switch/tasks/ofdpa-qct.yml
@@ -0,0 +1,26 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+---
+- name: Openflow Quanta Agent Debian Archive
+  get_url:
+    url: https://github.com/onfsdn/atrium-docs/raw/master/16A/ONOS/builds/ofdpa-ly8_0.3.0.5.0-EA5-qct-00.03_amd64.deb
+    validate_certs: false
+    checksum: "sha256:1c2aae5e4596b4c73c7ac63209dd1d303d4aaf794daadff7f5de3d476d0335a5"
+    dest: /mnt/onl/data/ofdpa-ly8_0.3.0.5.0-EA5-qct-0.0_amd64.deb
+
+- name: Openflow Agent Installed
+  apt: deb="/mnt/onl/data/ofdpa-ly8_0.3.0.5.0-EA5-qct-00.03_amd64.deb" force=true
+  when: not lsb_stat.stat.exists or dist.stdout == "0"
diff --git a/roles/fabric-switch/tasks/ofdpa.yml b/roles/fabric-switch/tasks/ofdpa.yml
index ace1f2b..9d8fb43 100644
--- a/roles/fabric-switch/tasks/ofdpa.yml
+++ b/roles/fabric-switch/tasks/ofdpa.yml
@@ -14,13 +14,6 @@
 # limitations under the License.
 
 ---
-- name: Openflow Agent Debian Archive
-  get_url:
-    url: https://github.com/onfsdn/atrium-docs/blob/master/16A/ONOS/builds/ofdpa_3.0.4.0+accton1.0~1-1_amd64.deb?raw=true
-    validate_certs: false
-    checksum: "sha256:e0b10051b2032454132c6634a0896883e1548e0c39b847ff10933e559b95a729"
-    dest: /mnt/onl/data/ofdpa_3.0.4.0+accton1.0~1-1_amd64.deb
-
 # We want to kill old agents and stop the old OFDPA service before removing
 - name: OpenFlow Agent Is Not Running
   command: killall ofagentapp
@@ -59,12 +52,19 @@
   changed_when: false
   failed_when: false
 
-- name: Verify Distribute Name
+- name: Verify Distribute Release Name
   shell: grep -i ubuntu /etc/lsb-release | wc -l
   register: dist
   changed_when: false
   failed_when: false
 
-- name: Openflow Agent Installed
-  apt: deb="/mnt/onl/data/ofdpa_3.0.4.0+accton1.0~1-1_amd64.deb" force=true
-  when: not lsb_stat.stat.exists or dist.stdout == "0"
+- name: Utilities Scripts
+  template:
+    src: "{{ item }}"
+    dest: /root
+    owner: root
+    group: root
+    mode: "0755"
+  with_items:
+    - killit
+    - connect
diff --git a/roles/maas/defaults/main.yml b/roles/maas/defaults/main.yml
index 8eb81ba..a3e3dbc 100644
--- a/roles/maas/defaults/main.yml
+++ b/roles/maas/defaults/main.yml
@@ -20,6 +20,9 @@
   - name: "ONL-2.0.0_ONL-OS_2017-01-04.0024-8d23df5_AMD64_INSTALLED_INSTALLER"
     url: 'https://github.com/opencord/OpenNetworkLinux/releases/download/2017-01-04.0024-8d23df5/ONL-2.0.0_ONL-OS_2017-01-04.0024-8d23df5_AMD64_INSTALLED_INSTALLER'
     checksum: "sha256:4ed90086cafc3899ddb10ab7bac8677d8ece27de3ed28ed385c12aba8d53c0a9"
+  - name: "ONL-2.0.0_ONL-OS_2017-10-19.2200-1211610_AMD64_INSTALLED_INSTALLER"
+    url: 'https://github.com/opencord/OpenNetworkLinux/releases/download/2017-10-19.2200-1211610/ONL-2.0.0_ONL-OS_2017-10-19.2200-1211610_AMD64_INSTALLED_INSTALLER'
+    checksum: "sha256:2db316ea83f5dc761b9b11cc8542f153f092f3b49d82ffc0a36a2c41290f5421"
 
 # Add specific models of switches here - the value of boot_image should be the
 # name of an image in the switch_boot_images list given above
@@ -30,6 +33,8 @@
     boot_image: "ONL-2.0.0_ONL-OS_2017-01-04.0024-8d23df5_AMD64_INSTALLED_INSTALLER"
   - name: "onie-installer-x86_64-accton_as6712_32x-r0"
     boot_image: "ONL-2.0.0_ONL-OS_2017-01-04.0024-8d23df5_AMD64_INSTALLED_INSTALLER"
+  - name: "onie-installer-x86_64-quanta_ly8_rangeley-r0"
+    boot_image: "ONL-2.0.0_ONL-OS_2017-10-19.2200-1211610_AMD64_INSTALLED_INSTALLER"
 
 pub_ssh_key_file_location: "{{ pub_ssh_key_location | default ('/etc/maas/.ssh') }}"