Trees | Indices | Help |
|
---|
|
Program which configures LVM on the Ganeti nodes.
This program wipes disks and creates a volume group on top of them. It can also show disk information to help you decide which disks you want to wipe.
The error handling is done by raising our own exceptions from most of the functions; these exceptions then handled globally in the main() function. The exceptions that each function can raise are not documented individually, since almost every error path ends in a raise.
Another two exceptions that are handled globally are IOError and OSError. The idea behind this is, since we run as root, we should usually not get these errors, but if we do it's most probably a system error, so they should be handled and the user instructed to report them.
|
|||
Error Generic exception |
|||
ProgrammingError Exception denoting invalid assumptions in programming. |
|||
SysconfigError Exception denoting invalid system configuration. |
|||
PrereqError Exception denoting invalid prerequisites. |
|||
OperationalError Exception denoting actual errors. |
|||
ParameterError Exception denoting invalid input from user. |
|
|||
|
|||
tuple |
|
||
|
|||
|
|||
|
|||
tuple |
|
||
|
|||
|
|||
|
|||
|
|||
int |
|
||
|
|||
|
|||
dict |
|
||
|
|||
|
|||
|
|||
boolean |
|
||
boolean |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
USAGE = "\tlvmstrap diskinfo\n" "\tlvmstrap [--vg-name=NAME] [
|
|||
verbose_flag = False
|
|||
SUPPORTED_TYPES = ["hd", "sd", "md", "ubd",] Supported disk types (as prefixes) |
|||
EXCLUDED_FS = compat.UniqueFrozenset(["nfs", "nfs4", "autofs", Excluded filesystem types |
|||
PART_RE = re.compile("^((?:h|s|m|ub)d[a-z]{1,2})[0-9]+$") A regular expression that matches partitions (must be kept in sync |
|||
PART_MINSIZE = 1024* 1024* 1024 Minimum partition size to be considered (1 GB) |
|||
MBR_MAX_SIZE = 2*(10** 12)
|
Imports: os, sys, optparse, time, errno, re, RunCmd, ReadFile, constants, cli, compat
|
Parses the command line options. In case of command line errors, it will show the usage and exit the program.
|
Returns whether a given disk should be used partitioned or as-is. Currently only md devices are used as is. |
Returns the appropriate device name for a disk. For non-partitioned devices, it returns the name as is, otherwise it returns the first partition. |
Executes a command. This is just a wrapper around commands.getstatusoutput, with the difference that if the command line argument -v has been given, it will print the command line and the command output on stdout.
|
Check the prerequisites of this program. It check that it runs on Linux 2.6, and that /sys is mounted and the fact that /sys/block is a directory. |
Checks to see if a volume group exists.
|
Checks consistency between /sys and /dev trees. In /sys/block/<name>/dev and /sys/block/<name>/<part>/dev are the kernel-known device numbers. The /dev/<name> block/char devices are created by userspace and thus could differ from the kernel view. This function checks the consistency between the device number read from /sys and the actual device number in /dev. Note that since the system could be using udev which removes and recreates the device nodes on partition table rescan, we need to do some retries here. Since we only do a stat, we can afford to do many short retries.
|
Reads the device number from a sysfs path. The device number is given in sysfs under a block device directory in a file named 'dev' which contains major:minor (in ASCII). This function reads that file and converts the major:minor pair to a dev number.
|
Reads the size from a sysfs path. The size is given in sysfs under a block device directory in a file named 'size' which contains the number of sectors (in ASCII). This function reads that file and converts the number in sectors to the size in bytes.
|
Reads physical volume information. This function tries to see if a block device is a physical volume.
|
Computes the block device list for this system. This function examines the /sys/block tree and using information therein, computes the status of the block device.
|
Reads /proc/mounts and computes the mountpoint-devnum mapping. This function reads /proc/mounts, finds the mounted filesystems (excepting a hard-coded blacklist of network and virtual filesystems) and does a stat on these mountpoints. The st_dev number of the results is memorised for later matching against the /sys/block devices.
|
Computes miscellaneous information about a block device.
|
Shows a nicely formatted block device list for this system. This function shows the user a table with the information gathered by the other functions defined, in order to help the user make a choice about which disks should be allocated to our volume group. |
Check to see if a device is 'hold' at sysfs level. This is usually the case for Physical Volumes under LVM.
|
Check to see if a block device is in use. Uses blockdev to reread the partition table of a block device (or fuser if the device is not partitionable), and thus compute the in-use status. See the discussion in GetDiskList about the meaning of 'in use'.
|
Check to see if a block device is a mountpoint. In recent distros/kernels, this is reported directly via fuser, but on older ones not, so we do an additional check here (manually). |
Wipes a block device. This function wipes a block device, by clearing and re-reading the partition table. If not successful, it writes back the old partition data, and leaves the cleanup to the user.
|
Partitions a disk. This function creates a single partition spanning the entire disk, by means of fdisk.
|
Creates a physical volume on a block device. This function creates a physical volume on a block device, overriding all warnings. So it can wipe existing PVs and PVs which are in a VG.
|
Creates the volume group. This function creates a volume group named `vgname` on the disks given as parameters. The physical extent size is set to 64MB.
|
Validates or computes the disk list for create. This function either computes the available disk list (if the user gave --alldisks option), or validates the user-given disk list (by using the --disks option) such that all given disks are present and not in use.
|
Application entry point. This is just a wrapper over BootStrap, to handle our own exceptions. |
|
USAGE
|
EXCLUDED_FSExcluded filesystem types
|
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Apr 4 13:43:46 2016 | http://epydoc.sourceforge.net |