34 |
34 |
from ganeti import constants
|
35 |
35 |
from ganeti import compat
|
36 |
36 |
from ganeti import errors
|
37 |
|
from ganeti import bootstrap
|
38 |
37 |
from ganeti import netutils
|
39 |
38 |
|
40 |
39 |
|
... | ... | |
112 |
111 |
_MODIFIABLE_STORAGE_TYPES = constants.MODIFIABLE_STORAGE_FIELDS.keys()
|
113 |
112 |
|
114 |
113 |
|
|
114 |
NONODE_SETUP_OPT = cli_option("--no-node-setup", default=True,
|
|
115 |
action="store_false", dest="node_setup",
|
|
116 |
help=("Do not make initial SSH setup on remote"
|
|
117 |
" node (needs to be done manually)"))
|
|
118 |
|
|
119 |
|
115 |
120 |
def ConvertStorageType(user_storage_type):
|
116 |
121 |
"""Converts a user storage type to its internal name.
|
117 |
122 |
|
... | ... | |
123 |
128 |
errors.ECODE_INVAL)
|
124 |
129 |
|
125 |
130 |
|
|
131 |
def _RunSetupSSH(options, nodes):
|
|
132 |
"""Wrapper around utils.RunCmd to call setup-ssh
|
|
133 |
|
|
134 |
@param options: The command line options
|
|
135 |
@param nodes: The nodes to setup
|
|
136 |
|
|
137 |
"""
|
|
138 |
cmd = [constants.SETUP_SSH]
|
|
139 |
|
|
140 |
# Pass --debug|--verbose to the external script if set on our invocation
|
|
141 |
# --debug overrides --verbose
|
|
142 |
if options.debug:
|
|
143 |
cmd.append("--debug")
|
|
144 |
elif options.verbose:
|
|
145 |
cmd.append("--verbose")
|
|
146 |
|
|
147 |
cmd.extend(nodes)
|
|
148 |
|
|
149 |
result = utils.RunCmd(cmd, interactive=True)
|
|
150 |
|
|
151 |
if result.failed:
|
|
152 |
errmsg = ("Command '%s' failed with exit code %s; output %r" %
|
|
153 |
(result.cmd, result.exit_code, result.output))
|
|
154 |
raise errors.OpExecError(errmsg)
|
|
155 |
|
|
156 |
|
126 |
157 |
@UsesRPC
|
127 |
158 |
def AddNode(opts, args):
|
128 |
159 |
"""Add a node to the cluster.
|
... | ... | |
160 |
191 |
|
161 |
192 |
# read the cluster name from the master
|
162 |
193 |
output = cl.QueryConfigValues(['cluster_name'])
|
163 |
|
cluster_name = output[0]
|
164 |
194 |
|
165 |
195 |
if not readd:
|
166 |
196 |
ToStderr("-- WARNING -- \n"
|
... | ... | |
170 |
200 |
" current one\n"
|
171 |
201 |
"and grant full intra-cluster ssh root access to/from it\n", node)
|
172 |
202 |
|
173 |
|
bootstrap.SetupNodeDaemon(cluster_name, node, opts.ssh_key_check)
|
|
203 |
if opts.node_setup:
|
|
204 |
_RunSetupSSH(opts, [node])
|
174 |
205 |
|
175 |
206 |
op = opcodes.OpAddNode(node_name=args[0], secondary_ip=sip,
|
176 |
207 |
readd=opts.readd)
|
... | ... | |
645 |
676 |
commands = {
|
646 |
677 |
'add': (
|
647 |
678 |
AddNode, [ArgHost(min=1, max=1)],
|
648 |
|
[SECONDARY_IP_OPT, READD_OPT, NOSSH_KEYCHECK_OPT],
|
649 |
|
"[-s ip] [--readd] [--no-ssh-key-check] <node_name>",
|
|
679 |
[SECONDARY_IP_OPT, READD_OPT, NONODE_SETUP_OPT, VERBOSE_OPT],
|
|
680 |
"[-s ip] [--readd] [--no-node-setup] [--verbose] "
|
|
681 |
" <node_name>",
|
650 |
682 |
"Add a node to the cluster"),
|
651 |
683 |
'evacuate': (
|
652 |
684 |
EvacuateNode, [ArgNode(min=1)],
|