from ganeti.utils import RunCmd
from ganeti import constants
-USAGE = ("\tlvmstrap.py diskinfo\n"
- "\tlvmstrap.py [--vgname=NAME] { --alldisks | --disks DISKLIST }"
+USAGE = ("\tlvmstrap diskinfo\n"
+ "\tlvmstrap [--vgname=NAME] [--allow-removable]"
+ " { --alldisks | --disks DISKLIST }"
" create")
verbose_flag = False
parser.add_option("-v", "--verbose",
action="store_true", dest="verbose", default=False,
help="print command execution messages to stdout")
+ parser.add_option("-r", "--allow-removable",
+ action="store_true", dest="removable_ok", default=False,
+ help="allow and use removable devices too")
parser.add_option("-g", "--vg-name", type="string",
dest="vgname", default="xenvg", metavar="NAME",
help="the volume group to be created [default: xenvg]")
return vgname
-def GetDiskList():
+def GetDiskList(opts):
"""Computes the block device list for this system.
This function examines the /sys/block tree and using information
removable = int(f.read().strip())
f.close()
- if removable:
+ if removable and not opts.removable_ok:
continue
dev = ReadDev("/sys/block/%s" % name)
return mpath, whatvg, fileinfo
-def ShowDiskInfo():
+def ShowDiskInfo(opts):
"""Shows a nicely formatted block device list for this system.
This function shows the user a table with the informations gathered
"""
mounts = GetMountInfo()
- dlist = GetDiskList()
+ dlist = GetDiskList(opts)
print "------- Disk information -------"
print ("%5s %7s %4s %5s %-10s %s" %
a list of disk names, e.g. ['sda', 'sdb']
"""
- sysdisks = GetDiskList()
+ sysdisks = GetDiskList(options)
if not sysdisks:
raise PrereqError("no disks found (I looked for"
" non-removable block devices).")
vgname = options.vgname
command = args.pop(0)
if command == "diskinfo":
- ShowDiskInfo()
+ ShowDiskInfo(options)
return
if command != "create":
Usage()