initial commit
Change-Id: I5063800f2ddaf90a350325a9186479c25f90f8e1
diff --git a/roles/fabric-switch/files/connect b/roles/fabric-switch/files/connect
new file mode 100755
index 0000000..a114178
--- /dev/null
+++ b/roles/fabric-switch/files/connect
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+BG=0
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ -bg|-background)
+ BG=1
+ esac
+ shift
+done
+
+if [ $BG -eq 1 ]; then
+ nohup brcm-indigo-ofdpa-ofagent --dpid={{ switch_id }} --controller={{ controller_ip }} 2>&1 > connect.log &
+else
+ brcm-indigo-ofdpa-ofagent --dpid={{ switch_id }} --controller={{ controller_ip }}
+fi
diff --git a/roles/fabric-switch/files/killit b/roles/fabric-switch/files/killit
new file mode 100755
index 0000000..2ed34a1
--- /dev/null
+++ b/roles/fabric-switch/files/killit
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+killall -9 brcm-indigo-ofdpa-ofagent
diff --git a/roles/fabric-switch/files/purge b/roles/fabric-switch/files/purge
new file mode 100755
index 0000000..296a8cf
--- /dev/null
+++ b/roles/fabric-switch/files/purge
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+/usr/bin/ofdpa-i.12.1.1/examples/client_cfg_purge
diff --git a/roles/fabric-switch/files/reset b/roles/fabric-switch/files/reset
new file mode 100755
index 0000000..4f58bd5
--- /dev/null
+++ b/roles/fabric-switch/files/reset
@@ -0,0 +1,6 @@
+#!/bin/bash
+./killit
+./purge
+service ofdpa restart
+./purge
+
diff --git a/roles/fabric-switch/meta/main.yml b/roles/fabric-switch/meta/main.yml
new file mode 100644
index 0000000..0bcac2c
--- /dev/null
+++ b/roles/fabric-switch/meta/main.yml
@@ -0,0 +1,14 @@
+---
+galaxy_info:
+ author: Ciena Blueplanet
+ description: Openflow Agent and Basic Utils for Fabric Switch
+ company: Ciena Blueplanet
+ license: Apache 2.0
+ min_ansible_version: 2.0
+ platforms:
+ - name: Ubuntu
+ versions:
+ - trusty
+ galaxy_tags:
+ - openflow
+dependencies: []
diff --git a/roles/fabric-switch/tasks/main.yml b/roles/fabric-switch/tasks/main.yml
new file mode 100644
index 0000000..326219a
--- /dev/null
+++ b/roles/fabric-switch/tasks/main.yml
@@ -0,0 +1,45 @@
+---
+- name: Verify controller_ip Set
+ fail: msg="Please set variable 'controller_ip'. This can be set via a variable file or via the command line using the '--extra-vars' option."
+ when: controller_ip is not defined
+
+- name: Verify switch_id Set
+ fail: msg="Please set variable 'switch_id'. This can be set via a host specific variable file or via the command line using the '--extra-vars' option."
+ when: switch_id is not defined
+
+- name: Openflow Agent Version
+ shell: ofdpa --version
+ register: ofdpa_version
+ changed_when: false
+
+- name: Version I.12.1.1+1.1 Openflow Agent
+ include: ofdpa.yml
+ when: ofdpa_version.stdout.find('version I.12.1.1+1.1') == -1
+
+- name: Utilities Scripts
+ template:
+ src: files/{{ item }}
+ dest: /root
+ owner: root
+ group: root
+ mode: 0755
+ with_items:
+ - purge
+ - killit
+ - connect
+ - reset
+ register: utils
+
+- name: Mark Persistent
+ command: persist {{ item }}
+ with_items:
+ - purge
+ - killit
+ - connect
+ - reset
+ when: utils.changed
+
+- name: Persist
+ command: savepersist
+ when: utils.changed
+ failed_when: false
diff --git a/roles/fabric-switch/tasks/ofdpa.yml b/roles/fabric-switch/tasks/ofdpa.yml
new file mode 100644
index 0000000..2c643e8
--- /dev/null
+++ b/roles/fabric-switch/tasks/ofdpa.yml
@@ -0,0 +1,22 @@
+---
+- name: Openflow Agent Debian Archive
+ get_url:
+ url: http://github.com/ciena/ZeroTouchProvisioning/raw/master/ofdpa-i.12.1.1_12.1.1%2Baccton1.7-1_amd64.deb
+ validate_certs: false
+ dest: /mnt/flash2/ofdpa-i.12.1.1_12.1.1%2Baccton1.7-1_amd64.deb
+
+- name: OpenFlow Agent Stopped
+ service: name=ofdpa state=stopped
+
+- name: Openflow Agent
+ apt: deb="/mnt/flash2/ofdpa-i.12.1.1_12.1.1%2Baccton1.7-1_amd64.deb" force=true
+
+- name: OpenFlow Agent Started
+ service: name=ofdpa state=started
+
+- name: Mark Persist Openflow Agent
+ command: persist /etc/accton/ofdpa.conf
+
+- name: Persist Openflow Agent
+ command: savepersist
+ failed_when: false