Statistics
| Branch: | Tag: | Revision:

root / scripts / gnt-cluster @ 9a033156

History | View | Annotate | Download (14.2 kB)

1 a8083063 Iustin Pop
#!/usr/bin/python
2 a8083063 Iustin Pop
#
3 a8083063 Iustin Pop
4 a8083063 Iustin Pop
# Copyright (C) 2006, 2007 Google Inc.
5 a8083063 Iustin Pop
#
6 a8083063 Iustin Pop
# This program is free software; you can redistribute it and/or modify
7 a8083063 Iustin Pop
# it under the terms of the GNU General Public License as published by
8 a8083063 Iustin Pop
# the Free Software Foundation; either version 2 of the License, or
9 a8083063 Iustin Pop
# (at your option) any later version.
10 a8083063 Iustin Pop
#
11 a8083063 Iustin Pop
# This program is distributed in the hope that it will be useful, but
12 a8083063 Iustin Pop
# WITHOUT ANY WARRANTY; without even the implied warranty of
13 a8083063 Iustin Pop
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 a8083063 Iustin Pop
# General Public License for more details.
15 a8083063 Iustin Pop
#
16 a8083063 Iustin Pop
# You should have received a copy of the GNU General Public License
17 a8083063 Iustin Pop
# along with this program; if not, write to the Free Software
18 a8083063 Iustin Pop
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 a8083063 Iustin Pop
# 02110-1301, USA.
20 a8083063 Iustin Pop
21 a8083063 Iustin Pop
22 a8083063 Iustin Pop
import sys
23 a8083063 Iustin Pop
from optparse import make_option
24 a8083063 Iustin Pop
import pprint
25 a8083063 Iustin Pop
26 a8083063 Iustin Pop
from ganeti.cli import *
27 a8083063 Iustin Pop
from ganeti import opcodes
28 c2a62a33 Michael Hanselmann
from ganeti import constants
29 f4d4e184 Iustin Pop
from ganeti import errors
30 b63ed789 Iustin Pop
from ganeti import utils
31 a8083063 Iustin Pop
32 a8083063 Iustin Pop
33 a8083063 Iustin Pop
def InitCluster(opts, args):
34 a8083063 Iustin Pop
  """Initialize the cluster.
35 a8083063 Iustin Pop
36 a8083063 Iustin Pop
  Args:
37 a8083063 Iustin Pop
    opts - class with options as members
38 a8083063 Iustin Pop
    args - list of arguments, expected to be [clustername]
39 a8083063 Iustin Pop
40 a8083063 Iustin Pop
  """
41 90b6aa3a Manuel Franceschini
  if not opts.lvm_storage and opts.vg_name:
42 90b6aa3a Manuel Franceschini
    print ("Options --no-lvm-storage and --vg-name conflict.")
43 90b6aa3a Manuel Franceschini
    return 1
44 90b6aa3a Manuel Franceschini
45 90b6aa3a Manuel Franceschini
  vg_name = opts.vg_name
46 90b6aa3a Manuel Franceschini
  if opts.lvm_storage and not opts.vg_name:
47 90b6aa3a Manuel Franceschini
    vg_name = constants.DEFAULT_VG
48 90b6aa3a Manuel Franceschini
49 a8083063 Iustin Pop
  op = opcodes.OpInitCluster(cluster_name=args[0],
50 a8083063 Iustin Pop
                             secondary_ip=opts.secondary_ip,
51 a8083063 Iustin Pop
                             hypervisor_type=opts.hypervisor_type,
52 90b6aa3a Manuel Franceschini
                             vg_name=vg_name,
53 a8083063 Iustin Pop
                             mac_prefix=opts.mac_prefix,
54 880478f8 Iustin Pop
                             def_bridge=opts.def_bridge,
55 79e82404 Manuel Franceschini
                             master_netdev=opts.master_netdev,
56 79e82404 Manuel Franceschini
                             file_storage_dir=opts.file_storage_dir)
57 a8083063 Iustin Pop
  SubmitOpCode(op)
58 a8083063 Iustin Pop
  return 0
59 a8083063 Iustin Pop
60 a8083063 Iustin Pop
61 a8083063 Iustin Pop
def DestroyCluster(opts, args):
62 a8083063 Iustin Pop
  """Destroy the cluster.
63 a8083063 Iustin Pop
64 a8083063 Iustin Pop
  Args:
65 a8083063 Iustin Pop
    opts - class with options as members
66 098c0958 Michael Hanselmann
67 a8083063 Iustin Pop
  """
68 a8083063 Iustin Pop
  if not opts.yes_do_it:
69 a8083063 Iustin Pop
    print ("Destroying a cluster is irreversibly. If you really want destroy"
70 79f7be7b Iustin Pop
           " this cluster, supply the --yes-do-it option.")
71 a8083063 Iustin Pop
    return 1
72 a8083063 Iustin Pop
73 a8083063 Iustin Pop
  op = opcodes.OpDestroyCluster()
74 a8083063 Iustin Pop
  SubmitOpCode(op)
75 a8083063 Iustin Pop
  return 0
76 a8083063 Iustin Pop
77 a8083063 Iustin Pop
78 07bd8a51 Iustin Pop
def RenameCluster(opts, args):
79 07bd8a51 Iustin Pop
  """Rename the cluster.
80 07bd8a51 Iustin Pop
81 07bd8a51 Iustin Pop
  Args:
82 07bd8a51 Iustin Pop
    opts - class with options as members, we use force only
83 07bd8a51 Iustin Pop
    args - list of arguments, expected to be [new_name]
84 07bd8a51 Iustin Pop
85 07bd8a51 Iustin Pop
  """
86 07bd8a51 Iustin Pop
  name = args[0]
87 07bd8a51 Iustin Pop
  if not opts.force:
88 07bd8a51 Iustin Pop
    usertext = ("This will rename the cluster to '%s'. If you are connected"
89 07bd8a51 Iustin Pop
                " over the network to the cluster name, the operation is very"
90 07bd8a51 Iustin Pop
                " dangerous as the IP address will be removed from the node"
91 07bd8a51 Iustin Pop
                " and the change may not go through. Continue?") % name
92 47988778 Iustin Pop
    if not AskUser(usertext):
93 07bd8a51 Iustin Pop
      return 1
94 07bd8a51 Iustin Pop
95 07bd8a51 Iustin Pop
  op = opcodes.OpRenameCluster(name=name)
96 07bd8a51 Iustin Pop
  SubmitOpCode(op)
97 07bd8a51 Iustin Pop
  return 0
98 07bd8a51 Iustin Pop
99 07bd8a51 Iustin Pop
100 a8083063 Iustin Pop
def ShowClusterVersion(opts, args):
101 a8083063 Iustin Pop
  """Write version of ganeti software to the standard output.
102 a8083063 Iustin Pop
103 a8083063 Iustin Pop
  Args:
104 a8083063 Iustin Pop
    opts - class with options as members
105 a8083063 Iustin Pop
106 a8083063 Iustin Pop
  """
107 a8083063 Iustin Pop
  op = opcodes.OpQueryClusterInfo()
108 a8083063 Iustin Pop
  result = SubmitOpCode(op)
109 a8083063 Iustin Pop
  print ("Software version: %s" % result["software_version"])
110 a8083063 Iustin Pop
  print ("Internode protocol: %s" % result["protocol_version"])
111 a8083063 Iustin Pop
  print ("Configuration format: %s" % result["config_version"])
112 a8083063 Iustin Pop
  print ("OS api version: %s" % result["os_api_version"])
113 a8083063 Iustin Pop
  print ("Export interface: %s" % result["export_version"])
114 a8083063 Iustin Pop
  return 0
115 a8083063 Iustin Pop
116 a8083063 Iustin Pop
117 a8083063 Iustin Pop
def ShowClusterMaster(opts, args):
118 a8083063 Iustin Pop
  """Write name of master node to the standard output.
119 a8083063 Iustin Pop
120 a8083063 Iustin Pop
  Args:
121 a8083063 Iustin Pop
    opts - class with options as members
122 a8083063 Iustin Pop
123 a8083063 Iustin Pop
  """
124 a8083063 Iustin Pop
  op = opcodes.OpQueryClusterInfo()
125 a8083063 Iustin Pop
  result = SubmitOpCode(op)
126 a8083063 Iustin Pop
  print (result["master"])
127 a8083063 Iustin Pop
  return 0
128 a8083063 Iustin Pop
129 a8083063 Iustin Pop
130 a8083063 Iustin Pop
def ShowClusterConfig(opts, args):
131 a8083063 Iustin Pop
  """Shows cluster information.
132 a8083063 Iustin Pop
133 a8083063 Iustin Pop
  """
134 a8083063 Iustin Pop
  op = opcodes.OpQueryClusterInfo()
135 a8083063 Iustin Pop
  result = SubmitOpCode(op)
136 a8083063 Iustin Pop
137 a8083063 Iustin Pop
  print ("Cluster name: %s" % result["name"])
138 a8083063 Iustin Pop
139 a8083063 Iustin Pop
  print ("Master node: %s" % result["master"])
140 a8083063 Iustin Pop
141 59322403 Iustin Pop
  print ("Architecture (this node): %s (%s)" %
142 59322403 Iustin Pop
         (result["architecture"][0], result["architecture"][1]))
143 a8083063 Iustin Pop
144 a8083063 Iustin Pop
  return 0
145 a8083063 Iustin Pop
146 a8083063 Iustin Pop
147 a8083063 Iustin Pop
def ClusterCopyFile(opts, args):
148 a8083063 Iustin Pop
  """Copy a file from master to some nodes.
149 a8083063 Iustin Pop
150 a8083063 Iustin Pop
  Args:
151 a8083063 Iustin Pop
    opts - class with options as members
152 a8083063 Iustin Pop
    args - list containing a single element, the file name
153 a8083063 Iustin Pop
  Opts used:
154 a8083063 Iustin Pop
    nodes - list containing the name of target nodes; if empty, all nodes
155 a8083063 Iustin Pop
156 a8083063 Iustin Pop
  """
157 a8083063 Iustin Pop
  op = opcodes.OpClusterCopyFile(filename=args[0], nodes=opts.nodes)
158 a8083063 Iustin Pop
  SubmitOpCode(op)
159 a8083063 Iustin Pop
  return 0
160 a8083063 Iustin Pop
161 a8083063 Iustin Pop
162 a8083063 Iustin Pop
def RunClusterCommand(opts, args):
163 a8083063 Iustin Pop
  """Run a command on some nodes.
164 a8083063 Iustin Pop
165 a8083063 Iustin Pop
  Args:
166 a8083063 Iustin Pop
    opts - class with options as members
167 a8083063 Iustin Pop
    args - the command list as a list
168 a8083063 Iustin Pop
  Opts used:
169 a8083063 Iustin Pop
    nodes: list containing the name of target nodes; if empty, all nodes
170 a8083063 Iustin Pop
171 a8083063 Iustin Pop
  """
172 a8083063 Iustin Pop
  command = " ".join(args)
173 a8083063 Iustin Pop
  nodes = opts.nodes
174 a8083063 Iustin Pop
  op = opcodes.OpRunClusterCommand(command=command, nodes=nodes)
175 a8083063 Iustin Pop
  result = SubmitOpCode(op)
176 02715459 Iustin Pop
  for node, output, exit_code in result:
177 a8083063 Iustin Pop
    print ("------------------------------------------------")
178 a8083063 Iustin Pop
    print ("node: %s" % node)
179 a8083063 Iustin Pop
    print ("%s" % output)
180 a8083063 Iustin Pop
    print ("return code = %s" % exit_code)
181 a8083063 Iustin Pop
182 a8083063 Iustin Pop
183 a8083063 Iustin Pop
def VerifyCluster(opts, args):
184 a8083063 Iustin Pop
  """Verify integrity of cluster, performing various test on nodes.
185 a8083063 Iustin Pop
186 a8083063 Iustin Pop
  Args:
187 a8083063 Iustin Pop
    opts - class with options as members
188 a8083063 Iustin Pop
189 a8083063 Iustin Pop
  """
190 e54c4c5e Guido Trotter
  skip_checks=[]
191 e54c4c5e Guido Trotter
  if opts.skip_nplusone_mem:
192 e54c4c5e Guido Trotter
    skip_checks.append(constants.VERIFY_NPLUSONE_MEM)
193 e54c4c5e Guido Trotter
  op = opcodes.OpVerifyCluster(skip_checks=skip_checks)
194 a8083063 Iustin Pop
  result = SubmitOpCode(op)
195 a8083063 Iustin Pop
  return result
196 a8083063 Iustin Pop
197 a8083063 Iustin Pop
198 f4d4e184 Iustin Pop
def VerifyDisks(opts, args):
199 f4d4e184 Iustin Pop
  """Verify integrity of cluster disks.
200 f4d4e184 Iustin Pop
201 f4d4e184 Iustin Pop
  Args:
202 f4d4e184 Iustin Pop
    opts - class with options as members
203 f4d4e184 Iustin Pop
204 f4d4e184 Iustin Pop
  """
205 f4d4e184 Iustin Pop
  op = opcodes.OpVerifyDisks()
206 f4d4e184 Iustin Pop
  result = SubmitOpCode(op)
207 b63ed789 Iustin Pop
  if not isinstance(result, tuple) or len(result) != 4:
208 f4d4e184 Iustin Pop
    raise errors.ProgrammerError("Unknown result type for OpVerifyDisks")
209 f4d4e184 Iustin Pop
210 b63ed789 Iustin Pop
  nodes, nlvm, instances, missing = result
211 b63ed789 Iustin Pop
212 f4d4e184 Iustin Pop
  if nodes:
213 f4d4e184 Iustin Pop
    print "Nodes unreachable or with bad data:"
214 f4d4e184 Iustin Pop
    for name in nodes:
215 f4d4e184 Iustin Pop
      print "\t%s" % name
216 f4d4e184 Iustin Pop
  retcode = constants.EXIT_SUCCESS
217 b63ed789 Iustin Pop
218 b63ed789 Iustin Pop
  if nlvm:
219 b63ed789 Iustin Pop
    for node, text in nlvm.iteritems():
220 b63ed789 Iustin Pop
      print ("Error on node %s: LVM error: %s" %
221 b63ed789 Iustin Pop
             (node, text[-400:].encode('string_escape')))
222 b63ed789 Iustin Pop
      retcode |= 1
223 b63ed789 Iustin Pop
      print "You need to fix these nodes first before fixing instances"
224 b63ed789 Iustin Pop
225 f4d4e184 Iustin Pop
  if instances:
226 f4d4e184 Iustin Pop
    for iname in instances:
227 b63ed789 Iustin Pop
      if iname in missing:
228 b63ed789 Iustin Pop
        continue
229 f4d4e184 Iustin Pop
      op = opcodes.OpActivateInstanceDisks(instance_name=iname)
230 f4d4e184 Iustin Pop
      try:
231 f4d4e184 Iustin Pop
        print "Activating disks for instance '%s'" % iname
232 f4d4e184 Iustin Pop
        SubmitOpCode(op)
233 f4d4e184 Iustin Pop
      except errors.GenericError, err:
234 f4d4e184 Iustin Pop
        nret, msg = FormatError(err)
235 f4d4e184 Iustin Pop
        retcode |= nret
236 b63ed789 Iustin Pop
        print >> sys.stderr, ("Error activating disks for instance %s: %s" %
237 b63ed789 Iustin Pop
                              (iname, msg))
238 b63ed789 Iustin Pop
239 b63ed789 Iustin Pop
  if missing:
240 b63ed789 Iustin Pop
    for iname, ival in missing.iteritems():
241 b63ed789 Iustin Pop
      all_missing = utils.all(ival, lambda x: x[0] in nlvm)
242 b63ed789 Iustin Pop
      if all_missing:
243 b63ed789 Iustin Pop
        print ("Instance %s cannot be verified as it lives on"
244 b63ed789 Iustin Pop
               " broken nodes" % iname)
245 b63ed789 Iustin Pop
      else:
246 b63ed789 Iustin Pop
        print "Instance %s has missing logical volumes:" % iname
247 b63ed789 Iustin Pop
        ival.sort()
248 b63ed789 Iustin Pop
        for node, vol in ival:
249 b63ed789 Iustin Pop
          if node in nlvm:
250 b63ed789 Iustin Pop
            print ("\tbroken node %s /dev/xenvg/%s" % (node, vol))
251 b63ed789 Iustin Pop
          else:
252 b63ed789 Iustin Pop
            print ("\t%s /dev/xenvg/%s" % (node, vol))
253 b63ed789 Iustin Pop
    print ("You need to run replace_disks for all the above"
254 b63ed789 Iustin Pop
           " instances, if this message persist after fixing nodes.")
255 b63ed789 Iustin Pop
    retcode |= 1
256 f4d4e184 Iustin Pop
257 f4d4e184 Iustin Pop
  return retcode
258 f4d4e184 Iustin Pop
259 f4d4e184 Iustin Pop
260 a8083063 Iustin Pop
def MasterFailover(opts, args):
261 a8083063 Iustin Pop
  """Failover the master node.
262 a8083063 Iustin Pop
263 a8083063 Iustin Pop
  This command, when run on a non-master node, will cause the current
264 a8083063 Iustin Pop
  master to cease being master, and the non-master to become new
265 a8083063 Iustin Pop
  master.
266 a8083063 Iustin Pop
267 a8083063 Iustin Pop
  """
268 a8083063 Iustin Pop
  op = opcodes.OpMasterFailover()
269 a8083063 Iustin Pop
  SubmitOpCode(op)
270 a8083063 Iustin Pop
271 a8083063 Iustin Pop
272 73415719 Iustin Pop
def SearchTags(opts, args):
273 73415719 Iustin Pop
  """Searches the tags on all the cluster.
274 73415719 Iustin Pop
275 73415719 Iustin Pop
  """
276 73415719 Iustin Pop
  op = opcodes.OpSearchTags(pattern=args[0])
277 73415719 Iustin Pop
  result = SubmitOpCode(op)
278 73415719 Iustin Pop
  if not result:
279 73415719 Iustin Pop
    return 1
280 73415719 Iustin Pop
  result = list(result)
281 73415719 Iustin Pop
  result.sort()
282 73415719 Iustin Pop
  for path, tag in result:
283 73415719 Iustin Pop
    print "%s %s" % (path, tag)
284 73415719 Iustin Pop
285 73415719 Iustin Pop
286 90b6aa3a Manuel Franceschini
def SetClusterParams(opts, args):
287 90b6aa3a Manuel Franceschini
  """Modify the cluster.
288 90b6aa3a Manuel Franceschini
289 90b6aa3a Manuel Franceschini
  Args:
290 90b6aa3a Manuel Franceschini
    opts - class with options as members
291 90b6aa3a Manuel Franceschini
292 90b6aa3a Manuel Franceschini
  """
293 90b6aa3a Manuel Franceschini
  if not (not opts.lvm_storage or opts.vg_name):
294 90b6aa3a Manuel Franceschini
    print "Please give at least one of the parameters."
295 90b6aa3a Manuel Franceschini
    return 1
296 90b6aa3a Manuel Franceschini
297 90b6aa3a Manuel Franceschini
  vg_name = opts.vg_name
298 90b6aa3a Manuel Franceschini
  if not opts.lvm_storage and opts.vg_name:
299 90b6aa3a Manuel Franceschini
    print ("Options --no-lvm-storage and --vg-name conflict.")
300 90b6aa3a Manuel Franceschini
    return 1
301 90b6aa3a Manuel Franceschini
302 90b6aa3a Manuel Franceschini
  op = opcodes.OpSetClusterParams(vg_name=opts.vg_name)
303 90b6aa3a Manuel Franceschini
  SubmitOpCode(op)
304 90b6aa3a Manuel Franceschini
  return 0
305 90b6aa3a Manuel Franceschini
306 90b6aa3a Manuel Franceschini
307 a8083063 Iustin Pop
# this is an option common to more than one command, so we declare
308 a8083063 Iustin Pop
# it here and reuse it
309 a8083063 Iustin Pop
node_option = make_option("-n", "--node", action="append", dest="nodes",
310 f4bc1f2c Michael Hanselmann
                          help="Node to copy to (if not given, all nodes),"
311 f4bc1f2c Michael Hanselmann
                               " can be given multiple times",
312 f4bc1f2c Michael Hanselmann
                          metavar="<node>", default=[])
313 a8083063 Iustin Pop
314 a8083063 Iustin Pop
commands = {
315 a8083063 Iustin Pop
  'init': (InitCluster, ARGS_ONE,
316 a8083063 Iustin Pop
           [DEBUG_OPT,
317 a8083063 Iustin Pop
            make_option("-s", "--secondary-ip", dest="secondary_ip",
318 a8083063 Iustin Pop
                        help="Specify the secondary ip for this node;"
319 a8083063 Iustin Pop
                        " if given, the entire cluster must have secondary"
320 a8083063 Iustin Pop
                        " addresses",
321 a8083063 Iustin Pop
                        metavar="ADDRESS", default=None),
322 a8083063 Iustin Pop
            make_option("-t", "--hypervisor-type", dest="hypervisor_type",
323 2a6469d5 Alexander Schreiber
                        help="Specify the hypervisor type "
324 2a6469d5 Alexander Schreiber
                        "(xen-3.0, fake, xen-hvm-3.1)",
325 2a6469d5 Alexander Schreiber
                        metavar="TYPE", choices=["xen-3.0",
326 2a6469d5 Alexander Schreiber
                                                 "fake",
327 2a6469d5 Alexander Schreiber
                                                 "xen-hvm-3.1"],
328 a8083063 Iustin Pop
                        default="xen-3.0",),
329 a8083063 Iustin Pop
            make_option("-m", "--mac-prefix", dest="mac_prefix",
330 a8083063 Iustin Pop
                        help="Specify the mac prefix for the instance IP"
331 a8083063 Iustin Pop
                        " addresses, in the format XX:XX:XX",
332 a8083063 Iustin Pop
                        metavar="PREFIX",
333 a8083063 Iustin Pop
                        default="aa:00:00",),
334 a8083063 Iustin Pop
            make_option("-g", "--vg-name", dest="vg_name",
335 a8083063 Iustin Pop
                        help="Specify the volume group name "
336 a8083063 Iustin Pop
                        " (cluster-wide) for disk allocation [xenvg]",
337 a8083063 Iustin Pop
                        metavar="VG",
338 90b6aa3a Manuel Franceschini
                        default=None,),
339 a8083063 Iustin Pop
            make_option("-b", "--bridge", dest="def_bridge",
340 a8083063 Iustin Pop
                        help="Specify the default bridge name (cluster-wide)"
341 cf62a272 Michael Hanselmann
                          " to connect the instances to [%s]" %
342 cf62a272 Michael Hanselmann
                          constants.DEFAULT_BRIDGE,
343 a8083063 Iustin Pop
                        metavar="BRIDGE",
344 cf62a272 Michael Hanselmann
                        default=constants.DEFAULT_BRIDGE,),
345 880478f8 Iustin Pop
            make_option("--master-netdev", dest="master_netdev",
346 880478f8 Iustin Pop
                        help="Specify the node interface (cluster-wide)"
347 cf62a272 Michael Hanselmann
                          " on which the master IP address will be added "
348 cf62a272 Michael Hanselmann
                          " [%s]" % constants.DEFAULT_BRIDGE,
349 880478f8 Iustin Pop
                        metavar="NETDEV",
350 cf62a272 Michael Hanselmann
                        default=constants.DEFAULT_BRIDGE,),
351 79e82404 Manuel Franceschini
            make_option("--file-storage-dir", dest="file_storage_dir",
352 79e82404 Manuel Franceschini
                        help="Specify the default directory (cluster-wide)"
353 79e82404 Manuel Franceschini
                             " for storing the file-based disks [%s]" %
354 79e82404 Manuel Franceschini
                             constants.DEFAULT_FILE_STORAGE_DIR,
355 79e82404 Manuel Franceschini
                        metavar="DIR",
356 79e82404 Manuel Franceschini
                        default=constants.DEFAULT_FILE_STORAGE_DIR,),
357 90b6aa3a Manuel Franceschini
            make_option("--no-lvm-storage", dest="lvm_storage",
358 90b6aa3a Manuel Franceschini
                        help="No support for lvm based instances"
359 90b6aa3a Manuel Franceschini
                             " (cluster-wide)",
360 90b6aa3a Manuel Franceschini
                        action="store_false", default=True,),
361 a8083063 Iustin Pop
            ],
362 9a033156 Iustin Pop
           "[opts...] <cluster_name>",
363 a8083063 Iustin Pop
           "Initialises a new cluster configuration"),
364 a8083063 Iustin Pop
  'destroy': (DestroyCluster, ARGS_NONE,
365 a8083063 Iustin Pop
              [DEBUG_OPT,
366 a8083063 Iustin Pop
               make_option("--yes-do-it", dest="yes_do_it",
367 a8083063 Iustin Pop
                           help="Destroy cluster",
368 a8083063 Iustin Pop
                           action="store_true"),
369 a8083063 Iustin Pop
              ],
370 9a033156 Iustin Pop
              "", "Destroy cluster"),
371 07bd8a51 Iustin Pop
  'rename': (RenameCluster, ARGS_ONE, [DEBUG_OPT, FORCE_OPT],
372 9a033156 Iustin Pop
               "<new_name>",
373 07bd8a51 Iustin Pop
               "Renames the cluster"),
374 e54c4c5e Guido Trotter
  'verify': (VerifyCluster, ARGS_NONE, [DEBUG_OPT,
375 e54c4c5e Guido Trotter
             make_option("--no-nplus1-mem", dest="skip_nplusone_mem",
376 e54c4c5e Guido Trotter
                         help="Skip N+1 memory redundancy tests",
377 e54c4c5e Guido Trotter
                         action="store_true",
378 e54c4c5e Guido Trotter
                         default=False,),
379 e54c4c5e Guido Trotter
             ],
380 9a033156 Iustin Pop
             "", "Does a check on the cluster configuration"),
381 f4d4e184 Iustin Pop
  'verify-disks': (VerifyDisks, ARGS_NONE, [DEBUG_OPT],
382 9a033156 Iustin Pop
                   "", "Does a check on the cluster disk status"),
383 a8083063 Iustin Pop
  'masterfailover': (MasterFailover, ARGS_NONE, [DEBUG_OPT],
384 9a033156 Iustin Pop
                     "", "Makes the current node the master"),
385 a8083063 Iustin Pop
  'version': (ShowClusterVersion, ARGS_NONE, [DEBUG_OPT],
386 9a033156 Iustin Pop
              "", "Shows the cluster version"),
387 a8083063 Iustin Pop
  'getmaster': (ShowClusterMaster, ARGS_NONE, [DEBUG_OPT],
388 9a033156 Iustin Pop
                "", "Shows the cluster master"),
389 a8083063 Iustin Pop
  'copyfile': (ClusterCopyFile, ARGS_ONE, [DEBUG_OPT, node_option],
390 9a033156 Iustin Pop
               "[-n node...] <filename>",
391 a8083063 Iustin Pop
               "Copies a file to all (or only some) nodes"),
392 a8083063 Iustin Pop
  'command': (RunClusterCommand, ARGS_ATLEAST(1), [DEBUG_OPT, node_option],
393 9a033156 Iustin Pop
              "[-n node...] <command>",
394 a8083063 Iustin Pop
              "Runs a command on all (or only some) nodes"),
395 a8083063 Iustin Pop
  'info': (ShowClusterConfig, ARGS_NONE, [DEBUG_OPT],
396 9a033156 Iustin Pop
                 "", "Show cluster configuration"),
397 846baef9 Iustin Pop
  'list-tags': (ListTags, ARGS_NONE,
398 9a033156 Iustin Pop
                [DEBUG_OPT], "", "List the tags of the cluster"),
399 810c50b7 Iustin Pop
  'add-tags': (AddTags, ARGS_ANY, [DEBUG_OPT, TAG_SRC_OPT],
400 9a033156 Iustin Pop
               "tag...", "Add tags to the cluster"),
401 810c50b7 Iustin Pop
  'remove-tags': (RemoveTags, ARGS_ANY, [DEBUG_OPT, TAG_SRC_OPT],
402 9a033156 Iustin Pop
                  "tag...", "Remove tags from the cluster"),
403 73415719 Iustin Pop
  'search-tags': (SearchTags, ARGS_ONE,
404 9a033156 Iustin Pop
                  [DEBUG_OPT], "", "Searches the tags on all objects on"
405 73415719 Iustin Pop
                  " the cluster for a given pattern (regex)"),
406 90b6aa3a Manuel Franceschini
  'modify': (SetClusterParams, ARGS_NONE,
407 90b6aa3a Manuel Franceschini
             [DEBUG_OPT,
408 90b6aa3a Manuel Franceschini
              make_option("-g", "--vg-name", dest="vg_name",
409 90b6aa3a Manuel Franceschini
                          help="Specify the volume group name "
410 90b6aa3a Manuel Franceschini
                          " (cluster-wide) for disk allocation "
411 90b6aa3a Manuel Franceschini
                          "and enable lvm based storage",
412 90b6aa3a Manuel Franceschini
                          metavar="VG",),
413 90b6aa3a Manuel Franceschini
              make_option("--no-lvm-storage", dest="lvm_storage",
414 90b6aa3a Manuel Franceschini
                          help="Disable support for lvm based instances"
415 90b6aa3a Manuel Franceschini
                               " (cluster-wide)",
416 90b6aa3a Manuel Franceschini
                          action="store_false", default=True,),
417 90b6aa3a Manuel Franceschini
              ],
418 90b6aa3a Manuel Franceschini
             "[opts...]",
419 90b6aa3a Manuel Franceschini
             "Alters the parameters of the cluster"),
420 a8083063 Iustin Pop
  }
421 a8083063 Iustin Pop
422 a8083063 Iustin Pop
if __name__ == '__main__':
423 846baef9 Iustin Pop
  sys.exit(GenericMain(commands, override={"tag_type": constants.TAG_CLUSTER}))