From: Weston Andros Adamson <dros@primarydata.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org, Weston Andros Adamson <dros@primarydata.com>
Subject: [PATCH pynfs v2 06/16] 4.1 server: add -v flag & silence random output
Date: Thu, 5 Jun 2014 09:55:34 -0400 [thread overview]
Message-ID: <1401976544-36374-7-git-send-email-dros@primarydata.com> (raw)
In-Reply-To: <1401976544-36374-1-git-send-email-dros@primarydata.com>
By default the nfs4server spews so much information to stdout/stderr
that it's almost useless. Add the -v flag (aka --verbose) to enable
the old output.
Also remove some random prints and change some to log.info().
Signed-off-by: Weston Andros Adamson <dros@primarydata.com>
---
nfs4.1/dataserver.py | 3 +--
nfs4.1/fs.py | 4 ----
nfs4.1/nfs4client.py | 11 ++--------
nfs4.1/nfs4server.py | 61 +++++++++++++++++++++++-----------------------------
nfs4.1/nfs4state.py | 1 -
5 files changed, 30 insertions(+), 50 deletions(-)
diff --git a/nfs4.1/dataserver.py b/nfs4.1/dataserver.py
index acca210..c400d22 100644
--- a/nfs4.1/dataserver.py
+++ b/nfs4.1/dataserver.py
@@ -182,7 +182,7 @@ class DSDevice(object):
line = line.strip()
if not line or line.startswith('#'):
continue
- print "Analyzing: %r" % line
+ log.info("Analyzing: %r" % line)
try:
server_list, path = nfs4lib.parse_nfs_url(line)
except:
@@ -192,7 +192,6 @@ class DSDevice(object):
# for now, just use the last path for local connections
server, port = server_list[-1]
server_list = server_list[:-1]
- print server, port, path
try:
log.info("Adding dataserver ip:%s port:%s path:%s" %
(server, port, '/'.join(path)))
diff --git a/nfs4.1/fs.py b/nfs4.1/fs.py
index 3d63ce5..6ef283b 100644
--- a/nfs4.1/fs.py
+++ b/nfs4.1/fs.py
@@ -13,7 +13,6 @@ from xdrdef.nfs4_pack import NFS4Packer
log_o = logging.getLogger("fs.obj")
log_fs = logging.getLogger("fs")
logging.addLevelName(5, "FUNCT")
-log_fs.setLevel(20)
class MetaData(object):
"""Contains everything that needs to be stored
@@ -743,7 +742,6 @@ class ConfigObj(FSObject):
line = line.strip()
if line and not line.startswith("#"):
lines.append(line)
- print lines
if len(lines) != 1:
self._reset()
return
@@ -1154,7 +1152,6 @@ class LayoutFSObj(FSObject):
disk_offset,
e.state))
block_layout = pnfs_block_layout4(elist)
- print block_layout
p = block.Packer()
p.pack_pnfs_block_layout4(block_layout)
## if self.id <= 4:
@@ -1194,7 +1191,6 @@ class LayoutFSObj(FSObject):
log_o.exception("Problem decoding opaque")
raise NFS4Error(NFS4ERR_BADLAYOUT, tag="Error decoding opaque")
upd_list = update.blu_commit_list
- print upd_list
# Error check
for e in upd_list:
if e.bex_state != block.PNFS_BLOCK_READWRITE_DATA:
diff --git a/nfs4.1/nfs4client.py b/nfs4.1/nfs4client.py
index 7a07ab7..0ba84bd 100644
--- a/nfs4.1/nfs4client.py
+++ b/nfs4.1/nfs4client.py
@@ -19,9 +19,7 @@ import logging
logging.basicConfig(level=logging.INFO,
format="%(levelname)-7s:%(name)s:%(message)s")
log_cb = logging.getLogger("nfs.client.cb")
-log_cb.setLevel(logging.DEBUG)
-SHOW_TRAFFIC = True # Debugging aid, prints out client traffic
class NFS4Client(rpc.Client, rpc.Server):
def __init__(self, host='localhost', port=2049, minorversion=1, ctrl_proc=16):
rpc.Client.__init__(self, 100003, 4)
@@ -76,9 +74,7 @@ class NFS4Client(rpc.Client, rpc.Server):
pipe = self.c1
p = packer(check_enum=checks, check_array=checks)
c4 = COMPOUND4args(tag, version, ops)
- if SHOW_TRAFFIC:
- print
- print c4
+ log_cb.info("compound args = %r" % (c4,))
p.pack_COMPOUND4args(c4)
return self.send_call(pipe, 1, p.get_buffer(), credinfo)
@@ -86,19 +82,16 @@ class NFS4Client(rpc.Client, rpc.Server):
xid = self.compound_async(*args, **kwargs)
pipe = kwargs.get("pipe", None)
res = self.listen(xid, pipe=pipe)
- if SHOW_TRAFFIC:
- print res
+ log_cb.info("compound result = %r" % (res,))
return res
def listen(self, xid, pipe=None, timeout=10.0):
if pipe is None:
pipe = self.c1
header, data = pipe.listen(xid, timeout)
- #print "HEADER", header
if data:
p = nfs4lib.FancyNFS4Unpacker(data)
data = p.unpack_COMPOUND4res()
- #print "DATA", repr(data)
return data
def handle_0(self, data, cred):
diff --git a/nfs4.1/nfs4server.py b/nfs4.1/nfs4server.py
index 2ae99fe..a495d3c 100755
--- a/nfs4.1/nfs4server.py
+++ b/nfs4.1/nfs4server.py
@@ -21,14 +21,11 @@ from nfs4commoncode import CompoundState, encode_status, encode_status_by_name
from fs import RootFS, ConfigFS
from config import ServerConfig, ServerPerClientConfig, OpsConfigServer, Actions
-logging.basicConfig(level=logging.INFO,
+logging.basicConfig(level=logging.WARN,
format="%(levelname)-7s:%(name)s:%(message)s")
log_41 = logging.getLogger("nfs.server")
-log_41.setLevel(logging.DEBUG)
-log_41.setLevel(9)
log_cfg = logging.getLogger("nfs.server.opconfig")
-log_cfg.setLevel(20)
##################################################
# Set various global constants and magic numbers #
@@ -116,9 +113,6 @@ class Recording(object):
def add(self, call, reply):
"""Add call and reply strings to records"""
if self.on:
- print "Adding"
- print repr(call)
- print repr(reply)
self.queue.appendleft((call, reply))
def set_stamp(self, stamp):
@@ -269,13 +263,13 @@ class VerboseDict(dict):
self.config = config
def __setitem__(self, key, value):
- if 0 or self.config.debug_state:
- print "+++ Adding client.state[%r]" % key
+ if self.config.debug_state:
+ log_41.info("+++ Adding client.state[%r]" % key)
dict.__setitem__(self, key, value)
def __delitem__(self, key):
- if 0 or self.config.debug_state:
- print "+++ Removing client.state[%r]" % key
+ if self.config.debug_state:
+ log_41.info("+++ Removing client.state[%r]" % key)
dict.__delitem__(self, key)
class ClientRecord(object):
@@ -526,6 +520,13 @@ class NFS4Server(rpc.Server):
port = kwargs.pop("port", NFS4_PORT)
self.is_mds = kwargs.pop("is_mds", False)
self.is_ds = kwargs.pop("is_ds", False)
+
+ self.verbose = kwargs.pop('verbose', False)
+ if self.verbose:
+ log_41.setLevel(logging.DEBUG) # XXX redundant?
+ log_41.setLevel(9)
+ log_cfg.setLevel(20)
+
rpc.Server.__init__(self, prog=NFS4_PROGRAM, versions=[4], port=port,
**kwargs)
self.root = RootFS().root # Root of exported filesystem tree
@@ -552,7 +553,7 @@ class NFS4Server(rpc.Server):
rpc.Server.start(self)
except KeyboardInterrupt:
# Put user into console where can look at state of server
- if not self.config.catch_ctrlc:
+ if not self.config.catch_ctrlc or not self.verbose:
raise
import code
import readline
@@ -1330,9 +1331,9 @@ class NFS4Server(rpc.Server):
sid, deleg, flags = self.open_file(existing, arg.owner,
arg.share_access, arg.share_deny)
env.set_cfh(existing, sid)
- if 0 or env.session.client.config.debug_state:
- print "+++ client(id=%i).state =" % env.session.client.clientid
- print env.session.client.state
+ if env.session.client.config.debug_state:
+ log_41.info("+++ client(id=%i).state = %r" %
+ (env.session.client.clientid, env.session.client.state))
res = OPEN4resok(sid, cinfo, flags, bitmask, deleg)
return encode_status(NFS4_OK, res)
@@ -1452,14 +1453,13 @@ class NFS4Server(rpc.Server):
ret_dict = {}
info = nfs4lib.attr_info
for attr in attrs:
- print "handling fattr4_%s : " % nfs4lib.attr_name(attr),
if attr not in info:
# Ignore unknown attributes
- print "Unknown"
+ log_41.info("Skipping unknown attr: %s" % (attr,))
continue
if not info[attr].readable:
# XXX How deal with write-only attrs?
- print "Write only"
+ log_41.info("Skipping write only attr: %s" % (attr,))
continue
# Attributes hide in different places, call the place 'base'
if info[attr].from_fs:
@@ -1471,24 +1471,14 @@ class NFS4Server(rpc.Server):
name = "fattr4_%s" % nfs4lib.attr_name(attr)
if hasattr(base, name) and (obj.fs.fattr4_supported_attrs & 1<<attr): # STUB we should be able to remove hasattr
ret_dict[attr] = getattr(base, name)
- print ret_dict[attr]
else:
if ignore:
# Must ignore for GETATTR (and READDIR) per 15.1
- print "ignored"
- if name == "fattr4_mounted_on_fileid":
- print base == obj
- print base.fattr4_mounted_on_fileid
- if name == "fattr4_layout_blksize":
- print base == obj
- print hasattr(base, name)
- print obj.fs.fattr4_supported_attrs
- print 1<<attr
- print obj.fs.fattr4_supported_attrs & 1<<attr
+ log_41.info("ignored attr %s" % (name,))
continue
else:
# This is for VERIFY/NVERIFY
- print "NOT SUPP"
+ log_41.info("attr NOT SUPP %s" % (name,))
raise NFS4Error(NFS4ERR_ATTRNOTSUPP)
obj.fattr4_rdattr_error = NFS4_OK # XXX STUB Handle correctly
return ret_dict
@@ -1953,14 +1943,14 @@ class NFS4Server(rpc.Server):
calls.append(call)
if arg.dir & xdrdef.sctrl_const.DIR_REPLY:
replies.append(reply)
- print calls
- print replies
+ #print calls
+ #print replies
grabres = xdrdef.sctrl_type.GRABres(calls, replies)
return xdrdef.sctrl_const.CTRLSTAT_OK, \
xdrdef.sctrl_type.resdata_t(arg.ctrlop, grab = grabres)
def ctrl_illegal(self, arg):
- print "ILLEGAL"
+ #print "ILLEGAL"
return xdrdef.sctrl_const.CTRLSTAT_ILLEGAL, xdrdef.sctrl_type.resdata_t(arg.ctrlop)
def op_setclientid(self, arg, env):
@@ -2067,6 +2057,8 @@ def scan_options():
)
p.add_option("-r", "--reset", action="store_true", default=False,
help="Reset and clear any disk-based filesystems")
+ p.add_option("-v", "--verbose", action="store_true", default=False,
+ help="Print debug info to screen and enter interpreter on ^C")
p.add_option("--use_block", action="store_true", default=False,
help="Mount a block-pnfs fs")
p.add_option("--use_files", action="store_true", default=False,
@@ -2099,7 +2091,8 @@ if __name__ == "__main__":
locking.DEBUG = True
S = NFS4Server(port=opts.port,
is_mds=opts.use_block or opts.use_files,
- is_ds = opts.is_ds)
+ is_ds = opts.is_ds,
+ verbose = opts.verbose)
read_exports(S, opts)
if True:
S.start()
diff --git a/nfs4.1/nfs4state.py b/nfs4.1/nfs4state.py
index 1294083..2f3cd59 100644
--- a/nfs4.1/nfs4state.py
+++ b/nfs4.1/nfs4state.py
@@ -13,7 +13,6 @@ import rpc
import logging
log = logging.getLogger("nfs.server.state")
-log.setLevel(10)
POSIXLOCK = False
--
1.8.5.2 (Apple Git-48)
next prev parent reply other threads:[~2014-06-05 13:55 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-05 13:55 [PATCH pynfs v2 00/16] prep for flex file layout server Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 01/16] dataserver: reclaim_complete after create_session Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 02/16] dataserver: only catch connection error Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 03/16] 4.1 server: avoid traceback in DS disconnect() Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 04/16] move .x files to subdir 'xdrdef' Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 05/16] 4.1 client: remove unused imports Weston Andros Adamson
2014-06-05 13:55 ` Weston Andros Adamson [this message]
2014-06-05 13:55 ` [PATCH pynfs v2 07/16] 4.1 server: add -s option to print summary of ops Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 08/16] dataserver: make generic interface to ops Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 09/16] dataserver: don't import * from nfs4 specific mods Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 10/16] 4.1 server: move nfs4_ops.py to nfs_ops.py Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 11/16] add mntv3, portmapv2 and nfsv3 .x files Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 12/16] dataserver: separate generic and 4.1 code Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 13/16] 4.1 server: add support for NFSv3 data servers Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 14/16] 4.1 server: get rid of old op_getdeviceinfo Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 15/16] rpc: on socket error, close and mark pipe inactive Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 16/16] nfs3clnt: reconnect when sending on inactive pipe Weston Andros Adamson
2014-06-05 14:19 ` [PATCH pynfs v2 00/16] prep for flex file layout server J. Bruce Fields
2014-06-05 14:22 ` Weston Andros Adamson
2014-06-05 14:24 ` J. Bruce Fields
2014-06-09 21:25 ` J. Bruce Fields
2014-06-10 1:41 ` Weston Andros Adamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1401976544-36374-7-git-send-email-dros@primarydata.com \
--to=dros@primarydata.com \
--cc=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).