From 73671d1cd286d2d7200201a9c5be137b08598258 Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Wed, 9 Oct 2019 13:18:23 +0200 Subject: [PATCH] fog: get rid of StringIO usage for python3 portability Signed-off-by: Kyr Shatskyy --- teuthology/provision/fog.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/teuthology/provision/fog.py b/teuthology/provision/fog.py index 607e01db4..993f30e3b 100644 --- a/teuthology/provision/fog.py +++ b/teuthology/provision/fog.py @@ -2,10 +2,10 @@ import json import logging import requests import socket +import re from datetime import datetime from paramiko import SSHException -from StringIO import StringIO import teuthology.orchestra @@ -276,15 +276,13 @@ class FOG(object): used to create the image initially. Fix that by making a call to /binhostname and tweaking /etc/hosts. """ - proc = self.remote.run(args='hostname', stdout=StringIO()) - wrong_hostname = proc.stdout.read().strip() - proc = self.remote.run( - args='grep %s /etc/hosts' % wrong_hostname, - stdout=StringIO(), + wrong_hostname = self.remote.sh('hostname').strip() + etc_hosts = self.remote.sh( + 'grep %s /etc/hosts' % wrong_hostname, check_status=False, - ) - if proc.returncode == 0: - wrong_ip = proc.stdout.readlines()[0].split(' ')[0] + ).strip() + if etc_hosts: + wrong_ip = re.split(r'\s+', etc_hosts.split('\n')[0].strip())[0] self.remote.run(args="sudo hostname %s" % self.shortname) self.remote.run( args="sudo sed -i -e 's/%s/%s/g' /etc/hosts" % ( -- 2.47.3