summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/metadata.py
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2017-01-13 15:12:37 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-19 22:47:22 +0000
commit8d51f62cd4933013b11b6812f7585810cc035fbd (patch)
tree7cb1190fdb0caf37ecb0fca2b1a8cac106052573 /meta/lib/oeqa/utils/metadata.py
parent2cd76135824095e5d1bff89bca5d26d9dc16847e (diff)
downloadpoky-8d51f62cd4933013b11b6812f7585810cc035fbd.tar.gz
oeqa.utils.metadata: re-organise host distro information
Put all host distro data under one <host_distro> element. In addition take the data directly from /etc/os-release instead of the "lsb API". The /etc/os-release file is virtually ubiquitous, now, and using its field names and values provides a more standardized and extensible format. [YOCTO #10590] (From OE-Core rev: 98cad0b4063772dad94fea96edce1a5422256c32) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils/metadata.py')
-rw-r--r--meta/lib/oeqa/utils/metadata.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/meta/lib/oeqa/utils/metadata.py b/meta/lib/oeqa/utils/metadata.py
index 5d8bf84755..2316841e0f 100644
--- a/meta/lib/oeqa/utils/metadata.py
+++ b/meta/lib/oeqa/utils/metadata.py
@@ -10,11 +10,22 @@ from collections.abc import MutableMapping
10from xml.dom.minidom import parseString 10from xml.dom.minidom import parseString
11from xml.etree.ElementTree import Element, tostring 11from xml.etree.ElementTree import Element, tostring
12 12
13from oe.lsb import distro_identifier
14from oeqa.utils.commands import runCmd, get_bb_var, get_bb_vars 13from oeqa.utils.commands import runCmd, get_bb_var, get_bb_vars
15 14
16metadata_vars = ['MACHINE', 'DISTRO', 'DISTRO_VERSION'] 15metadata_vars = ['MACHINE', 'DISTRO', 'DISTRO_VERSION']
17 16
17def get_os_release():
18 """Get info from /etc/os-release as a dict"""
19 data = OrderedDict()
20 os_release_file = '/etc/os-release'
21 if not os.path.exists(os_release_file):
22 return None
23 with open(os_release_file) as fobj:
24 for line in fobj:
25 key, value = line.split('=', 1)
26 data[key.strip().lower()] = value.strip().strip('"')
27 return data
28
18def metadata_from_bb(): 29def metadata_from_bb():
19 """ Returns test's metadata as OrderedDict. 30 """ Returns test's metadata as OrderedDict.
20 31
@@ -27,10 +38,15 @@ def metadata_from_bb():
27 data_dict = get_bb_vars(metadata_vars) 38 data_dict = get_bb_vars(metadata_vars)
28 for var in metadata_vars: 39 for var in metadata_vars:
29 info_dict[var.lower()] = data_dict[var] 40 info_dict[var.lower()] = data_dict[var]
30 host_distro= distro_identifier() 41
31 host_distro, _, host_distro_release = host_distro.partition('-') 42 # Host distro information
32 info_dict['host_distro'] = host_distro 43 os_release = get_os_release()
33 info_dict['host_distro_release'] = host_distro_release 44 if os_release:
45 info_dict['host_distro'] = OrderedDict()
46 for key in ('id', 'version_id', 'pretty_name'):
47 if key in os_release:
48 info_dict['host_distro'][key] = os_release[key]
49
34 info_dict['layers'] = get_layers(get_bb_var('BBLAYERS')) 50 info_dict['layers'] = get_layers(get_bb_var('BBLAYERS'))
35 return info_dict 51 return info_dict
36 52