From d755461e7a2011a0bcee483bb6e890cb699c3275 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Wed, 8 Jun 2022 15:29:55 -0700 Subject: [PATCH] EX-5347 lipe: update lpcc to python3 Update the lpcc utility to use python 3. Test-Parameters: trivial clientdistro=ubuntu2204 env=SANITY_PCC_EXCEPT="15 16 27 39 101a 201" testlist=sanity-pcc Test-Parameters: trivial clientdistro=ubuntu2004 env=SANITY_PCC_EXCEPT="101a" testlist=sanity-pcc Signed-off-by: John L. Hammond Signed-off-by: Lei Feng Change-Id: I690ef4362cbdd0118419ab37a15127619a860178 Reviewed-on: https://review.whamcloud.com/47553 Reviewed-by: Jian Yu Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lipe/debian/control | 2 +- lipe/debian/control.main | 2 +- lipe/lpcc | 17 ++++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lipe/debian/control b/lipe/debian/control index 39ae314..292be7a 100644 --- a/lipe/debian/control +++ b/lipe/debian/control @@ -12,5 +12,5 @@ Package: lipe-lpcc Section: utils Architecture: all Priority: optional -Depends: ${shlibs:Depends}, ${misc:Depends}, e2fsprogs (>= 1.42.13.wc6), python-yaml +Depends: ${shlibs:Depends}, ${misc:Depends}, e2fsprogs (>= 1.42.13.wc6), python3-yaml Description: Tools for LPCC (Lustre Persisted Client Cache) diff --git a/lipe/debian/control.main b/lipe/debian/control.main index 39ae314..292be7a 100644 --- a/lipe/debian/control.main +++ b/lipe/debian/control.main @@ -12,5 +12,5 @@ Package: lipe-lpcc Section: utils Architecture: all Priority: optional -Depends: ${shlibs:Depends}, ${misc:Depends}, e2fsprogs (>= 1.42.13.wc6), python-yaml +Depends: ${shlibs:Depends}, ${misc:Depends}, e2fsprogs (>= 1.42.13.wc6), python3-yaml Description: Tools for LPCC (Lustre Persisted Client Cache) diff --git a/lipe/lpcc b/lipe/lpcc index 05a8a7a..462efff 100755 --- a/lipe/lpcc +++ b/lipe/lpcc @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # Copyright (c) 2021 DataDirect Networks, Inc. # All Rights Reserved. # Author: flei@ddn.com @@ -7,7 +7,6 @@ Manage all PCC devices and services """ -from __future__ import print_function import argparse import errno @@ -218,7 +217,7 @@ class LpccService: cmdline = ['lctl', 'pcc', 'list', self.lpcc_mount] try: - output = subprocess.check_output(cmdline) + output = subprocess.check_output(cmdline).decode() except subprocess.CalledProcessError as err: result['status'] = "error" result['error_msg'] = os.strerror(err.returncode) @@ -388,13 +387,13 @@ class LpccMonitor: result = {} try: - fsname = subprocess.check_output(['lfs', 'getname', mount]).split()[0] + fsname = subprocess.check_output(['lfs', 'getname', mount]).split()[0].decode() except subprocess.CalledProcessError as err: result['error_msg'] = os.strerror(err.returncode) return result cmdline = ['lctl', 'get_param', '-n', 'llite.%s.stats' % fsname] - output = subprocess.check_output(cmdline) + output = subprocess.check_output(cmdline).decode() for line in output.splitlines(): words = line.split() if (words[0] == "open"): @@ -445,13 +444,13 @@ class LpccMonitor: groups = {} for lpcc_status in status_list: mount = lpcc_status['mount'] - if groups.has_key(mount): + if mount in groups: groups[mount]['pcc'].append(lpcc_status) else: groups[mount] = {} groups[mount]['pcc'] = [lpcc_status,] - for mount in groups.keys(): + for mount in groups: fs_stats = self._get_fs_stats(mount) groups[mount]['fs_stats'] = fs_stats @@ -507,7 +506,7 @@ class LpccMonitor: eprint("Response:", response) try: - conn.sendall(json.dumps(response)) + conn.sendall(json.dumps(response).encode()) conn.shutdown(socket.SHUT_WR) except Exception as ex: eprint(ex) @@ -574,7 +573,7 @@ class LpccCli: "please check whether the monitor service started!") sys.exit(1) - sock.sendall(json.dumps(cmd)) + sock.sendall(json.dumps(cmd).encode()) sock.shutdown(socket.SHUT_WR) response = sock.makefile().readline() sock.close() -- 1.8.3.1