Revision 56b9f2db

b/qa/qa_utils.py
160 160
                         (cmdstr, nodename, rcode))
161 161

  
162 162

  
163
def AssertCommand(cmd, fail=False, node=None):
163
def AssertCommand(cmd, fail=False, node=None, log_cmd=True):
164 164
  """Checks that a remote command succeeds.
165 165

  
166 166
  @param cmd: either a string (the command to execute) or a list (to
......
170 170
  @param node: if passed, it should be the node on which the command
171 171
      should be executed, instead of the master node (can be either a
172 172
      dict or a string)
173
  @param log_cmd: if False, the command won't be logged (simply passed to
174
      StartSSH)
173 175
  @return: the return code of the command
174 176
  @raise qa_error.Error: if the command fails when it shouldn't or vice versa
175 177

  
......
184 186
  else:
185 187
    cmdstr = utils.ShellQuoteArgs(cmd)
186 188

  
187
  rcode = StartSSH(nodename, cmdstr).wait()
189
  rcode = StartSSH(nodename, cmdstr, log_cmd=log_cmd).wait()
188 190
  _AssertRetCode(rcode, fail, cmdstr, nodename)
189 191

  
190 192
  return rcode
......
234 236
  return args
235 237

  
236 238

  
237
def StartLocalCommand(cmd, _nolog_opts=False, **kwargs):
239
def StartLocalCommand(cmd, _nolog_opts=False, log_cmd=True, **kwargs):
238 240
  """Starts a local command.
239 241

  
240 242
  """
241
  if _nolog_opts:
242
    pcmd = [i for i in cmd if not i.startswith("-")]
243
  else:
244
    pcmd = cmd
245
  print "Command: %s" % utils.ShellQuoteArgs(pcmd)
243
  if log_cmd:
244
    if _nolog_opts:
245
      pcmd = [i for i in cmd if not i.startswith("-")]
246
    else:
247
      pcmd = cmd
248
    print "Command: %s" % utils.ShellQuoteArgs(pcmd)
246 249
  return subprocess.Popen(cmd, shell=False, **kwargs)
247 250

  
248 251

  
249
def StartSSH(node, cmd, strict=True):
252
def StartSSH(node, cmd, strict=True, log_cmd=True):
250 253
  """Starts SSH.
251 254

  
252 255
  """
253 256
  return StartLocalCommand(GetSSHCommand(node, cmd, strict=strict),
254
                           _nolog_opts=True)
257
                           _nolog_opts=True, log_cmd=log_cmd)
255 258

  
256 259

  
257 260
def StartMultiplexer(node):

Also available in: Unified diff