aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/dpdk/roles/ins_ovs
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/dpdk/roles/ins_ovs')
-rw-r--r--plugins/dpdk/roles/ins_ovs/tasks/main.yml11
-rw-r--r--plugins/dpdk/roles/ins_ovs/tasks/ovs.yml97
-rw-r--r--plugins/dpdk/roles/ins_ovs/templates/start_ovs_vswitchd.sh.j24
-rw-r--r--plugins/dpdk/roles/ins_ovs/templates/start_ovsdb_server.sh.j24
-rw-r--r--plugins/dpdk/roles/ins_ovs/vars/main.yml14
5 files changed, 130 insertions, 0 deletions
diff --git a/plugins/dpdk/roles/ins_ovs/tasks/main.yml b/plugins/dpdk/roles/ins_ovs/tasks/main.yml
new file mode 100644
index 00000000..6570d06c
--- /dev/null
+++ b/plugins/dpdk/roles/ins_ovs/tasks/main.yml
@@ -0,0 +1,11 @@
+# #############################################################################
+# Copyright (c) 2016-2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+# #############################################################################
+---
+- include: ovs.yml
+ when: dpdk is defined and dpdk == "Enable"
diff --git a/plugins/dpdk/roles/ins_ovs/tasks/ovs.yml b/plugins/dpdk/roles/ins_ovs/tasks/ovs.yml
new file mode 100644
index 00000000..9f728696
--- /dev/null
+++ b/plugins/dpdk/roles/ins_ovs/tasks/ovs.yml
@@ -0,0 +1,97 @@
+# #############################################################################
+# Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+# #############################################################################
+---
+- name: install prerequisites package
+ apt:
+ name: "{{ item }}"
+ state: present
+ with_items:
+ - git
+ - libnuma-dev
+ - dh-autoreconf
+ - python-pip
+
+- name: git clone open-vswitch code
+ git:
+ repo: "{{ ovs_repo }}"
+ dest: "{{ ovs_dir }}"
+ version: "{{ ovs_version }}"
+
+- name: install prerequisites package
+ pip:
+ name: six
+
+- name: Check if OVS configure script exists
+ stat: path={{ ovs_dir }}/configure
+ register: ovs_config_status
+
+- name: Bootstrap OVS if required
+ command: ./boot.sh chdir={{ ovs_dir }}
+ when: ovs_config_status.stat.exists == false or (ovs_rebuild is defined) or ovs_changed.changed
+
+- name: Check if OVS Makefile exists
+ stat: path={{ ovs_dir }}/Makefile
+ register: ovs_makefile_status
+
+# yamllint disable rule:line-length
+- name: Configure OVS
+ command: ./configure --with-dpdk={{ dpdk_build }} CFLAGS="-g -O2 -Wno-cast-align" chdir={{ ovs_dir }}
+ when: ovs_makefile_status.stat.exists == false or (ovs_rebuild is defined) or ovs_changed.changed
+# yamllint enable rule:line-length
+
+- name: Check if OVS distribution files exists
+ stat: path={{ ovs_dir }}/distfiles
+ register: ovs_distfiles_status
+
+- name: Build OVS
+ command: make CFLAGS='-O3 -march=native' chdir={{ ovs_dir }}
+ when: ovs_distfiles_status.stat.exists == false or (ovs_rebuild is defined) or ovs_changed.changed
+
+- name: Check if OVS tools are installed
+ stat: path=/usr/local/bin/ovsdb-tool
+ register: ovs_tools_status
+
+- name: Install OVS tools
+ command: make install chdir={{ ovs_dir }}
+ when: ovs_tools_status.stat.exists == false or (ovs_rebuild is defined) or ovs_changed.changed
+
+- name: Create OVS scripts
+ template:
+ src: "templates/{{ item }}.j2"
+ dest: "/root/{{ item }}"
+ mode: 0755
+ with_items:
+ - start_ovs_vswitchd.sh
+ - start_ovsdb_server.sh
+
+- name: Create folders
+ file: path={{ item }} state=directory
+ with_items:
+ - /usr/local/etc/openvswitch
+ - /usr/local/var/run/openvswitch
+
+- name: Clear database configuration if required
+ file: path=/usr/local/etc/openvswitch/conf.db state=absent
+ when: ovs_rebuild is defined or ovs_changed.changed
+
+- name: Check if database configuration exists
+ stat: path=/usr/local/etc/openvswitch/conf.db
+ register: ovs_dbconfig_status
+
+# yamllint disable rule:line-length
+- name: Create database configuration
+ command: ovsdb-tool create /usr/local/etc/openvswitch/conf.db /usr/local/share/openvswitch/vswitch.ovsschema
+ when: ovs_dbconfig_status.stat.exists == false
+# yamllint enable rule:line-length
+
+- name: Start ovsdb Server
+ command: /root/start_ovsdb_server.sh
+
+- name: Start OVS vswitchd with DPDK support enabled
+ command: /root/start_ovs_vswitchd.sh
diff --git a/plugins/dpdk/roles/ins_ovs/templates/start_ovs_vswitchd.sh.j2 b/plugins/dpdk/roles/ins_ovs/templates/start_ovs_vswitchd.sh.j2
new file mode 100644
index 00000000..c1504177
--- /dev/null
+++ b/plugins/dpdk/roles/ins_ovs/templates/start_ovs_vswitchd.sh.j2
@@ -0,0 +1,4 @@
+#!/bin/bash
+export DB_SOCK=/usr/local/var/run/openvswitch/db.sock
+sudo ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true
+sudo ovs-vswitchd unix:$DB_SOCK --pidfile --detach
diff --git a/plugins/dpdk/roles/ins_ovs/templates/start_ovsdb_server.sh.j2 b/plugins/dpdk/roles/ins_ovs/templates/start_ovsdb_server.sh.j2
new file mode 100644
index 00000000..8bc408b6
--- /dev/null
+++ b/plugins/dpdk/roles/ins_ovs/templates/start_ovsdb_server.sh.j2
@@ -0,0 +1,4 @@
+#!/bin/bash
+ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
+ --remote=db:Open_vSwitch,Open_vSwitch,manager_options \
+ --pidfile --detach
diff --git a/plugins/dpdk/roles/ins_ovs/vars/main.yml b/plugins/dpdk/roles/ins_ovs/vars/main.yml
new file mode 100644
index 00000000..c5f14d4e
--- /dev/null
+++ b/plugins/dpdk/roles/ins_ovs/vars/main.yml
@@ -0,0 +1,14 @@
+##############################################################################
+# Copyright (c) 2016-2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+---
+dpdk_dir: /root/dpdk
+dpdk_build: '{{ dpdk_dir }}/x86_64-native-linuxapp-gcc'
+ovs_dir: /root/ovs
+ovs_repo: https://github.com/openvswitch/ovs.git
+ovs_version: v2.7.2