aboutsummaryrefslogtreecommitdiffstats
path: root/resources/ansible_roles/nDPI
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2017-04-22 09:06:05 +0800
committerYujun Zhang <zhang.yujunz@zte.com.cn>2017-04-22 10:03:17 +0800
commitbb208192872c841cafdb27769f3680a56b18fa65 (patch)
tree9ebe854c9baa6acb8c9f237111ab0f894f825815 /resources/ansible_roles/nDPI
parentc480cf222cf50e131f9160a39a7f954946b3353d (diff)
Rename folders
* copy -> defaults * render -> custom * roles -> ansible_roles Change-Id: Ia96214691873f3bd8e6c5f9f433292fd912ac46e Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
Diffstat (limited to 'resources/ansible_roles/nDPI')
-rw-r--r--resources/ansible_roles/nDPI/defaults/main.yml12
-rw-r--r--resources/ansible_roles/nDPI/tasks/main.yml67
-rw-r--r--resources/ansible_roles/nDPI/templates/dpi-metrics.j24
3 files changed, 83 insertions, 0 deletions
diff --git a/resources/ansible_roles/nDPI/defaults/main.yml b/resources/ansible_roles/nDPI/defaults/main.yml
new file mode 100644
index 00000000..d8aae81a
--- /dev/null
+++ b/resources/ansible_roles/nDPI/defaults/main.yml
@@ -0,0 +1,12 @@
+#############################################################################
+# Copyright (c) 2017 ZTE Corporation 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
+#############################################################################
+
+---
+nDPI_cwd: "{{ ansible_env.HOME }}/qtip/nDPI"
+nDPI_file: "dpi.pcap"
diff --git a/resources/ansible_roles/nDPI/tasks/main.yml b/resources/ansible_roles/nDPI/tasks/main.yml
new file mode 100644
index 00000000..c53a22fc
--- /dev/null
+++ b/resources/ansible_roles/nDPI/tasks/main.yml
@@ -0,0 +1,67 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation 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: prepare sample pcap file
+ get_url:
+ url: "http://artifacts.opnfv.org/qtip/utilities/test.pcap"
+ dest: "{{ qtip_cache }}/{{ nDPI_file }}"
+ # validate_certs: no # required when using proxy for https
+ run_once: yes
+ delegate_to: localhost
+
+- name: making nDPI temporary directory
+ file:
+ path: "{{ nDPI_cwd }}"
+ state: directory
+
+- name: clone nDPI
+ git:
+ repo: https://github.com/ntop/nDPI.git
+ dest: "{{ nDPI_cwd }}"
+ depth: 1
+ update: no
+
+- name: build nDPI library
+ command: '{{ item }}'
+ with_items:
+ - ./autogen.sh
+ - ./configure
+ - make
+ args:
+ chdir: "{{ nDPI_cwd }}"
+ creates: example/ndpiReader
+
+- name: copy sample packet file
+ copy:
+ src: "{{ qtip_cache}}/{{ nDPI_file }}"
+ dest: "{{ nDPI_cwd }}/example/{{ nDPI_file }}"
+
+- name:
+ command: "./ndpiReader -i {{ nDPI_file }}"
+ args:
+ chdir: "{{ nDPI_cwd }}/example/"
+ register: nDPI_out
+
+- name: collect DPI metrics from nDPI
+ collect:
+ string: "{{ nDPI_out.stdout }}"
+ patterns:
+ # nDPI throughput: 1.46 M pps / 13.69 Gb/sec
+ # TODO(yujunz) convert "M pps" and "K pps" to number
+ - 'nDPI throughput:\s+?(?P<dpi_pps>\d+.\d+.*) \/ (?P<dpi_bps>\d+.\d+.*)$'
+ dump: 'nDPI.log'
+ register: dpi_metrics
+
+- name: create dpi report
+ template:
+ src: dpi-metrics.j2
+ dest: "{{ qtip_results }}/{{ inventory_hostname }}/dpi-metrics"
+ delegate_to: localhost
+ tags: [report]
diff --git a/resources/ansible_roles/nDPI/templates/dpi-metrics.j2 b/resources/ansible_roles/nDPI/templates/dpi-metrics.j2
new file mode 100644
index 00000000..4d6e0b69
--- /dev/null
+++ b/resources/ansible_roles/nDPI/templates/dpi-metrics.j2
@@ -0,0 +1,4 @@
+nDPI throughput
+===============
+
+{{ ('Result:', "{} / {}".format(dpi_metrics.dpi_pps[0], dpi_metrics.dpi_bps[0]))|justify }}