Dump collected facts 91/33291/2
authorYujun Zhang <zhang.yujunz@zte.com.cn>
Wed, 12 Apr 2017 07:37:24 +0000 (15:37 +0800)
committerYujun Zhang <zhang.yujunz@zte.com.cn>
Wed, 12 Apr 2017 08:09:49 +0000 (16:09 +0800)
Change-Id: Id0b7b2e94016a73ffcaa2d737af1ca33230b3662
Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
.gitignore
qtip/ansible_library/plugins/action/collect.py
tests/integration/run.yaml
tests/integration/tasks/inxi.yaml

index 64945b8..03de790 100644 (file)
@@ -73,3 +73,9 @@ ChangeLog
 
 # unignore external data
 !/tests/data/**/*
+
+# integration data
+/tests/integration/hosts
+/tests/integration/ssh.cfg
+/tests/integration/reports/*
+!/tests/integration/reports/*.sample
index 88ad0e3..26e813b 100644 (file)
@@ -10,6 +10,7 @@
 ##############################################################################
 
 from collections import defaultdict
+import os
 import re
 
 from ansible.plugins.action import ActionBase
@@ -26,6 +27,10 @@ class ActionModule(ActionBase):
         string = self._task.args.get('string')
         patterns = self._task.args.get('patterns')
 
+        dump = self._task.args.get('dump')
+        if dump is not None:
+            dump_facts(task_vars['inventory_hostname'], [{'name': 'inxi.log', 'content': string}])
+
         return collect(patterns, string)
 
 
@@ -43,3 +48,11 @@ def collect(patterns, string):
                 captured[key].append(value)
 
     return captured
+
+
+def dump_facts(hostname, facts):
+    dump_root = os.path.join('dump', hostname)
+    if not os.path.exists(dump_root):
+        os.mkdir(dump_root)
+    return [{'name': fact['name'], 'result': open(os.path.join(dump_root, fact['name']), 'w+').write(fact['content'])}
+            for fact in facts]
index 7eb141d..d2768d6 100644 (file)
@@ -21,6 +21,7 @@
     include: tasks/inxi.yaml
   - name: ssl metrics
     include: tasks/openssl.yaml
+    tags: [ssl]
 
 - hosts: compute
   tasks:
@@ -59,6 +60,7 @@
                   baseline: 6402.9
     register: qpi_result
     delegate_to: localhost
+    tags: [calculate]
 
 # Generate and publish report
 - hosts: local
@@ -67,4 +69,5 @@
     template: src=templates/system-info.j2 dest=reports/system-info
   - name: create qpi report
     template: src=templates/qpi-report.j2 dest=reports/qpi-report
+    tags: [report]
   # TODO(yujunz) push test result to testapi
index 6c2db6a..47eb2e7 100644 (file)
@@ -14,7 +14,7 @@
 
 - name: check hardware information with inxi
   command: inxi -b -c0 -n
-  register: inxi_log
+  register: inxi_out
 
 # TODO(yujunz) normalize system information, test condition and performance metrics for future data mining
 # e.g. convert "2 Deca core Intel Xeon E5-2650 v3s (-HT-MCP-SMP-) speed/max: 1200/3000 MHz" to
@@ -31,7 +31,7 @@
 #   cache_mb: None
 - name: collect system information from inxi
   collect:
-    string: "{{ inxi_log.stdout }}"
+    string: "{{ inxi_out.stdout }}"
     patterns:
       - '.+\s+Host:\s+(?P<hostname>.+)\sKernel'
       - '.+\sMemory:\s+(?P<memory>.+MB)\s'
@@ -40,4 +40,5 @@
       - '.+\sKernel:\s+(?P<kernel>.+)\sConsole'
       - '.+\s+HDD Total Size:\s+(?P<disk>.+)\s'
       - '.+\sproduct:\s+(?P<product>.+)\sv'
+    dump: 'inix.log'
   register: system_info