From: Kyr Shatskyy Date: Fri, 21 Feb 2020 20:19:08 +0000 (+0100) Subject: qa/tasks/netem: get rid of cStringIO for py3 X-Git-Tag: v15.1.1~129^2~10 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=fa3db2529fb1b7f9f5145d3d8752d38b439a32f8;p=ceph.git qa/tasks/netem: get rid of cStringIO for py3 Signed-off-by: Kyr Shatskyy --- diff --git a/qa/tasks/netem.py b/qa/tasks/netem.py index 4fa08bbc0a0b8..1d9fd98f72402 100644 --- a/qa/tasks/netem.py +++ b/qa/tasks/netem.py @@ -6,7 +6,6 @@ Reference:https://wiki.linuxfoundation.org/networking/netem. import logging import contextlib -from cStringIO import StringIO from paramiko import SSHException import socket import time @@ -59,8 +58,8 @@ def static_delay(remote, host, interface, delay): ip = socket.gethostbyname(host.hostname) - r = remote.run(args=show_tc(interface), stdout=StringIO()) - if r.stdout.getvalue().strip().find('refcnt') == -1: + tc = remote.sh(show_tc(interface)) + if tc.strip().find('refcnt') == -1: # call set_priority() func to create priority queue # if not already created(indicated by -1) log.info('Create priority queue') @@ -94,8 +93,8 @@ def variable_delay(remote, host, interface, delay_range=[]): delay1 = delay_range[0] delay2 = delay_range[1] - r = remote.run(args=show_tc(interface), stdout=StringIO()) - if r.stdout.getvalue().strip().find('refcnt') == -1: + tc = remote.sh(show_tc(interface)) + if tc.strip().find('refcnt') == -1: # call set_priority() func to create priority queue # if not already created(indicated by -1) remote.run(args=set_priority(interface)) @@ -121,8 +120,8 @@ def delete_dev(remote, interface): """ Delete the qdisc if present""" log.info('Delete tc') - r = remote.run(args=show_tc(interface), stdout=StringIO()) - if r.stdout.getvalue().strip().find('refcnt') != -1: + tc = remote.sh(show_tc(interface)) + if tc.strip().find('refcnt') != -1: remote.run(args=del_tc(interface)) @@ -144,8 +143,8 @@ class Toggle: _, _, set_ip = cmd_prefix(self.interface) - r = self.remote.run(args=show_tc(self.interface), stdout=StringIO()) - if r.stdout.getvalue().strip().find('refcnt') == -1: + tc = self.remote.sh(show_tc(self.interface)) + if tc.strip().find('refcnt') == -1: self.remote.run(args=set_priority(self.interface)) # packet drop to specific ip log.info('Drop all packets to %s' % self.host)