Revision d1687c6f

b/tools/lvmstrap
47 47
from ganeti.utils import RunCmd
48 48
from ganeti import constants
49 49

  
50
USAGE = ("\tlvmstrap.py diskinfo\n"
51
         "\tlvmstrap.py [--vgname=NAME] { --alldisks | --disks DISKLIST }"
50
USAGE = ("\tlvmstrap diskinfo\n"
51
         "\tlvmstrap [--vgname=NAME] [--allow-removable]"
52
         " { --alldisks | --disks DISKLIST }"
52 53
         " create")
53 54

  
54 55
verbose_flag = False
......
143 144
  parser.add_option("-v", "--verbose",
144 145
                    action="store_true", dest="verbose", default=False,
145 146
                    help="print command execution messages to stdout")
147
  parser.add_option("-r", "--allow-removable",
148
                    action="store_true", dest="removable_ok", default=False,
149
                    help="allow and use removable devices too")
146 150
  parser.add_option("-g", "--vg-name", type="string",
147 151
                    dest="vgname", default="xenvg", metavar="NAME",
148 152
                    help="the volume group to be created [default: xenvg]")
......
353 357
  return vgname
354 358

  
355 359

  
356
def GetDiskList():
360
def GetDiskList(opts):
357 361
  """Computes the block device list for this system.
358 362

  
359 363
  This function examines the /sys/block tree and using information
......
386 390
    removable = int(f.read().strip())
387 391
    f.close()
388 392

  
389
    if removable:
393
    if removable and not opts.removable_ok:
390 394
      continue
391 395

  
392 396
    dev = ReadDev("/sys/block/%s" % name)
......
471 475
  return mpath, whatvg, fileinfo
472 476

  
473 477

  
474
def ShowDiskInfo():
478
def ShowDiskInfo(opts):
475 479
  """Shows a nicely formatted block device list for this system.
476 480

  
477 481
  This function shows the user a table with the informations gathered
......
480 484

  
481 485
  """
482 486
  mounts = GetMountInfo()
483
  dlist = GetDiskList()
487
  dlist = GetDiskList(opts)
484 488

  
485 489
  print "------- Disk information -------"
486 490
  print ("%5s %7s %4s %5s %-10s %s" %
......
650 654
    a list of disk names, e.g. ['sda', 'sdb']
651 655
  """
652 656

  
653
  sysdisks = GetDiskList()
657
  sysdisks = GetDiskList(options)
654 658
  if not sysdisks:
655 659
    raise PrereqError("no disks found (I looked for"
656 660
                      " non-removable block devices).")
......
689 693
  vgname = options.vgname
690 694
  command = args.pop(0)
691 695
  if command == "diskinfo":
692
    ShowDiskInfo()
696
    ShowDiskInfo(options)
693 697
    return
694 698
  if command != "create":
695 699
    Usage()

Also available in: Unified diff