X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=tools%2Fsysteminfo.py;h=f34bcce6a1df4ca31cb25bb3156307f7619ed69e;hb=2cfae5e4569bf595e238a4ccb56a6ef5544a3265;hp=fb1616d4e157692a0c12b713ba6daf6bce8b9b2a;hpb=e3c52e2eeacc1ec995b9492ce8315fb166886fdd;p=vswitchperf.git diff --git a/tools/systeminfo.py b/tools/systeminfo.py index fb1616d4..f34bcce6 100644 --- a/tools/systeminfo.py +++ b/tools/systeminfo.py @@ -1,4 +1,4 @@ -# Copyright 2015-2016 Intel Corporation. +# Copyright 2015-2017 Intel Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,8 +20,10 @@ import platform import subprocess import locale import re +import distro from conf import settings as S +from tools.version import Version def match_line(file_name, pattern): """ loops through given file and returns first line matching given pattern @@ -46,7 +48,7 @@ def get_os(): :returns: Return distro name as a string """ - return ' '.join(platform.dist()) + return ' '.join(distro.linux_distribution()) def get_kernel(): """Get kernel version. @@ -183,7 +185,8 @@ def get_bin_version(binary, regex): :returns: version string or None """ try: - output = subprocess.check_output(binary, shell=True).decode().rstrip('\n') + output = str(subprocess.check_output( + binary, stderr=subprocess.STDOUT, shell=True).decode().rstrip('\n')) except subprocess.CalledProcessError: return None @@ -212,7 +215,7 @@ def get_git_tag(path): return None # This function uses long switch per purpose, so let us suppress pylint warning too-many-branches -# pylint: disable=R0912 +# pylint: disable=too-many-branches, too-many-statements def get_version(app_name): """ Get version of given application and its git tag @@ -225,9 +228,9 @@ def get_version(app_name): 'testpmd' : r'RTE Version: \'\S+ ([0-9.]+)', 'qemu' : r'QEMU emulator version ([0-9.]+)', 'loopback_l2fwd' : os.path.join(S.getValue('ROOT_DIR'), 'src/l2fwd/l2fwd.c'), - 'loopback_testpmd' : os.path.join(S.getValue('TOOLS')['dpdk_src'], - 'lib/librte_eal/common/include/rte_version.h'), 'ixnet' : os.path.join(S.getValue('TRAFFICGEN_IXNET_LIB_PATH'), 'pkgIndex.tcl'), + 'ixia' : os.path.join(S.getValue('TRAFFICGEN_IXIA_ROOT_DIR'), 'lib/ixTcl1.0/ixTclHal.tcl'), + 'trex' : os.path.join(S.getValue('ROOT_DIR'), 'src/trex/trex'), } @@ -252,7 +255,12 @@ def get_version(app_name): # stored at TOOS['dpdk_src'] directory tmp_ver = ['', '', ''] dpdk_16 = False - with open(app_version_file['loopback_testpmd']) as file_: + # TOOLS dictionary is created during runtime and it is not + # available in some vsperf modes (e.g. -m trafficgen), thus + # following definition can't be part of app_version_file dict above + app_file = os.path.join(S.getValue('TOOLS')['dpdk_src'], + 'lib/librte_eal/common/include/rte_version.h') + with open(app_file) as file_: for line in file_: if not line.strip(): continue @@ -301,6 +309,13 @@ def get_version(app_name): app_version = match_line(app_version_file['ixnet'], 'package provide IxTclNetwork') if app_version: app_version = app_version.split(' ')[3] + elif app_name.lower() == 'ixia': + app_version = match_line(app_version_file['ixia'], 'package provide IxTclHal') + if app_version: + app_version = app_version.split(' ')[3] + elif app_name.lower() == 'trex': + app_version = match_line(os.path.join(app_version_file['trex'], 'VERSION'), 'v') + app_git_tag = get_git_tag(app_version_file['trex']) elif app_name.lower() == 'xena': try: app_version = S.getValue('XENA_VERSION') @@ -322,7 +337,7 @@ def get_version(app_name): app_version = 'NA' app_git_tag = 'NA' - return {'name' : app_name, 'version' : app_version, 'git_tag' : app_git_tag} + return Version(app_name, app_version, app_git_tag) def get_loopback_version(loopback_app_name): """ Get version of given guest loopback application and its git tag @@ -331,5 +346,5 @@ def get_loopback_version(loopback_app_name): version or git tag are not known or not applicaple, than None is returned for any unknown value """ version = get_version("loopback_{}".format(loopback_app_name)) - version['name'] = loopback_app_name + version.set_value('name', loopback_app_name) return version