1HOST(3)                            host 1.3                            HOST(3)
2
3
4

NAME

6       nfstest.host - Host module
7

DESCRIPTION

9       Provides  a  set  of  tools for running commands on the local host or a
10       remote host, including a mechanism for running commands  in  the  back‐
11       ground.   It  provides  methods for mounting and unmounting from an NFS
12       server and a mechanism to simulate a network partition via the  use  of
13       'iptables'.   Currently,  there is no mechanism to restore the iptables
14       rules to their original state.
15

CLASSES

17   class Host(baseobj.BaseObj)
18       Host object
19
20       Host() -> New Host object
21
22       Usage:
23           from nfstest.host import Host
24
25           # Create host object for local host
26           x = Host()
27           # Create host object for remote host
28           y = Host(host='192.168.0.11')
29
30           # Run command to the local host
31           x.run_cmd("ls -l")
32
33           # Send command to the remote host and run it as root
34           y.run_cmd("ls -l", sudo=True)
35
36           # Run command in the background
37           x.run_cmd("tcpdump", sudo=True, wait=False)
38           ....
39           ....
40           # Stop command running in the background
41           x.stop_cmd()
42
43           # Mount volume using default options
44           x.mount()
45
46           # Unmount volume
47           x.umount()
48
49           # Start packet trace
50           x.trace_start()
51
52           # Stop packet trace
53           x.trace_stop()
54
55           # Open packet trace
56           x.trace_open()
57
58           # Enable NFS kernel debug
59           x.nfs_debug_enable(nfsdebug='all'):
60
61           # Stop NFS kernel debug
62           x.nfs_debug_reset()
63
64
65       Methods defined here:
66       ---------------------
67
68       __del__(self)
69       Destructor
70
71       Gracefully unmount volume and reset network.
72
73       __init__(self, **kwargs)
74       Constructor
75
76       Initialize object's private data.
77
78
79              host:  Hostname or IP address [default: localhost]
80
81              user:  User to log in to host [default: '']
82
83              server:
84                     NFS server name or IP address [default: None]
85
86              nfsversion:
87                     NFS version [default: 4.1]
88
89              proto: NFS protocol name [default: 'tcp']
90
91              port:  NFS server port [default: 2049]
92
93              sec:   Security flavor [default: 'sys']
94
95              export:
96                     Exported file system to mount [default: '/']
97
98              mtpoint:
99                     Mount point [default: '/mnt/t']
100
101              datadir:
102                     Data directory where files are created [default: '']
103
104              mtopts:
105                     Mount options [default: 'hard,rsize=4096,wsize=4096']
106
107              interface:
108                     Network device interface [default: 'eth0']
109
110              nomount:
111                     Debug option so the server is not actually mounted [default: False]
112
113              tracename:
114                     Base name for trace files to create [default: 'tracefile']
115
116              trcdelay:
117                     Seconds to delay before stopping packet trace [default: 0.0]
118
119              tcpdump:
120                     Tcpdump command [default: '/usr/sbin/tcpdump']
121
122              tbsize:
123                     Capture buffer size in kB [default: 150000]
124
125              notrace:
126                     Debug option so a trace is not actually started [default: False]
127
128              rpcdebug:
129                     Set RPC kernel debug flags and save log messages [default: '']
130
131              nfsdebug:
132                     Set NFS kernel debug flags and save log messages [default: '']
133
134              dbgname:
135                     Base name for log messages files to create [default: 'dbgfile']
136
137              messages:
138                     Location of file for system messages [default: '/var/log/messages']
139
140              tmpdir:
141                     Temporary directory where trace/debug files are created
142                     [default: '/tmp']
143
144              iptables:
145                     Iptables command [default: '/usr/sbin/iptables']
146
147              sudo:  Sudo command [default: '/usr/bin/sudo']
148
149       abspath(self, filename, dir=None)
150       Return the absolute path for the given file name.
151
152       get_route(self, ipaddr)
153       Get routing information for destination IP address
154       Returns a tuple: (gateway, device name, src IP address)
155
156       mount(self, **kwargs)
157       Mount the file system on the given mount point.
158
159
160              server:
161                     NFS server name or IP address [default: self.server]
162
163              nfsversion:
164                     NFS version [default: self.nfsversion]
165
166              proto: NFS protocol name [default: self.proto]
167
168              port:  NFS server port [default: self.port]
169
170              sec:   Security flavor [default: self.sec]
171
172              export:
173                     Exported file system to mount [default: self.export]
174
175              mtpoint:
176                     Mount point [default: self.mtpoint]
177
178              datadir:
179                     Data directory where files are created [default: self.datadir]
180
181              mtopts:
182                     Mount options [default: self.mtopts]
183
184              Return the mount point.
185
186       network_drop(self, ipaddr, port)
187       Simulate a network drop by dropping all tcp packets going to the
188       given ipaddr and port using the iptables commands.
189
190       network_reset(self)
191       Reset the network by flushing all the chains in the table using
192       the iptables command.
193
194       nfs_debug_enable(self, **kwargs)
195       Enable NFS debug messages.
196
197
198              rpcdebug:
199                     Set RPC kernel debug flags and save log messages [default: self.rpcdebug]
200
201              nfsdebug:
202                     Set NFS kernel debug flags and save log messages [default: self.nfsdebug]
203
204              dbgfile:
205                     Name of log messages file to create, default is a unique name
206                     created in the temporary directory using self.dbgname as the
207                     base name.
208
209       nfs_debug_reset(self)
210       Reset NFS debug messages.
211
212       nfsstr(self, version=None)
213       Return the NFS string for the given NFS version
214
215
216              version:
217                     NFS version, default is the object attribute nfsversion
218
219       nfsvers(self, version=None)
220       Return major and minor version for the given NFS version
221
222
223              version:
224                     NFS version, default is the object attribute nfsversion
225
226       run_cmd(self, cmd, sudo=False, dlevel='DBG1', msg='', wait=True)
227       Run the command to the remote machine using ssh.
228       There is no user authentication, so remote host must allow
229       ssh connection without any passwords for the user.
230       For a localhost the command is just executed and ssh is not used.
231
232       The object for the process of the command is stored in object
233       attribute 'self.process' to be used by methods wait_cmd() and
234       stop_cmd(). The standard output of the command is also stored
235       in the object attribute 'self.pstdout' while the standard error
236       output of the command is stored in 'self.pstderr'.
237
238
239              cmd:   Command to execute
240
241              sudo:  Run command using sudo if option is True
242
243              dlevel:
244                     Debug level for displaying the command to the user
245
246              msg:   Prefix this message to the debug message to be displayed
247
248              wait:  Wait for command to complete before returning
249
250              Return the standard output of the command and the return code or
251              exit status is stored in the object attribute 'self.returncode'.
252
253       stop_cmd(self, process=None, dlevel=None, msg='')
254       Terminate command started by run_cmd() by calling wait_cmd()
255       with the 'terminate' option set to True.
256
257
258              process:
259                     The object for the process of the command to terminate,
260                     or terminate all commands started by run_cmd() if this
261                     option is not given
262
263              dlevel:
264                     Debug level for displaying the command to the user, default
265                     is the level given by run_cmd()
266
267              msg:   Prefix this message to the debug message to be displayed
268
269              Return the exit status of the last command
270
271       sudo_cmd(self, cmd)
272       Prefix the SUDO command if effective user is not root.
273
274       trace_open(self, tracefile=None, **kwargs)
275       Open the trace file given or the trace file started by trace_start().
276
277       All extra options are passed directly to the packet trace object.
278
279       Return the packet trace object created, the packet trace object
280       is also stored in the object attribute pktt.
281
282       trace_start(self, tracefile=None, interface=None, capsize=None, clients=None)
283       Start trace on interface given
284
285
286              tracefile:
287                     Name of trace file to create, default is a unique name
288                     created in the temporary directory using self.tracename as the
289                     base name.
290
291              capsize:
292                     Use the -C option of tcpdump to split the trace files every
293                     1000000*capsize bytes. See documentation for tcpdump for more
294                     information
295
296              clients:
297                     List of Host() objects to monitor
298
299              Return the name of the trace file created.
300
301       trace_stop(self)
302       Stop the trace started by trace_start().
303
304       umount(self)
305       Unmount the file system.
306
307       wait_cmd(self, process=None, terminate=False, dlevel=None, msg='')
308       Wait for command started by run_cmd() to finish.
309
310
311              process:
312                     The object for the process of the command to wait for,
313                     or wait for all commands started by run_cmd() if this
314                     option is not given
315
316              terminate:
317                     If True, send a signal to terminate the command or commands
318                     and then wait for all commands to finish
319
320              dlevel:
321                     Debug level for displaying the command to the user, default
322                     is the level given by run_cmd()
323
324              msg:   Prefix this message to the debug message to be displayed
325
326              Return the exit status of the last command
327
328       Static methods defined here:
329       ----------------------------
330
331       get_ip_address(host='', ipv6=False)
332       Get IP address associated with the given host name.
333       This could be run as an instance or class method.
334

SEE ALSO

336       baseobj(3), packet.pktt(3)
337
338

BUGS

340       No known bugs.
341

AUTHOR

343       Jorge Mora (mora@netapp.com)
344
345
346
347NFStest 2.1.5                  14 February 2017                        HOST(3)
Impressum