NFSTEST.NFS_UTIL(1) nfstest.nfs_util 1.0.1 NFSTEST.NFS_UTIL(1)NAME
nfstest.nfs_util - NFS utilities module
DESCRIPTION
Provides a set of tools for testing NFS including methods for starting
a packet trace, stopping the packet trace and then open the packet
trace for analysis. It also provides a mechanism to enable NFS/RPC
kernel debug and saving the log messages for further analysis.
Furthermore, methods for finding specific NFSv4 operations within the
packet trace is also included.
CLASSES
class NFSUtil(nfstest.host.Host)
NFSUtil object
NFSUtil() -> New NFSUtil object
Usage:
from nfstest.nfs_util import NFSUtil
# Create object for local host
x = NFSUtil()
# Start packet trace
x.trace_start()
# Stop packet trace
x.trace_stop()
# Open packet trace
x.trace_open()
# Enable NFS kernel debug
x.nfs_debug_enable(nfsdebug='all'):
# Stop NFS kernel debug
x.nfs_debug_reset()
Methods defined here:
---------------------
__init__(self, **kwargs)
Constructor
Initialize object's private data.
rpcdebug:
Set RPC kernel debug flags and save log messages
[default: '']
nfsdebug:
Set NFS kernel debug flags and save log messages
[default: '']
dbgname:
Base name for log messages files to create [default:
'dbgfile']
tracename:
Base name for trace files to create [default: 'trace‐
file']
notrace:
Debug option so a trace is not actually started [default:
False]
tcpdump:
Tcpdump command [default: '/usr/sbin/tcpdump']
messages:
Location of file for system messages [default:
'/var/log/messages']
tmpdir:
Temporary directory where trace files are created
[default: '/tmp']
find_exchange_id(self, **kwargs)
Find the call and its corresponding reply for the NFSv4
EXCHANGE_ID going to the server specified by the ipaddr and
port.
ipaddr:
Destination IP address [default: self.server]
port: Destination port [default: self.port]
Store the callback IP/TCP expression in object attribute cb_dst
Return a tuple: (pktcall, pktreply).
find_getdeviceinfo(self, deviceid=None)
Find the call and its corresponding reply for the NFSv4 GETDEVI‐
CEINFO going to the server specified by the ipaddr for
self.server and port given by self.port.
deviceid:
Look for an specific deviceid [default: any deviceid]
Return a tuple: (pktcall, pktreply, dslist).
find_layoutget(self, filehandle)
Find the call and its corresponding reply for the NFSv4 LAYOUT‐
GET of the given file handle going to the server specified by
the ipaddr for self.server and port given by self.port.
Return a tuple: (layoutget, layoutget_res, loc_body).
find_layoutrecall(self, status=0)
Find NFSv4 CB_LAYOUTRECALL call and return its reply. The reply
must also match the given status.
find_nfs_op(self, op, ipaddr, port=None, match='', status=0,
src_ipaddr=None, maxindex=None, call_only=False)
Find the call and its corresponding reply for the specified
NFSv4 operation going to the server specified by the ipaddr and
port. The reply must also match the given status.
op: NFS operation to find
ipaddr:
Destination IP address
port: Destination port [default: any destination port]
match: Match string to include [default: '']
status:
Match the status of the operation [default: 0]
src_ipaddr:
Source IP address [default: any IP address]
maxindex:
The match fails if packet index hits this limit [default:
no limit]
call_only:
Find the call only [default: False]
Return a tuple: (pktcall, pktreply).
find_open(self, filename, ipaddr, port, deleg_type=None,
deleg_stateid=None, src_ipaddr=None, maxindex=None, anyclaim=False)
Find the call and its corresponding reply for the NFSv4 OPEN of
the given file going to the server specified by the ipaddr and
port.
filename:
Find open call and reply for this file
ipaddr:
Destination IP address
port: Destination port
deleg_type:
Expected delegation type on reply
deleg_stateid:
Delegation stateid expected on call in delegate_cur_info
src_ipaddr:
Source IP address [default: any IP address]
maxindex:
The match fails if packet index hits this limit [default:
no limit]
anyclaim:
Find open for either regular open or using dele‐
gate_cur_info
Return a tuple: (filehandle, open_stateid, deleg_stateid).
get_abs_offset(self, offset, ds_index=None)
Get real file offset given by the (read/write) offset on the
given data server index, taking into account the type of layout
(dense/sparse), the stripe_size, first stripe index and the num‐
ber of filehandles. The layout information is taken from object
attribute layout.
get_filehandle(self, ds_index)
Return filehandle from the layout list of filehandles.
nfs_debug_enable(self, **kwargs)
Enable NFS debug messages.
rpcdebug:
Set RPC kernel debug flags and save log messages
[default: self.rpcdebug]
nfsdebug:
Set NFS kernel debug flags and save log messages
[default: self.nfsdebug]
dbgfile:
Name of log messages file to create, default is a unique
name created in the temporary directory using self.dbg‐
name as the base name.
nfs_debug_reset(self)
Reset NFS debug messages.
trace_open(self, tracefile=None, **kwargs)
Open the trace file given or the trace file started by
trace_start().
All extra options are passed directly to the packet trace
object.
Return the packet trace object created, the packet trace object
is also stored in the object attribute pktt.
trace_start(self, tracefile=None, interface=None, capsize=None,
clients=None)
Start trace on interface given
tracefile:
Name of trace file to create, default is a unique name
created in the temporary directory using self.tracename
as the base name.
capsize:
Use the -C option of tcpdump to split the trace files
every 1000000*capsize bytes. See documentation for tcp‐
dump for more information
clients:
List of Host() objects to monitor
Return the name of the trace file created.
trace_stop(self)
Stop the trace started by trace_start().
verify_commit(self, ipaddr, port, filehandle, init=False)
Verify commits are properly sent to the server specified by the
given ipaddr and port.
ipaddr:
Destination IP address of MDS or DS
port: Destination port number of MDS or DS
filehandle:
Find commits for this file handle
init: Initialized test variables [default: False]
Return the number of commits sent to the server.
verify_create_session(self, ipaddr, port, ds=False, nocreate=False,
ds_index=None, exchid_status=0, cs_status=0)
Verify initial connection to the metadata server(MDS)/data
server(DS). Verify if EXCHANGE_ID, CREATE_SESSION, RECLAIM_COM‐
PLETE, GETATTR asking for FATTR4_LEASE_TIME, and GETATTR asking
for FATTR4_FS_LAYOUT_TYPE are all sent or not to the server.
ipaddr:
Destination IP address of MDS or DS
port: Destination port number of MDS or DS
ds: True if ipaddr/port defines a DS, otherwise MDS [default:
False]
nocreate:
True if expecting the client NOT to send EXCHANGE_ID,
CREATE_SESSION, and RECLAIM_COMPLETE. Otherwise, verify
all these operations are sent by the client [default:
False]
ds_index:
DS index used for displaying purposes only [default:
None]
exchid_status:
Expected status for EXCHANGE_ID [default: 0]
cs_status:
Expected status for CREATE_SESSION [default: 0]
Return the sessionid and it is also stored in the object
attribute sessionid.
verify_io(self, iomode, stateid, ipaddr=None, port=None,
src_ipaddr=None, filehandle=None, ds_index=None, init=False, maxin‐
dex=None, pattern=None)
Verify I/O is sent to the server specified by the ipaddr and
port.
iomode:
Verify reads (iomode == 1) or writes (iomode == 2)
stateid:
Expected stateid to use in all I/O requests
ipaddr:
Destination IP address of MDS or DS [default: do not
match destination]
port: Destination port number of MDS or DS [default: do not
match destination port]
src_ipaddr:
Source IP address of request [default: do not match
source]
filehandle:
Find I/O for this file handle. This option is used when
verifying I/O sent to the MDS [default: use filehandle
given by ds_index]
ds_index:
Data server index. This option is used when verifying I/O
sent to the DS -- filehandle is taken from x.layout for
this index [default: None]
init: Initialized test variables [default: False]
maxindex:
The match fails if packet index hits this limit [default:
no limit]
pattern:
Data pattern to compare [default: default data pattern]
Return the number of I/O operations sent to the server.
verify_layoutcommit(self, filehandle, filesize)
Verify layoutcommit is properly sent to the server specified by
the ipaddr for self.server and port given by self.port. Verify
a GETATTR asking for file size is sent within the same compound
as the LAYOUTCOMMIT. Verify GETATTR returns correct size for
the file.
filehandle:
Find layoutcommit for this file handle
filesize:
Expected size of file
verify_layoutget(self, filehandle, iomode, riomode=None, status=0, off‐
set=None, length=None)
Verify the client sends a LAYOUTGET for the given file handle.
filehandle:
Find LAYOUTGET for this file handle
iomode:
Expected I/O mode for LAYOUTGET call
riomode:
Expected I/O mode for LAYOUTGET reply if specified, else
verify reply I/O mode is equal to call I/O mode if iomode
== 2. If iomode == 1, the reply I/O mode could be equal
to 1 or 2
status:
Expected status for LAYOUTGET reply [default: 0]
offset:
Expected layout range for LAYOUTGET reply [default: None]
length:
Expected layout range for LAYOUTGET reply [default: None]
If both offset and length are not given, verify LAYOUTGET reply
should be a full layout [0, NFS4_UINT64_MAX]. If only one is
provided the following defaults are used: offset = 0, length =
NFS4_UINT64_MAX.
Layout information is stored in the object attribute layout.
Return a tuple: (layoutget, layoutget_res, loc_body).
verify_stripe(self, offset, size, ds_index)
Verify if read/write is sent to the correct data server accord‐
ing to stripe size, first stripe index and the number of file‐
handles. The layout information is taken from object attribute
layout.
offset:
Real file offset
size: I/O size
ds_index:
Data server index
Return True if stripe is correctly verified, False otherwise.
Static methods defined here:
----------------------------
bitmap_str(bitmap, count, bmap, blist)
Return the string representation of bitmap.
bitmap:
Bitmap to convert
count: Number of occurrences of bitmap
bmap: Dictionary mapping the bits to strings
blist: List of all possible bit combinations
iomode_str(iomode)
Return a string representation of iomode. This could be run as
an instance or class method.
SEE ALSObaseobj(1), nfstest.host(1), packet.pktt(1)BUGS
No known bugs.
AUTHOR
Jorge Mora (mora@netapp.com)
NFStest 1.0.2 10 April 2013 NFSTEST.NFS_UTIL(1)