Revision 90b6aa3a

b/scripts/gnt-cluster
38 38
    args - list of arguments, expected to be [clustername]
39 39

  
40 40
  """
41
  if not opts.lvm_storage and opts.vg_name:
42
    print ("Options --no-lvm-storage and --vg-name conflict.")
43
    return 1
44

  
45
  vg_name = opts.vg_name
46
  if opts.lvm_storage and not opts.vg_name:
47
    vg_name = constants.DEFAULT_VG
48

  
41 49
  op = opcodes.OpInitCluster(cluster_name=args[0],
42 50
                             secondary_ip=opts.secondary_ip,
43 51
                             hypervisor_type=opts.hypervisor_type,
44
                             vg_name=opts.vg_name,
52
                             vg_name=vg_name,
45 53
                             mac_prefix=opts.mac_prefix,
46 54
                             def_bridge=opts.def_bridge,
47 55
                             master_netdev=opts.master_netdev,
......
272 280
    print "%s %s" % (path, tag)
273 281

  
274 282

  
283
def SetClusterParams(opts, args):
284
  """Modify the cluster.
285

  
286
  Args:
287
    opts - class with options as members
288

  
289
  """
290
  if not (not opts.lvm_storage or opts.vg_name):
291
    print "Please give at least one of the parameters."
292
    return 1
293

  
294
  vg_name = opts.vg_name
295
  if not opts.lvm_storage and opts.vg_name:
296
    print ("Options --no-lvm-storage and --vg-name conflict.")
297
    return 1
298

  
299
  op = opcodes.OpSetClusterParams(vg_name=opts.vg_name)
300
  SubmitOpCode(op)
301
  return 0
302

  
303

  
275 304
# this is an option common to more than one command, so we declare
276 305
# it here and reuse it
277 306
node_option = make_option("-n", "--node", action="append", dest="nodes",
......
303 332
                        help="Specify the volume group name "
304 333
                        " (cluster-wide) for disk allocation [xenvg]",
305 334
                        metavar="VG",
306
                        default="xenvg",),
335
                        default=None,),
307 336
            make_option("-b", "--bridge", dest="def_bridge",
308 337
                        help="Specify the default bridge name (cluster-wide)"
309 338
                          " to connect the instances to [%s]" %
......
322 351
                             constants.DEFAULT_FILE_STORAGE_DIR,
323 352
                        metavar="DIR",
324 353
                        default=constants.DEFAULT_FILE_STORAGE_DIR,),
354
            make_option("--no-lvm-storage", dest="lvm_storage",
355
                        help="No support for lvm based instances"
356
                             " (cluster-wide)",
357
                        action="store_false", default=True,),
325 358
            ],
326 359
           "[opts...] <cluster_name>",
327 360
           "Initialises a new cluster configuration"),
......
362 395
  'search-tags': (SearchTags, ARGS_ONE,
363 396
                  [DEBUG_OPT], "", "Searches the tags on all objects on"
364 397
                  " the cluster for a given pattern (regex)"),
398
  'modify': (SetClusterParams, ARGS_NONE,
399
             [DEBUG_OPT,
400
              make_option("-g", "--vg-name", dest="vg_name",
401
                          help="Specify the volume group name "
402
                          " (cluster-wide) for disk allocation "
403
                          "and enable lvm based storage",
404
                          metavar="VG",),
405
              make_option("--no-lvm-storage", dest="lvm_storage",
406
                          help="Disable support for lvm based instances"
407
                               " (cluster-wide)",
408
                          action="store_false", default=True,),
409
              ],
410
             "[opts...]",
411
             "Alters the parameters of the cluster"),
365 412
  }
366 413

  
367 414
if __name__ == '__main__':

Also available in: Unified diff