From 9ec7cf4447f5333097065a35a7d8e1de05b0425c Mon Sep 17 00:00:00 2001 From: Long Li Date: Fri, 20 Mar 2020 18:24:32 +0800 Subject: [PATCH] Update engtools to use python3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change spec and scripts to only use python3 explicitly Verification: 1. Regard as the README,in development docker environment, run ./patch-engtools.sh, it will generate the ENGTOOLS-20.01.patch if we scp the patch to controller, we could sw-patch upload and sw-apply it successfully. 2. The engtools-1.0-4.tis.noarch.rpm is not built into bootimage by default thus if we package it into bootimage when to verify it. 1). Run some bash script, such as ceph.sh, memstats.sh, netstats.sh and so on it will display the collect system resource information. 2). The service of collect-engtools.service could start and stop without problem 3). If we run the modified python which we have changed to python3. python3 buddyinfo.py it will deplay the resource information python3 live_stream.py the log of livestream.log will display collect information This package only be packaged into bootimage when we need it to collect system resource information. Change-Id: I9bd77e34650e200f0c65db966635a8ebcdc584aa Story: 2007106 Task: 39112 Depends-on: https://review.opendev.org/#/c/712218/ Depends-on: https://review.opendev.org/#/c/714072/ Signed-off-by: Long Li --- tools/engtools/hostdata-collectors/README | 2 +- .../hostdata-collectors/centos/collect-engtools.spec | 2 ++ tools/engtools/hostdata-collectors/patch-engtools.sh | 4 ++-- tools/engtools/hostdata-collectors/scripts/buddyinfo.py | 4 ++-- .../engtools/hostdata-collectors/scripts/cfg/engtools.conf | 2 +- tools/engtools/hostdata-collectors/scripts/live_stream.py | 6 +++--- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/engtools/hostdata-collectors/README b/tools/engtools/hostdata-collectors/README index b33a91d6..6daf1d40 100644 --- a/tools/engtools/hostdata-collectors/README +++ b/tools/engtools/hostdata-collectors/README @@ -2,7 +2,7 @@ The Engineering tools is meant to be installed as a patch. Therefore, the RPM is of the build but is not included in the image. Assuming your development environment is fully set up, simply run patch-engtools.sh to generate the patch: -In this directory ($MY_REPO/stx/middleware/util/recipes-common/engtools/hostdata-collectors), +In this directory ($MY_REPO/stx/utilities/tools/engtools/hostdata-collectors), enter the command: >./patch-engtools.sh diff --git a/tools/engtools/hostdata-collectors/centos/collect-engtools.spec b/tools/engtools/hostdata-collectors/centos/collect-engtools.spec index 288577bc..1d83efb3 100644 --- a/tools/engtools/hostdata-collectors/centos/collect-engtools.spec +++ b/tools/engtools/hostdata-collectors/centos/collect-engtools.spec @@ -12,6 +12,8 @@ Source: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: systemd Requires: iperf3 +Requires: python36-six +Requires: python36-psutil %description This package contains data collection tools to monitor host performance. diff --git a/tools/engtools/hostdata-collectors/patch-engtools.sh b/tools/engtools/hostdata-collectors/patch-engtools.sh index dbb80682..88c2cd32 100755 --- a/tools/engtools/hostdata-collectors/patch-engtools.sh +++ b/tools/engtools/hostdata-collectors/patch-engtools.sh @@ -14,7 +14,7 @@ if [ $? -ne 0 ]; then exit 1 fi -source ${MY_REPO}/stx/middleware/recipes-common/build-info/release-info.inc +source ${MY_REPO}/stx/utilities/utilities/build-info/release-info.inc #TiS_REL="16.10" #PATCH_ID="ENGTOOLS-${TiS_REL}" PATCH_ID="ENGTOOLS-${PLATFORM_RELEASE}" @@ -23,7 +23,7 @@ PWD=$(pwd) # Create CGCS Patch cd ${MY_WORKSPACE} -PATCH_BUILD=${MY_REPO}/stx/stx-update/extras/scripts/patch_build.sh +PATCH_BUILD=${MY_REPO}/stx/update/extras/scripts/patch_build.sh ${PATCH_BUILD} --id ${PATCH_ID} --reboot-required=N \ --summary "System engineering data collection and analysis tools." \ --desc "System engineering data collection and analysis tools." \ diff --git a/tools/engtools/hostdata-collectors/scripts/buddyinfo.py b/tools/engtools/hostdata-collectors/scripts/buddyinfo.py index d23b404b..3cf3427d 100644 --- a/tools/engtools/hostdata-collectors/scripts/buddyinfo.py +++ b/tools/engtools/hostdata-collectors/scripts/buddyinfo.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 textwidth=79 autoindent """ @@ -8,7 +8,7 @@ Last author: lmwangi at gmail com Displays the available memory fragments by querying /proc/buddyinfo Example: -# python buddyinfo.py +# python3 buddyinfo.py """ import optparse import os diff --git a/tools/engtools/hostdata-collectors/scripts/cfg/engtools.conf b/tools/engtools/hostdata-collectors/scripts/cfg/engtools.conf index aefc62ae..5901fd80 100644 --- a/tools/engtools/hostdata-collectors/scripts/cfg/engtools.conf +++ b/tools/engtools/hostdata-collectors/scripts/cfg/engtools.conf @@ -87,7 +87,7 @@ OPEN_STACK_SERVICE_LIST=nova cinder aodh barbican ceilometer heat glance ceph ho SKIP_LIST=ps top sh curl awk wc sleep lsof cut grep ip tail su [ExcludeList] -EXCLUDE_LIST=python python2 bash perl sudo init +EXCLUDE_LIST=python python2 python3 bash perl sudo init [ApiStatsConstantPorts] DB_PORT_NUMBER=5432 diff --git a/tools/engtools/hostdata-collectors/scripts/live_stream.py b/tools/engtools/hostdata-collectors/scripts/live_stream.py index 3fc10a50..c32dd745 100644 --- a/tools/engtools/hostdata-collectors/scripts/live_stream.py +++ b/tools/engtools/hostdata-collectors/scripts/live_stream.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 """ Copyright (c) 2017 Wind River Systems, Inc. @@ -1478,14 +1478,14 @@ if __name__ == "__main__": # use first interface if not specified in engtools.conf if external_if == "" or external_if is None: p = Popen("ifconfig", shell=True, stdout=PIPE) - external_if = p.stdout.readline().split(":")[0] + external_if = p.stdout.readline().decode().split(":")[0] p.kill() appendToFile("/tmp/livestream.log", "-External interface for {}: {}".format(node, external_if)) # enable IP forwarding p = Popen("sysctl -w net.ipv4.ip_forward=1 > /dev/null", shell=True) p.communicate() p = Popen("iptables -t nat -L --line-numbers", shell=True, stdout=PIPE) - tmp = [line.strip("\n") for line in p.stdout.readlines()] + tmp = [line.decode().strip("\n") for line in p.stdout.readlines()] # entries need to be removed in reverse order for line in reversed(tmp): formatted_line = " ".join(line.strip("\n").split()[1:])