import itertools
import errno
-import tempfile
from ganeti.cli import *
from ganeti import cli
from ganeti import errors
from ganeti import netutils
from ganeti import pathutils
-from ganeti import serializer
from ganeti import ssh
+from ganeti import compat
from cStringIO import StringIO
from ganeti import confd
_MODIFIABLE_STORAGE_TYPES = constants.MODIFIABLE_STORAGE_FIELDS.keys()
+_OOB_COMMAND_ASK = compat.UniqueFrozenset([
+ constants.OOB_POWER_OFF,
+ constants.OOB_POWER_CYCLE,
+ ])
-_OOB_COMMAND_ASK = frozenset([constants.OOB_POWER_OFF,
- constants.OOB_POWER_CYCLE])
-
-
-_ENV_OVERRIDE = frozenset(["list"])
-
+_ENV_OVERRIDE = compat.UniqueFrozenset(["list"])
NONODE_SETUP_OPT = cli_option("--no-node-setup", default=True,
action="store_false", dest="node_setup",
ToStderr("The \"--force-join\" option is no longer supported and will be"
" ignored.")
- cmd = [pathutils.PREPARE_NODE_JOIN]
-
- # Pass --debug/--verbose to the external script if set on our invocation
- if options.debug:
- cmd.append("--debug")
-
- if options.verbose:
- cmd.append("--verbose")
-
host_keys = _ReadSshKeys(constants.SSH_DAEMON_KEYFILES)
(_, root_keyfiles) = \
constants.SSHS_SSH_ROOT_KEY: root_keys,
}
- srun = ssh.SshRunner(cluster_name)
- scmd = srun.BuildCmd(node, constants.SSH_LOGIN_USER,
- utils.ShellQuoteArgs(cmd),
- batch=False, ask_key=options.ssh_key_check,
- strict_host_check=options.ssh_key_check, quiet=False,
- use_cluster_key=False)
-
- tempfh = tempfile.TemporaryFile()
- try:
- tempfh.write(serializer.DumpJson(data))
- tempfh.seek(0)
-
- result = utils.RunCmd(scmd, interactive=True, input_fd=tempfh)
- finally:
- tempfh.close()
-
- if result.failed:
- raise errors.OpExecError("Command '%s' failed: %s" %
- (result.cmd, result.fail_reason))
+ bootstrap.RunNodeSetupCmd(cluster_name, node, pathutils.PREPARE_NODE_JOIN,
+ options.debug, options.verbose, False,
+ options.ssh_key_check, options.ssh_key_check, data)
@UsesRPC
if opts.node_setup:
_SetupSSH(opts, cluster_name, node)
- bootstrap.SetupNodeDaemon(cluster_name, node, opts.ssh_key_check)
+ bootstrap.SetupNodeDaemon(opts, cluster_name, node)
if opts.disk_state:
disk_state = utils.FlatToDict(opts.disk_state)