1NFS_UTIL(3)                      nfs_util 2.7                      NFS_UTIL(3)
2
3
4

NAME

6       nfstest.nfs_util - NFS utilities module
7

DESCRIPTION

9       Provides  a set of tools for testing NFS including methods for starting
10       a packet trace, stopping the packet trace  and  then  open  the  packet
11       trace  for  analysis.   It  also provides a mechanism to enable NFS/RPC
12       kernel debug and saving the log messages for further analysis.
13
14       Furthermore, methods for finding specific NFSv4 operations  within  the
15       packet trace are also included.
16

CLASSES

18   class NFSUtil(nfstest.host.Host)
19       NFSUtil object
20
21       NFSUtil() -> New NFSUtil object
22
23       Usage:
24           from nfstest.nfs_util import NFSUtil
25
26           # Create object for local host
27           x = NFSUtil()
28
29           # Create client host object
30           clientobj = x.create_host('192.168.0.11')
31
32           # Use buffered matching on packets
33           x.set_pktlist()
34
35           # Get the next LOOKUP packets
36           pktcall, pktreply = x.find_nfs_op(OP_LOOKUP)
37
38           # Get OPEN information for the given file name
39           fh, open_stid, deleg_stid = x.find_open(filename="file1")
40
41           # Get address and port number from universal address string
42           ipaddr, port = x.get_addr_port(addr)
43
44           # Get packets and DS list for GETDEVICEINFO
45           pktcall, pktreply, dslist = x.find_getdeviceinfo()
46
47           # Get packets for EXCHANGE_ID
48           pktcall, pktreply = x.find_exchange_id()
49
50           # Get the NFS operation object from the given packet
51           getfh = x.getop(x.pktreply, OP_GETFH)
52
53           # Get the stateid which must be used by I/O operations
54           stateid = x.get_stateid("file1")
55
56           # Get the client id
57           clientid = x.get_clientid()
58
59           # Get the session id for the given clientid
60           sessionid = x.get_sessionid(clientid=clientid)
61
62           # Get the root file handle from PUTROOTFH for the given session id
63           x.get_rootfh(sessionid=sessionid)
64
65           # Get the file handle for the given path
66           dirfh = x.get_pathfh("/vol1/data")
67
68           # Display the state id in CRC16 format
69           stidstr = x.stid_str(stateid)
70
71           # Get the number of bytes available in the given directory
72           freebytes = x.get_freebytes("/mnt/t")
73
74
75       Methods defined here:
76       ---------------------
77
78       __del__(self)
79       Destructor
80
81       Gracefully stop the packet trace and un-reference all client
82       objects
83
84       __init__(self, **kwargs)
85       Constructor
86
87       Initialize object's private data.
88
89       create_host(self, host, **kwargs)
90       Create client host object and set defaults.
91
92       find_exchange_id(self, **kwargs)
93       Find the call and its corresponding reply for the NFSv4 EXCHANGE_ID
94       going to the server specified by the ipaddr and port.
95
96
97              ipaddr:
98                     Destination IP address [default: self.server_ipaddr]
99
100              port:  Destination port [default: self.port]
101
102              Store the callback IP/TCP expression in object attribute cb_dst
103
104              Return a tuple: (pktcall, pktreply).
105
106       find_getdeviceinfo(self, deviceid=None)
107       Find the call and its corresponding reply for the NFSv4 GETDEVICEINFO
108       going to the server specified by the ipaddr for self.server and port
109       given by self.port.
110
111
112              deviceid:
113                     Look for an specific deviceid [default: any deviceid]
114
115              Return a tuple: (pktcall, pktreply, dslist).
116
117       find_layoutget(self, filehandle)
118       Find the call and its corresponding reply for the NFSv4 LAYOUTGET
119       of the given file handle going to the server specified by the
120       ipaddr for self.server and port given by self.port.
121
122       Return a tuple: (layoutget, layoutget_res, loc_body).
123
124       find_layoutrecall(self, status=0)
125       Find NFSv4 CB_LAYOUTRECALL call and return its reply.
126       The reply must also match the given status.
127
128       find_nfs_op(self, op, **kwargs)
129       Find the call and its corresponding reply for the specified NFSv4
130       operation going to the server specified by the ipaddr and port.
131       The reply must also match the given status. Also the following
132       object attributes are defined: pktcall referencing the packet call
133       while pktreply referencing the packet reply.
134
135
136              op:    NFS operation to find
137
138              ipaddr:
139                     Destination IP address [default: self.server_ipaddr]
140                     A value of None matches any IP address
141
142              port:  Destination port [default: self.port]
143                     A value of None matches any destination port
144
145              match: Match string to include [default: '']
146
147              status:
148                     Match the status of the operation [default: 0]
149                     A value of None matches any status.
150
151              src_ipaddr:
152                     Source IP address [default: None]
153                     A value of None matches any IP address
154
155              maxindex:
156                     The match fails if packet index hits this limit [default: None]
157                     A value of None means there is no limit
158
159              call_only:
160                     Find the call only [default: False]
161
162              Return a tuple: (pktcall, pktreply).
163
164       find_open(self, **kwargs)
165       Find the call and its corresponding reply for the NFSv4 OPEN of the
166       given file going to the server specified by the ipaddr and port.
167       The following object attributes are defined: opencall and pktcall
168       both referencing the packet call while openreply and pktreply both
169       referencing the packet reply.
170
171
172              filename:
173                     Find open call and reply for this file [default: None]
174
175              claimfh:
176                     Find open call and reply for this file handle using CLAIM_FH
177                     [default: None]
178
179              ipaddr:
180                     Destination IP address [default: self.server_ipaddr]
181
182              port:  Destination port [default: self.port]
183
184              deleg_type:
185                     Expected delegation type on reply [default: None]
186
187              deleg_stateid:
188                     Delegation stateid expected on call in delegate_cur_info [default: None]
189
190              fh:    Find open call and reply for this file handle when using
191                     deleg_stateid or as the directory FH when deleg_stateid
192                     is not set [default: None]
193
194              src_ipaddr:
195                     Source IP address [default: any IP address]
196
197              maxindex:
198                     The match fails if packet index hits this limit [default: no limit]
199
200              anyclaim:
201                     Find open for either regular open or using delegate_cur_info [default: False]
202
203              Must specify either filename, claimfh or both.
204              Return a tuple: (filehandle, open_stateid, deleg_stateid).
205
206       get_abs_offset(self, offset, ds_index=None)
207       Get real file offset given by the (read/write) offset on the given
208       data server index, taking into account the type of layout
209       (dense/sparse), the stripe_size, first stripe index and the number
210       of filehandles. The layout information is taken from object
211       attribute layout.
212
213       get_addr_port(self, addr)
214       Get address and port number from universal address string
215
216       get_clientid(self, **kwargs)
217       Return the client id for the given IP address and port number.
218
219
220              ipaddr:
221                     Destination IP address [default: self.server_ipaddr]
222
223              port:  Destination port [default: self.port]
224
225       get_filehandle(self, ds_index)
226       Return filehandle from the layout list of filehandles.
227
228       get_freebytes(self, dir=None)
229       Get the number of bytes available in the given directory.
230       It takes into account the effective user running the test.
231       The root user is allowed to use all the available disk space
232       on the device, on the other hand a regular user is allowed a
233       little bit less.
234
235       get_pathfh(self, path, dirfh=None)
236       Return the file handle for the given path by searching the packet
237       trace for every component in the path.
238       The file handle for each component is used to search for the file
239       handle in the next component.
240
241
242              path:  File system path
243
244              dirfh: Directory file handle to start with [default: None]
245
246       get_rootfh(self, **kwargs)
247       Return the root file handle from PUTROOTFH
248
249
250              sessionid:
251                     Search the PUTROOTFH tied to this session id [default: None]
252
253              ipaddr:
254                     Destination IP address [default: self.server_ipaddr]
255
256              port:  Destination port [default: self.port]
257
258       get_sessionid(self, **kwargs)
259       Return the session id for the given IP address and port number.
260
261
262              clientid:
263                     Search the CREATE_SESSION tied to this client id [default: None]
264
265              ipaddr:
266                     Destination IP address [default: self.server_ipaddr]
267
268              port:  Destination port [default: self.port]
269
270       get_stateid(self, filename, **kwargs)
271       Search the packet trace for the file name given to get the OPEN
272       so all related state ids can be searched. A couple of object
273       attributes are defined, one is the correct state id that should
274       be used by I/O operations. The second is a dictionary table
275       which maps the state id to a string identifying if the state
276       id is an open, lock or delegation state id.
277
278
279              ipaddr:
280                     Destination IP address [default: self.server_ipaddr]
281
282              port:  Destination port [default: self.port]
283
284              noreset:
285                     Do not reset the state id map [default: False]
286
287       getop(self, pkt, op)
288       Get the NFS operation object from the given packet
289
290       set_pktlist(self, ops=None, cbs=None, procs=None, maxindex=None, pktdisp=False)
291       Set the current packet list for buffered matching in which the
292       match method will only use this list instead of getting the next
293       packet from the packet trace file. The default is to get all
294       packets unless any of the arguments is given.
295
296       NOTE: all READ reply data and all WRITE request data is discarded
297       to avoid having memory issues.
298
299
300              ops:   List of NFSv4 operations to include in the packet list
301
302              cbs:   List of NFSv4 callback operations to include in the packet list
303
304              procs: List of NFSv3 procedures to include in the packet list
305
306              maxindex:
307                     Include packets up to but not including the packet indexed
308                     by this argument [default: None]
309                     A value of None means there is no limit
310
311              pktdisp:
312                     Display all cached packets [default: False]
313
314       stid_str(self, stateid)
315       Display the state id in CRC16 format
316
317       verify_commit(self, ipaddr, port, filehandle, init=False)
318       Verify commits are properly sent to the server specified by the
319       given ipaddr and port.
320
321
322              ipaddr:
323                     Destination IP address of MDS or DS
324
325              port:  Destination port number of MDS or DS
326
327              filehandle:
328                     Find commits for this file handle
329
330              init:  Initialized test variables [default: False]
331
332              Return the number of commits sent to the server.
333
334       verify_create_session(self, ipaddr, port, ds=False, nocreate=False, ds_index=None, exchid_status=0, cs_status=0)
335       Verify initial connection to the metadata server(MDS)/data server(DS).
336       Verify if EXCHANGE_ID, CREATE_SESSION, RECLAIM_COMPLETE,
337       GETATTR asking for FATTR4_LEASE_TIME, and GETATTR asking for
338       FATTR4_FS_LAYOUT_TYPES are all sent or not to the server.
339
340
341              ipaddr:
342                     Destination IP address of MDS or DS
343
344              port:  Destination port number of MDS or DS
345
346              ds:    True if ipaddr/port defines a DS, otherwise MDS [default: False]
347
348              nocreate:
349                     True if expecting the client NOT to send EXCHANGE_ID,
350                     CREATE_SESSION, and RECLAIM_COMPLETE. Otherwise, verify all
351                     these operations are sent by the client [default: False]
352
353              ds_index:
354                     DS index used for displaying purposes only [default: None]
355
356              exchid_status:
357                     Expected status for EXCHANGE_ID [default: 0]
358
359              cs_status:
360                     Expected status for CREATE_SESSION [default: 0]
361
362              Return the sessionid and it is also stored in the object
363              attribute sessionid.
364
365       verify_io(self, iomode, stateid, ipaddr=None, port=None, src_ipaddr=None, filehandle=None, ds_index=None, init=False, maxindex=None, pattern=None)
366       Verify I/O is sent to the server specified by the ipaddr and port.
367
368
369              iomode:
370                     Verify reads (iomode == 1) or writes (iomode == 2)
371
372              stateid:
373                     Expected stateid to use in all I/O requests
374
375              ipaddr:
376                     Destination IP address of MDS or DS
377                     [default: do not match destination]
378
379              port:  Destination port number of MDS or DS
380                     [default: do not match destination port]
381
382              src_ipaddr:
383                     Source IP address of request
384                     [default: do not match source]
385
386              filehandle:
387                     Find I/O for this file handle. This option is used when
388                     verifying I/O sent to the MDS
389                     [default: use filehandle given by ds_index]
390
391              ds_index:
392                     Data server index. This option is used when verifying I/O sent
393                     to the DS -- filehandle is taken from x.layout for this index
394                     [default: None]
395
396              init:  Initialized test variables [default: False]
397
398              maxindex:
399                     The match fails if packet index hits this limit [default: no limit]
400
401              pattern:
402                     Data pattern to compare [default: default data pattern]
403
404              Return the number of I/O operations sent to the server.
405
406       verify_layoutcommit(self, filehandle, filesize)
407       Verify layoutcommit is properly sent to the server specified by
408       the ipaddr for self.server and port given by self.port.
409       Verify a GETATTR asking for file size is sent within the same
410       compound as the LAYOUTCOMMIT.
411       Verify GETATTR returns correct size for the file.
412
413
414              filehandle:
415                     Find layoutcommit for this file handle
416
417              filesize:
418                     Expected size of file
419
420       verify_layoutget(self, filehandle, iomode, riomode=None, status=0, offset=None, length=None)
421       Verify the client sends a LAYOUTGET for the given file handle.
422
423
424              filehandle:
425                     Find LAYOUTGET for this file handle
426
427              iomode:
428                     Expected I/O mode for LAYOUTGET call
429
430              riomode:
431                     Expected I/O mode for LAYOUTGET reply if specified, else verify
432                     reply I/O mode is equal to call I/O mode if iomode == 2.
433                     If iomode == 1, the reply I/O mode could be equal to 1 or 2
434
435              status:
436                     Expected status for LAYOUTGET reply [default: 0]
437
438              offset:
439                     Expected layout range for LAYOUTGET reply [default: None]
440
441              length:
442                     Expected layout range for LAYOUTGET reply [default: None]
443
444              If both offset and length are not given, verify LAYOUTGET reply
445              should be a full layout [0, NFS4_UINT64_MAX]. If only one is
446              provided the following defaults are used: offset = 0,
447              length = NFS4_UINT64_MAX.
448
449              Layout information is stored in the object attribute layout.
450
451              Return a tuple: (layoutget, layoutget_res, loc_body).
452
453       verify_pnfs_supported(self, filehandle, server_type, path=None)
454       Verify pNFS is supported in the given server path.
455       Finds the GETATTR asking for FATTR4_SUPPORTED_ATTRS(bit 0 and its
456       reply to verify FATTR4_FS_LAYOUT_TYPES is supported for the path.
457       Then it finds the GETATTR asking for FATTR4_FS_LAYOUT_TYPES(bit 62)
458       to verify LAYOUT4_NFSV4_1_FILES is returned in fs_layout_types.
459
460       verify_stripe(self, offset, size, ds_index)
461       Verify if read/write is sent to the correct data server according
462       to stripe size, first stripe index and the number of filehandles.
463       The layout information is taken from object attribute layout.
464
465
466              offset:
467                     Real file offset
468
469              size:  I/O size
470
471              ds_index:
472                     Data server index
473
474              Return True if stripe is correctly verified, False otherwise.
475
476       Static methods defined here:
477       ----------------------------
478
479       bitmap_str(bitmap, count, bmap, blist)
480       Return the string representation of bitmap.
481
482
483              bitmap:
484                     Bitmap to convert
485
486              count: Number of occurrences of bitmap
487
488              bmap:  Dictionary mapping the bits to strings
489
490              blist: List of all possible bit combinations
491
492       iomode_str(iomode)
493       Return a string representation of iomode.
494       This could be run as an instance or class method.
495

SEE ALSO

497       baseobj(3),     formatstr(3),     nfstest.host(3),    nfstest.utils(3),
498       packet.nfs.nfs3_const(3), packet.nfs.nfs4_const(3)
499
500

BUGS

502       No known bugs.
503

AUTHOR

505       Jorge Mora (mora@netapp.com)
506
507
508
509NFStest 2.1.5                  14 February 2017                    NFS_UTIL(3)
Impressum