Revision a698cdbb lib/client/gnt_node.py

b/lib/client/gnt_node.py
28 28

  
29 29
import itertools
30 30
import errno
31
import tempfile
32 31

  
33 32
from ganeti.cli import *
34 33
from ganeti import cli
......
39 38
from ganeti import errors
40 39
from ganeti import netutils
41 40
from ganeti import pathutils
42
from ganeti import serializer
43 41
from ganeti import ssh
44 42
from cStringIO import StringIO
45 43

  
......
198 196
    ToStderr("The \"--force-join\" option is no longer supported and will be"
199 197
             " ignored.")
200 198

  
201
  cmd = [pathutils.PREPARE_NODE_JOIN]
202

  
203
  # Pass --debug/--verbose to the external script if set on our invocation
204
  if options.debug:
205
    cmd.append("--debug")
206

  
207
  if options.verbose:
208
    cmd.append("--verbose")
209

  
210 199
  host_keys = _ReadSshKeys(constants.SSH_DAEMON_KEYFILES)
211 200

  
212 201
  (_, root_keyfiles) = \
......
224 213
    constants.SSHS_SSH_ROOT_KEY: root_keys,
225 214
    }
226 215

  
227
  srun = ssh.SshRunner(cluster_name)
228
  scmd = srun.BuildCmd(node, constants.SSH_LOGIN_USER,
229
                       utils.ShellQuoteArgs(cmd),
230
                       batch=False, ask_key=options.ssh_key_check,
231
                       strict_host_check=options.ssh_key_check, quiet=False,
232
                       use_cluster_key=False)
233

  
234
  tempfh = tempfile.TemporaryFile()
235
  try:
236
    tempfh.write(serializer.DumpJson(data))
237
    tempfh.seek(0)
238

  
239
    result = utils.RunCmd(scmd, interactive=True, input_fd=tempfh)
240
  finally:
241
    tempfh.close()
242

  
243
  if result.failed:
244
    raise errors.OpExecError("Command '%s' failed: %s" %
245
                             (result.cmd, result.fail_reason))
216
  bootstrap.RunNodeSetupCmd(cluster_name, node, pathutils.PREPARE_NODE_JOIN,
217
                            options.debug, options.verbose, False,
218
                            options.ssh_key_check, options.ssh_key_check, data)
246 219

  
247 220

  
248 221
@UsesRPC

Also available in: Unified diff