Statistics
| Branch: | Tag: | Revision:

root / scripts / gnt-cluster @ 7688d0d3

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