python2/3 compatibilty for spdk/util using oslo.log

replacing print with log.info

Change-Id: I127484e0c27f7d82e51351b5cbde58198c9eef9f
This commit is contained in:
Sumit Jamgade 2018-08-23 11:54:12 +02:00
parent 08588d0904
commit 715f03953a
3 changed files with 28 additions and 16 deletions

View File

@ -1,5 +1,9 @@
import json
from oslo_log import log as logging
LOG = logging.getLogger(__name__)
class NvmfTgt(object):
@ -20,12 +24,12 @@ class NvmfTgt(object):
def delete_bdev(self, name):
sub_args = [name]
res = self.py.exec_rpc('delete_bdev', '10.0.2.15', sub_args=sub_args)
print res
LOG.info(res)
def kill_instance(self, sig_name):
sub_args = [sig_name]
res = self.py.exec_rpc('kill_instance', '10.0.2.15', sub_args=sub_args)
print res
LOG.info(res)
def construct_aio_bdev(self, filename, name, block_size):
sub_args = [filename, name, str(block_size)]
@ -33,7 +37,7 @@ class NvmfTgt(object):
'construct_aio_bdev',
'10.0.2.15',
sub_args=sub_args)
print res
LOG.info(res)
def construct_error_bdev(self, basename):
sub_args = [basename]
@ -41,7 +45,7 @@ class NvmfTgt(object):
'construct_error_bdev',
'10.0.2.15',
sub_args=sub_args)
print res
LOG.info(res)
def construct_nvme_bdev(
self,
@ -84,7 +88,7 @@ class NvmfTgt(object):
'construct_malloc_bdev',
'10.0.2.15',
sub_args=sub_args)
print res
LOG.info(res)
def delete_nvmf_subsystem(self, nqn):
sub_args = [nqn]
@ -92,7 +96,7 @@ class NvmfTgt(object):
'delete_nvmf_subsystem',
'10.0.2.15',
sub_args=sub_args)
print res
LOG.info(res)
def construct_nvmf_subsystem(
self,
@ -106,7 +110,7 @@ class NvmfTgt(object):
'construct_nvmf_subsystem',
'10.0.2.15',
sub_args=sub_args)
print res
LOG.info(res)
def get_nvmf_subsystems(self):
subsystems = self._get_json_objs(

View File

@ -3,6 +3,10 @@ import re
import os
import subprocess
from oslo_log import log as logging
LOG = logging.getLogger(__name__)
class PySPDK(object):
@ -16,7 +20,7 @@ class PySPDK(object):
self.init_hugepages(spdk_dir)
server_dir = os.path.join(spdk_dir, 'app/')
file_dir = self._search_file(server_dir, server_name)
print file_dir
LOG.info(file_dir)
os.chdir(file_dir)
p = subprocess.Popen(
'sudo ./%s' % server_name,
@ -28,7 +32,7 @@ class PySPDK(object):
def init_hugepages(self, spdk_dir):
huge_dir = os.path.join(spdk_dir, 'scripts/')
file_dir = self._search_file(huge_dir, 'setup.sh')
print file_dir
LOG.info(file_dir)
os.chdir(file_dir)
p = subprocess.Popen(
'sudo ./setup.sh',
@ -52,8 +56,8 @@ class PySPDK(object):
self.pid = pinfo.get('pid')
return self.pid
except psutil.NoSuchProcess:
print "NoSuchProcess:%s" % self.pname
print "NoSuchProcess:%s" % self.pname
LOG.info("NoSuchProcess:%s" % self.pname)
LOG.info("NoSuchProcess:%s" % self.pname)
return self.pid
def is_alive(self):

View File

@ -1,5 +1,9 @@
import json
from oslo_log import log as logging
LOG = logging.getLogger(__name__)
class VhostTgt(object):
@ -49,12 +53,12 @@ class VhostTgt(object):
def delete_bdev(self, name):
sub_args = [name]
res = self.py.exec_rpc('delete_bdev', '127.0.0.1', sub_args=sub_args)
print res
LOG.info(res)
def kill_instance(self, sig_name):
sub_args = [sig_name]
res = self.py.exec_rpc('kill_instance', '127.0.0.1', sub_args=sub_args)
print res
LOG.info(res)
def construct_aio_bdev(self, filename, name, block_size):
sub_args = [filename, name, str(block_size)]
@ -62,7 +66,7 @@ class VhostTgt(object):
'construct_aio_bdev',
'127.0.0.1',
sub_args=sub_args)
print res
LOG.info(res)
def construct_error_bdev(self, basename):
sub_args = [basename]
@ -70,7 +74,7 @@ class VhostTgt(object):
'construct_error_bdev',
'127.0.0.1',
sub_args=sub_args)
print res
LOG.info(res)
def construct_nvme_bdev(
self,
@ -113,7 +117,7 @@ class VhostTgt(object):
'construct_malloc_bdev',
'10.0.2.15',
sub_args=sub_args)
print res
LOG.info(res)
def _get_json_objs(self, method, server_ip):
res = self.py.exec_rpc(method, server_ip)