aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/dpdk/roles/ins_dpdk/tasks
diff options
context:
space:
mode:
authorchigang <chigang@huawei.com>2017-08-10 10:40:11 +0800
committerchigang <chigang@huawei.com>2017-09-13 20:25:19 +0800
commit193dc2117a1fb96d9fdd98258c1040775a33f033 (patch)
tree07dc0ac2553e6e397cdd3d6d9cf110f5bfab9cd5 /plugins/dpdk/roles/ins_dpdk/tasks
parent28d894c7f577625635ef238a89e5cf53a92017a4 (diff)
Add dpdk plugin
JIRA: COMPASS-550 add OVS-DPDK plugin, there are two roles in this plugin. 1. ins_dpdk is for dpdk installation and hugepages setting. 2. ins_ovs is for openvswitch installation. add dpdk scenario networking configuration example called "network_cfg_dpdk.yaml" Change-Id: Ifd8c1aadc218753f99bc26bb530e7cf9962ad8e3 Signed-off-by: chigang <chigang@huawei.com>
Diffstat (limited to 'plugins/dpdk/roles/ins_dpdk/tasks')
-rw-r--r--plugins/dpdk/roles/ins_dpdk/tasks/dpdk.yml81
-rw-r--r--plugins/dpdk/roles/ins_dpdk/tasks/hugepages.yml45
-rw-r--r--plugins/dpdk/roles/ins_dpdk/tasks/main.yml14
3 files changed, 140 insertions, 0 deletions
diff --git a/plugins/dpdk/roles/ins_dpdk/tasks/dpdk.yml b/plugins/dpdk/roles/ins_dpdk/tasks/dpdk.yml
new file mode 100644
index 00000000..6a08386f
--- /dev/null
+++ b/plugins/dpdk/roles/ins_dpdk/tasks/dpdk.yml
@@ -0,0 +1,81 @@
+# #############################################################################
+# 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
+ - gcc
+ - make
+ - cmake
+ - libpcap0.8
+ - libpcap0.8-dev
+
+- name: git clone DPDK code
+ git:
+ repo: "{{ dpdk_repo }}"
+ dest: "{{ dpdk_dir }}"
+ version: "{{ dpdk_version }}"
+
+- name: Configure DPDK
+ lineinfile:
+ dest: "{{ dpdk_dir }}/config/common_linuxapp"
+ regexp: '^{{ item.key }}='
+ line: "{{ item.key }}={{ item.value }}"
+ with_items:
+ - key: CONFIG_RTE_BUILD_COMBINE_LIBS
+ value: y
+ register: dpdk_config_change
+
+- name: make config DPDK
+ command: make config T=x86_64-native-linuxapp-gcc chdir={{ dpdk_dir }}
+
+- name: Configure PMD
+ lineinfile:
+ dest: "{{ dpdk_dir }}/build/.config"
+ regexp: '^{{ item.key }}='
+ line: "{{ item.key }}={{ item.value }}"
+ with_items:
+ - key: PMD_PCAP
+ value: y
+
+- name: Check if DPDK build exists
+ stat: path={{ dpdk_build }}
+ register: dpdk_build_status
+
+- name: Build DPDK
+ command: make install T=x86_64-native-linuxapp-gcc chdir={{ dpdk_dir }}
+ when: (dpdk_build_status.stat.isdir is not defined) or
+ (dpdk_rebuild is defined) or
+ dpdk_config_change.changed or dpdk_changed.changed
+
+- name: Get dpdk interface device name
+ command: echo "{{ compu_sys_mappings['tenant']['interface'] }}"
+ register: dpdk_device_name
+ when: compu_sys_mappings["tenant"]["type"] == "dpdk"
+
+- debug:
+ msg: "{{ dpdk_device_name }}"
+
+- name: Create DPDK scripts
+ template:
+ src: "templates/{{ item.name }}.j2"
+ dest: "/root/{{ item.name }}"
+ mode: 0755
+ with_items:
+ - name: dpdk_uio.sh
+ dpdk_build: '{{ dpdk_build }}'
+ dpdk_dir: '{{ dpdk_dir }}'
+ device_name: '{{ dpdk_device_name.stdout | default("eth2") }}'
+ - name: dpdk_vfio.sh
+ dpdk_build: '{{ dpdk_build }}'
+ dpdk_dir: '{{ dpdk_dir }}'
+ device_name: '{{ dpdk_device_name.stdout | default("eth2") }}'
diff --git a/plugins/dpdk/roles/ins_dpdk/tasks/hugepages.yml b/plugins/dpdk/roles/ins_dpdk/tasks/hugepages.yml
new file mode 100644
index 00000000..3f41cf03
--- /dev/null
+++ b/plugins/dpdk/roles/ins_dpdk/tasks/hugepages.yml
@@ -0,0 +1,45 @@
+# #############################################################################
+# 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
+# #############################################################################
+---
+# yamllint disable rule:truthy
+- name: Check hugepages
+ shell: grep -q intel_iommu /etc/default/grub
+ register: check_result
+ ignore_errors: True
+# yamllint enable rule:truthy
+
+- name: Config grub
+ lineinfile:
+ dest: /etc/default/grub
+ regexp: '^GRUB_CMDLINE_LINUX_DEFAULT=""'
+ line: "{{ grub_cmdline }}"
+ state: present
+ when: check_result.rc == 1
+
+- name: Update grub
+ shell: update-grub
+ when: check_result.rc == 1
+
+- name: wait a moment
+ command: sleep 5
+ when: check_result.rc == 1
+
+- name: Reboot
+ shell: sleep 2 && shutdown -r now 'Reboot required'
+ become: true
+ async: 1
+ poll: 0
+ when: check_result.rc == 1
+ ignore_errors: true
+
+- name: Wait for reboot
+ local_action:
+ module: wait_for
+ host={{ ansible_eth0.ipv4.address }} port=22 delay=1 timeout=300
+ when: check_result.rc == 1
diff --git a/plugins/dpdk/roles/ins_dpdk/tasks/main.yml b/plugins/dpdk/roles/ins_dpdk/tasks/main.yml
new file mode 100644
index 00000000..923dc3b4
--- /dev/null
+++ b/plugins/dpdk/roles/ins_dpdk/tasks/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
+##############################################################################
+---
+- include: hugepages.yml
+ when: dpdk is defined and dpdk == "Enable"
+
+- include: dpdk.yml
+ when: dpdk is defined and dpdk == "Enable"