From a84cbaaf620fff614a68e0cc95775c45738f14b1 Mon Sep 17 00:00:00 2001
From: Stepan Andrushko <stepanx.andrushko@intel.com>
Date: Wed, 31 Oct 2018 15:58:51 +0200
Subject: Log VM OS version, Sample VNF branch/commit ID

Added debug logs to track VM, Sample VNF details during testing:
 - Virtual machine OS, kernel version;
 - Sample VNF branch, commit ID.

JIRA: YARDSTICK-1499

Change-Id: I243c435809d4541dfdb8c7c3466f50c5d524ac00
Signed-off-by: Stepan Andrushko <stepanx.andrushko@intel.com>
---
 .../tasks/cloudimg_modify_nsb.yml                  |  8 ++++--
 .../build_yardstick_image/tasks/post_build.yml     | 11 --------
 .../roles/download_samplevnfs/defaults/main.yml    |  1 +
 ansible/roles/download_samplevnfs/tasks/main.yml   |  4 +++
 ansible/roles/install_samplevnf/tasks/main.yml     | 32 ++++++++++++++++++++++
 5 files changed, 42 insertions(+), 14 deletions(-)

(limited to 'ansible')

diff --git a/ansible/roles/build_yardstick_image/tasks/cloudimg_modify_nsb.yml b/ansible/roles/build_yardstick_image/tasks/cloudimg_modify_nsb.yml
index 8e2c3a623..65b9b8188 100644
--- a/ansible/roles/build_yardstick_image/tasks/cloudimg_modify_nsb.yml
+++ b/ansible/roles/build_yardstick_image/tasks/cloudimg_modify_nsb.yml
@@ -60,6 +60,11 @@
     loop_var: role_item
   environment: "{{ proxy_env }}"
 
+- include_vars: roles/install_dpdk/defaults/main.yml
+  when: INSTALL_BIN_PATH is undefined
+
+- include_vars: roles/download_samplevnfs/defaults/main.yml
+
 - include_role:
     name: "{{ role_item }}"
   vars:
@@ -72,9 +77,6 @@
     loop_var: role_item
   environment: "{{ proxy_env }}"
 
-- include_vars: roles/install_dpdk/defaults/main.yml
-  when: INSTALL_BIN_PATH is undefined
-
 - name: Install PROX
   include_role:
     name: install_samplevnf
diff --git a/ansible/roles/build_yardstick_image/tasks/post_build.yml b/ansible/roles/build_yardstick_image/tasks/post_build.yml
index abbf57c03..14b7a3d17 100644
--- a/ansible/roles/build_yardstick_image/tasks/post_build.yml
+++ b/ansible/roles/build_yardstick_image/tasks/post_build.yml
@@ -51,17 +51,6 @@
 
 - set_fact:
     imgdest: "/var/lib/libvirt/images/{{ imgfile | basename}}"
-    name: "{{ (imgfile | basename | splitext)[0] }}"
-    ext: "{{ (imgfile | basename | splitext)[1] }}"
-
-- name: Verify if imgfile exists in libvirt images
-  stat:
-    path: "{{ imgdest }}"
-  register: imgdest_stat
-
-- set_fact:
-    imgdest: "/var/lib/libvirt/images/{{ name }}_autogen{{ ext }}"
-  when: imgdest_stat.stat.exists
 
 - name: Copy image to libvirt images
   shell: "cp {{ imgfile }} {{ imgdest }}"
diff --git a/ansible/roles/download_samplevnfs/defaults/main.yml b/ansible/roles/download_samplevnfs/defaults/main.yml
index 5ddc9f0f9..2ae4d6159 100644
--- a/ansible/roles/download_samplevnfs/defaults/main.yml
+++ b/ansible/roles/download_samplevnfs/defaults/main.yml
@@ -14,3 +14,4 @@
 samplevnf_url: "https://git.opnfv.org/samplevnf"
 samplevnf_dest: "{{ clone_dest }}/samplevnf"
 samplevnf_version: "47123bfc1b3c0d0b01884aebbce1a3e09ad7ddb0"
+path_json: "{{ INSTALL_BIN_PATH }}/{{ inventory_hostname | basename }}_sample_vnf.json"
diff --git a/ansible/roles/download_samplevnfs/tasks/main.yml b/ansible/roles/download_samplevnfs/tasks/main.yml
index e9d4142c9..f98f2a42d 100644
--- a/ansible/roles/download_samplevnfs/tasks/main.yml
+++ b/ansible/roles/download_samplevnfs/tasks/main.yml
@@ -27,3 +27,7 @@
 
 - set_fact:
     samplevnf_path: "{{ samplevnf_dest }}"
+
+- file:
+   dest: "{{ path_json }}"
+   state: absent
diff --git a/ansible/roles/install_samplevnf/tasks/main.yml b/ansible/roles/install_samplevnf/tasks/main.yml
index b5d33f668..ad147b00f 100644
--- a/ansible/roles/install_samplevnf/tasks/main.yml
+++ b/ansible/roles/install_samplevnf/tasks/main.yml
@@ -56,3 +56,35 @@
     # make executable
     mode: 0755
 
+- set_fact:
+    path_vnf: "{{ INSTALL_BIN_PATH }}/{{ vnf_app_names[vnf_name]}}"
+
+- stat:
+    path: "{{ path_vnf }}"
+    checksum_algorithm: md5
+  register: path_vnf_var
+
+- stat:
+    path: "{{ path_json }}"
+  register: path_json_var
+
+- name: Fetch from remote
+  fetch:
+    src: "{{ path_json }}"
+    dest: "{{ path_json }}"
+    flat: yes
+  when: path_json_var.stat.exists
+
+- name: Read from json
+  set_fact:
+    json_vars: "{{ lookup('file', path_json) | from_json }}"
+  when: path_json_var.stat.exists
+
+- set_fact:
+    json_vars: "{{ json_vars | default([]) | combine({ vnf_app_names[vnf_name]: {'branch_commit': samplevnf_version, 'path_vnf': path_vnf, 'md5': path_vnf_var.stat.checksum }}) }}"
+
+- name: Update json file
+  copy:
+    content: "{{ json_vars | to_nice_json }}"
+    dest: "{{ path_json }}"
+    mode: 0755
-- 
cgit