Revision 63c73073 lib/utils/lvm.py
b/lib/utils/lvm.py | ||
---|---|---|
22 | 22 |
|
23 | 23 |
""" |
24 | 24 |
|
25 |
from ganeti import constants |
|
26 |
|
|
27 |
|
|
25 | 28 |
def CheckVolumeGroupSize(vglist, vgname, minsize): |
26 | 29 |
"""Checks if the volume group list is valid. |
27 | 30 |
|
... | ... | |
45 | 48 |
return ("volume group '%s' too small (%s MiB required, %d MiB found)" % |
46 | 49 |
(vgname, minsize, vgsize)) |
47 | 50 |
return None |
51 |
|
|
52 |
|
|
53 |
def LvmExclusiveCheckNodePvs(pvs_info): |
|
54 |
"""Check consistency of PV sizes in a node for exclusive storage. |
|
55 |
|
|
56 |
@type pvs_info: list |
|
57 |
@param pvs_info: list of L{LvmPvInfo} objects |
|
58 |
@rtype: list |
|
59 |
@return: A list of error strings described the violation found, or an empty |
|
60 |
list if everything is ok |
|
61 |
""" |
|
62 |
errmsgs = [] |
|
63 |
sizes = [pv.size for pv in pvs_info] |
|
64 |
# The sizes of PVs must be the same (tolerance is constants.PART_MARGIN) |
|
65 |
small = min(sizes) |
|
66 |
big = max(sizes) |
|
67 |
if LvmExclusiveTestBadPvSizes(small, big): |
|
68 |
m = ("Sizes of PVs are too different: min=%d max=%d" % (small, big)) |
|
69 |
errmsgs.append(m) |
|
70 |
return errmsgs |
|
71 |
|
|
72 |
|
|
73 |
def LvmExclusiveTestBadPvSizes(small, big): |
|
74 |
"""Test if the given PV sizes are permitted with exclusive storage. |
|
75 |
|
|
76 |
@param small: size of the smallest PV |
|
77 |
@param big: size of the biggest PV |
|
78 |
@return: True when the given sizes are bad, False otherwise |
|
79 |
""" |
|
80 |
# Test whether no X exists such that: |
|
81 |
# small >= X * (1 - constants.PART_MARGIN) and |
|
82 |
# big <= X * (1 + constants.PART_MARGIN) |
|
83 |
return (small * (1 + constants.PART_MARGIN) < |
|
84 |
big * (1 - constants.PART_MARGIN)) |
Also available in: Unified diff