CORD-1511 Use OVS instead of CPqD

Change-Id: I89315b9155774f697c3ee0768f318e351fa23b38
diff --git a/ansible/roles/ciab-ovs/defaults/main.yml b/ansible/roles/ciab-ovs/defaults/main.yml
new file mode 100644
index 0000000..38c9652
--- /dev/null
+++ b/ansible/roles/ciab-ovs/defaults/main.yml
@@ -0,0 +1,46 @@
+# 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.
+
+ovs_bridges:
+  - leaf1
+#  - leaf2
+  - spine1
+#  - spine2
+
+ovs_patch_ports:
+  - { bridge: leaf1, port: leaf1-spine1, peer: spine1-leaf1 }
+#  - { bridge: leaf2, port: leaf2-spine1, peer: spine1-leaf2 }
+#  - { bridge: leaf1, port: leaf1-spine2, peer: spine2-leaf1 }
+#  - { bridge: leaf2, port: leaf2-spine2, peer: spine2-leaf2 }
+  - { bridge: spine1, port: spine1-leaf1, peer: leaf1-spine1 }
+#  - { bridge: spine2, port: spine2-leaf1, peer: leaf1-spine2 }
+#  - { bridge: spine1, port: spine1-leaf2, peer: leaf2-spine1 }
+#  - { bridge: spine2, port: spine2-leaf2, peer: leaf2-spine2 }
+
+enable_fabric: False
+
+ovs_controller_ip: 10.100.198.201
+ovs_controller_port: 6653
+
+ovs_packages:
+  - openvswitch-switch
+  - openvswitch-common
+
+ovs_fabric_packages:
+  - name: openvswitch-common_2.5.3-1_amd64.deb
+    url: http://www.vicci.org/openvswitch-2.5.3/openvswitch-common_2.5.3-1_amd64.deb
+    checksum: sha256:30c159c4a13d4eab75acdb04dca7acc0beee5dd0465b1b5b2e31a3a625e4c248
+  - name: openvswitch-switch_2.5.3-1_amd64.deb
+    url: http://www.vicci.org/openvswitch-2.5.3/openvswitch-switch_2.5.3-1_amd64.deb
+    checksum: sha256:b68e63f6408e1392bb0457760c77189c9b3380e1b354fdaec17e119e09ab5db6
diff --git a/ansible/roles/ciab-ovs/tasks/main.yml b/ansible/roles/ciab-ovs/tasks/main.yml
new file mode 100644
index 0000000..d5bb41a
--- /dev/null
+++ b/ansible/roles/ciab-ovs/tasks/main.yml
@@ -0,0 +1,79 @@
+# 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: Remove old OVS
+  apt:
+    name: "{{ item }}"
+    state: absent
+  with_items:
+    - openvswitch-switch
+    - openvswitch-common
+  when: enable_fabric
+
+- name: Install default OVS
+  apt:
+    name: "{{ item }}"
+    state: present
+  with_items: "{{ ovs_packages }}"
+  when: not enable_fabric
+
+- name: (fabric) Download OVS 2.5.3 packages
+  get_url:
+    url: "{{ item.url }}"
+    checksum: "{{ item.checksum }}"
+    dest: "/tmp/{{ item.name }}"
+  with_items: "{{ ovs_fabric_packages }}"
+  when: enable_fabric
+
+- name: (fabric) Install OVS 2.5.3
+  apt:
+    deb: "/tmp/{{ item.name }}"
+    state: present
+  with_items: "{{ ovs_fabric_packages }}"
+  when: enable_fabric
+
+- name: Create OVS bridges for CiaB
+  openvswitch_bridge:
+    bridge: "{{ item }}"
+    state: present
+  with_items: "{{ ovs_bridges }}"
+
+- name: Create patch ports
+  openvswitch_port:
+    bridge: "{{ item.bridge }}"
+    port: "{{ item.port }}"
+    set: "Interface {{ item.port }} type=patch"
+  with_items: "{{ ovs_patch_ports }}"
+
+- name: Create peers
+  openvswitch_port:
+    bridge: "{{ item.bridge }}"
+    port: "{{ item.port }}"
+    set: "Interface {{ item.port }} options:peer={{ item.peer }}"
+  with_items: "{{ ovs_patch_ports }}"
+
+# "set" argument to openvswitch_bridge wasn't working...
+- name: Set bridges to OpenFlow 1.3
+  command: ovs-vsctl set bridge {{ item }} protocols=OpenFlow13
+  when: enable_fabric
+  with_items: "{{ ovs_bridges }}"
+  tags:
+    - skip_ansible_lint # running a sub job
+
+- name: Add ONOS fabric controller
+  command: ovs-vsctl set-controller {{ item }} tcp:{{ ovs_controller_ip }}:{{ ovs_controller_port }}
+  when: enable_fabric
+  with_items: "{{ ovs_bridges }}"
+  tags:
+    - skip_ansible_lint # running a sub job
diff --git a/ansible/roles/ovs-deb-packages/defaults/main.yml b/ansible/roles/ovs-deb-packages/defaults/main.yml
new file mode 100644
index 0000000..5a7aafc
--- /dev/null
+++ b/ansible/roles/ovs-deb-packages/defaults/main.yml
@@ -0,0 +1,15 @@
+# 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.
+
+ovs_version: 2.5.3
\ No newline at end of file
diff --git a/ansible/roles/ovs-deb-packages/tasks/main.yml b/ansible/roles/ovs-deb-packages/tasks/main.yml
new file mode 100644
index 0000000..464ed9b
--- /dev/null
+++ b/ansible/roles/ovs-deb-packages/tasks/main.yml
@@ -0,0 +1,49 @@
+# 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: Install prereqs for building OVS
+  apt:
+    name: "{{ item }}"
+    state: present
+    update_cache: yes
+  become: yes
+  with_items:
+    - build-essential
+    - fakeroot
+    - graphviz
+    - autoconf
+    - automake
+    - bzip2
+    - debhelper
+    - dh-autoreconf
+    - libssl-dev
+    - libtool
+    - openssl
+    - procps
+    - python-all
+    - python-qt4
+    - python-twisted-conch
+    - python-zopeinterface
+
+- name: Download and unarchive OVS tarball
+  unarchive:
+    src: http://openvswitch.org/releases/openvswitch-{{ ovs_version }}.tar.gz
+    dest: /tmp/
+    remote_src: yes
+
+- name: Build OVS .deb packages
+  command: fakeroot debian/rules binary
+  args:
+    chdir: /tmp/openvswitch-{{ ovs_version }}
+    creates: /tmp/openvswitch-switch_{{ ovs_version }}-1_amd64.deb