CORD-1750 Upgrade OFDPA to OFDPA 3.0 EA4

Change-Id: Ieb79e766f037d7981fefcde6936b303021488b83
diff --git a/roles/fabric-switch/tasks/main.yml b/roles/fabric-switch/tasks/main.yml
index 041f954..97327bc 100644
--- a/roles/fabric-switch/tasks/main.yml
+++ b/roles/fabric-switch/tasks/main.yml
@@ -13,7 +13,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 ---
 - name: Generate DPID
   shell: ifconfig ma1 | grep HWaddr | awk '{ print "0x0000"$5 }' | sed s/://g
@@ -26,20 +25,20 @@
     controller_ip: "onos-fabric"
 
 - name: Verify Openflow Agent
-  shell: which ofdpa | wc -w
+  shell: which ofagentapp | wc -w
   register: ofdpa_exists
   changed_when: false
 
 - name: Openflow Agent Version
-  command: ofdpa --version
+  command: ofagentapp --version
   register: ofdpa_version
   changed_when: false
   when: ofdpa_exists.stdout != "0"
 
-# Note: This is the version number of OFDPA 3.0 EA0
+# Note: This is the version number of OFDPA 3.0 EA4
 - name: Version 2.0.4.0 Openflow Agent
   include: ofdpa.yml
-  when: ofdpa_exists.stdout == "0" or ofdpa_version.stdout.find('version 2.0.4.0') == -1
+  when: ofdpa_exists.stdout == "0" or ofdpa_version.stderr.find('version 2.0.4.0') == -1
 
 - name: Utilities Scripts
   template:
@@ -49,10 +48,8 @@
     group: root
     mode: "0755"
   with_items:
-    - purge
     - killit
     - connect
-    - reset
   register: utils
 
 - name: Authorize SSH Key
diff --git a/roles/fabric-switch/tasks/ofdpa.yml b/roles/fabric-switch/tasks/ofdpa.yml
index 48b0eff..ace1f2b 100644
--- a/roles/fabric-switch/tasks/ofdpa.yml
+++ b/roles/fabric-switch/tasks/ofdpa.yml
@@ -13,13 +13,26 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
 ---
 - name: Openflow Agent Debian Archive
   get_url:
-    url: https://github.com/onfsdn/atrium-docs/raw/master/16A/ONOS/builds/ofdpa-3.0-ea0_3.0.0.0%2Baccton1.0-1_amd64.deb
+    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
-    dest: /mnt/onl/data/ofdpa-3.0-ea0_3.0.0.0+accton1.0-1_amd64.deb
+    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
+  failed_when: false
+  tags:
+   - skip_ansible_lint # there's no harm to run killall if process is not running
+
+- name: Old OFDPA Is Not Running
+  command: killall -9 brcm-indigo-ofdpa-ofagent
+  failed_when: false
+  tags:
+   - skip_ansible_lint # there's no harm to run killall if process is not running
 
 - name: Verify Service Exists
   stat:
@@ -32,7 +45,14 @@
   service: name=ofdpa state=stopped
   when: ofdpa_stat.stat.exists
 
-- name: Verify Distributeion Release File
+- name: OFDPA 3.0 EA0 Is Not Present
+  apt:
+    name: ofdpa-3.0-ea0
+    state: absent
+    force: yes
+    purge: yes
+
+- name: Verify Distribution Release File
   stat:
     path: /etc/lsb-release
   register: lsb_stat
@@ -45,11 +65,6 @@
   changed_when: false
   failed_when: false
 
-- name: Openflow Agent
-  apt: deb="/mnt/onl/data/ofdpa-3.0-ea0_3.0.0.0+accton1.0-1_amd64.deb" force=true
+- 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: OpenFlow Agent Started
-  service: name=ofdpa state=started
-  when: not lsb_stat.stat.exists or dist.stdout == "0"
-
diff --git a/roles/fabric-switch/templates/connect b/roles/fabric-switch/templates/connect
index 8fa37e8..73f2911 100755
--- a/roles/fabric-switch/templates/connect
+++ b/roles/fabric-switch/templates/connect
@@ -18,7 +18,7 @@
 done
 
 if [ $BG -eq 1 ]; then
-  nohup brcm-indigo-ofdpa-ofagent --dpid={{ switch_id }} --controller=$IP 2>&1 > connect.log &
+  nohup launcher ofagentapp -i {{ switch_id }} -t $IP 2>&1 > connect.log &
 else
-  brcm-indigo-ofdpa-ofagent --dpid={{ switch_id }} --controller=$IP
+  launcher ofagentapp -i {{ switch_id }} -t $IP
 fi
diff --git a/roles/fabric-switch/templates/killit b/roles/fabric-switch/templates/killit
index 2ed34a1..fdc10bf 100755
--- a/roles/fabric-switch/templates/killit
+++ b/roles/fabric-switch/templates/killit
@@ -1,3 +1,3 @@
 #!/bin/bash
 
-killall -9 brcm-indigo-ofdpa-ofagent
+killall ofagentapp
diff --git a/roles/fabric-switch/templates/purge b/roles/fabric-switch/templates/purge
deleted file mode 100755
index 720dcb4..0000000
--- a/roles/fabric-switch/templates/purge
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-/usr/bin/client_cfg_purge
diff --git a/roles/fabric-switch/templates/reset b/roles/fabric-switch/templates/reset
deleted file mode 100755
index 4f58bd5..0000000
--- a/roles/fabric-switch/templates/reset
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-./killit
-./purge
-service ofdpa restart
-./purge
-
diff --git a/roles/head-node/files/commands/cord-prov b/roles/head-node/files/commands/cord-prov
index a0881fe..f7136cc 100755
--- a/roles/head-node/files/commands/cord-prov
+++ b/roles/head-node/files/commands/cord-prov
@@ -6,7 +6,7 @@
 usage() {
     echo "usage: $PROG <sub-command> [options]"
     echo "    list    display the provisioning status of all nodes"
-    echo "    show    display the provisiniong status of a single node"
+    echo "    show    display the provisioning status of a single node"
     echo "    delete  delete node(s) provisioning state"
     echo "    help    this message"
 }
diff --git a/roles/head-node/files/commands/cord-switch b/roles/head-node/files/commands/cord-switch
index 2f92137..859e527 100755
--- a/roles/head-node/files/commands/cord-switch
+++ b/roles/head-node/files/commands/cord-switch
@@ -1,5 +1,5 @@
 #!/bin/bash
-#D provides access to the CORD POD swtich identification service
+#D provides access to the CORD POD switch identification service
 
 PROG=$(echo $(basename $0) | sed -e 's/^cord-/cord /g')
 
diff --git a/switchq/switchq.go b/switchq/switchq.go
index c2adab2..7d3022b 100644
--- a/switchq/switchq.go
+++ b/switchq/switchq.go
@@ -36,11 +36,11 @@
 	VendorsURL      string `default:"file:///switchq/vendors.json" envconfig:"VENDORS_URL" desc:"URL that specifies supported vendor OUI information"`
 	AddressURL      string `default:"file:///switchq/dhcp_harvest.inc" envconfig:"ADDRESS_URL" desc:"URL of service or file from which to query IP information"`
 	PollInterval    string `default:"1m" envconfig:"POLL_INTERVAL" desc:"how often IP information should be queried and processed"`
-	ProvisionTTL    string `default:"1h" envconfig:"PROVISION_TTL" desc:"duraction to wait for a provisioning request before considering it failed"`
+	ProvisionTTL    string `default:"1h" envconfig:"PROVISION_TTL" desc:"duration to wait for a provisioning request before considering it failed"`
 	ProvisionURL    string `default:"" envconfig:"PROVISION_URL" desc:"URL of provisioning service"`
 	RoleSelectorURL string `default:"" envconfig:"ROLE_SELECTOR_URL" desc:"URL of service to query for switch role"`
 	DefaultRole     string `default:"fabric-switch" envconfig:"DEFAULT_ROLE" desc:"default switch role"`
-	Script          string `default:"do-ansible" desc:"script to run for provisioniner"`
+	Script          string `default:"do-ansible" desc:"script to run for provisioner"`
 	LogLevel        string `default:"warning" envconfig:"LOG_LEVEL" desc:"detail level for logging"`
 	LogFormat       string `default:"text" envconfig:"LOG_FORMAT" desc:"output format for logging, text or json"`
 	Listen          string `default:"" desc:"IP on which to listen for requests"`