Revision fbb6b864 lib/impexpd/__init__.py
b/lib/impexpd/__init__.py | ||
---|---|---|
197 | 197 |
",".join(addr1), ",".join(addr2) |
198 | 198 |
] |
199 | 199 |
|
200 |
def _GetTransportCommand(self):
|
|
201 |
"""Returns the command for the transport part of the daemon.
|
|
200 |
def _GetDdCommand(self):
|
|
201 |
"""Returns the command for measuring throughput.
|
|
202 | 202 |
|
203 | 203 |
""" |
204 |
socat_cmd = ("%s 2>&%d" % |
|
205 |
(utils.ShellQuoteArgs(self._GetSocatCommand()), |
|
206 |
self._socat_stderr_fd)) |
|
207 |
|
|
208 | 204 |
dd_cmd = StringIO() |
209 | 205 |
# Setting LC_ALL since we want to parse the output and explicitely |
210 | 206 |
# redirecting stdin, as the background process (dd) would have /dev/null as |
... | ... | |
216 | 212 |
# And wait for dd |
217 | 213 |
dd_cmd.write(" wait $pid;") |
218 | 214 |
dd_cmd.write(" }") |
215 |
return dd_cmd.getvalue() |
|
216 |
|
|
217 |
def _GetTransportCommand(self): |
|
218 |
"""Returns the command for the transport part of the daemon. |
|
219 |
|
|
220 |
""" |
|
221 |
socat_cmd = ("%s 2>&%d" % |
|
222 |
(utils.ShellQuoteArgs(self._GetSocatCommand()), |
|
223 |
self._socat_stderr_fd)) |
|
224 |
dd_cmd = self._GetDdCommand() |
|
219 | 225 |
|
220 | 226 |
compr = self._opts.compress |
221 | 227 |
|
222 | 228 |
assert compr in constants.IEC_ALL |
223 | 229 |
|
230 |
parts = [] |
|
231 |
|
|
224 | 232 |
if self._mode == constants.IEM_IMPORT: |
233 |
parts.append(socat_cmd) |
|
234 |
|
|
225 | 235 |
if compr == constants.IEC_GZIP: |
226 |
transport_cmd = "%s | gunzip -c" % socat_cmd
|
|
227 |
else: |
|
228 |
transport_cmd = socat_cmd
|
|
236 |
parts.append("gunzip -c")
|
|
237 |
|
|
238 |
parts.append(dd_cmd)
|
|
229 | 239 |
|
230 |
transport_cmd += " | %s" % dd_cmd.getvalue() |
|
231 | 240 |
elif self._mode == constants.IEM_EXPORT: |
241 |
parts.append(dd_cmd) |
|
242 |
|
|
232 | 243 |
if compr == constants.IEC_GZIP: |
233 |
transport_cmd = "gzip -c | %s" % socat_cmd
|
|
234 |
else: |
|
235 |
transport_cmd = socat_cmd
|
|
244 |
parts.append("gzip -c")
|
|
245 |
|
|
246 |
parts.append(socat_cmd)
|
|
236 | 247 |
|
237 |
transport_cmd = "%s | %s" % (dd_cmd.getvalue(), transport_cmd) |
|
238 | 248 |
else: |
239 | 249 |
raise errors.GenericError("Invalid mode '%s'" % self._mode) |
240 | 250 |
|
241 | 251 |
# TODO: Run transport as separate user |
242 | 252 |
# The transport uses its own shell to simplify running it as a separate user |
243 | 253 |
# in the future. |
244 |
return self.GetBashCommand(transport_cmd)
|
|
254 |
return self.GetBashCommand(" | ".join(parts))
|
|
245 | 255 |
|
246 | 256 |
def GetCommand(self): |
247 | 257 |
"""Returns the complete child process command. |
Also available in: Unified diff