Revision 49d50e52 qa/qa_utils.py

b/qa/qa_utils.py
150 150

  
151 151
  Caller needs to remove the returned file on the node when it's not needed
152 152
  anymore.
153

  
153 154
  """
154 155
  # Make sure nobody else has access to it while preserving local permissions
155 156
  mode = os.stat(src).st_mode & 0700
......
171 172
    f.close()
172 173

  
173 174

  
175
def BackupFile(node, path):
176
  """Creates a backup of a file on the node and returns the filename.
177

  
178
  Caller needs to remove the returned file on the node when it's not needed
179
  anymore.
180

  
181
  """
182
  cmd = ("tmp=$(tempfile --prefix .gnt --directory=$(dirname %s)) && "
183
         "[[ -f \"$tmp\" ]] && "
184
         "cp %s $tmp && "
185
         "echo $tmp") % (utils.ShellQuote(path), utils.ShellQuote(path))
186

  
187
  # Return temporary filename
188
  return GetCommandOutput(node, cmd).strip()
189

  
190

  
174 191
def _ResolveName(cmd, key):
175 192
  """Helper function.
176 193

  

Also available in: Unified diff