Statistics
| Branch: | Tag: | Revision:

root / lib / utils / lvm.py @ 59726e15

History | View | Annotate | Download (1.5 kB)

1
#
2
#
3

    
4
# Copyright (C) 2006, 2007, 2010, 2011, 2012 Google Inc.
5
#
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
# General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
# 02110-1301, USA.
20

    
21
"""Utility functions for LVM.
22

23
"""
24

    
25
def CheckVolumeGroupSize(vglist, vgname, minsize):
26
  """Checks if the volume group list is valid.
27

28
  The function will check if a given volume group is in the list of
29
  volume groups and has a minimum size.
30

31
  @type vglist: dict
32
  @param vglist: dictionary of volume group names and their size
33
  @type vgname: str
34
  @param vgname: the volume group we should check
35
  @type minsize: int
36
  @param minsize: the minimum size we accept
37
  @rtype: None or str
38
  @return: None for success, otherwise the error message
39

40
  """
41
  vgsize = vglist.get(vgname, None)
42
  if vgsize is None:
43
    return "volume group '%s' missing" % vgname
44
  elif vgsize < minsize:
45
    return ("volume group '%s' too small (%s MiB required, %d MiB found)" %
46
            (vgname, minsize, vgsize))
47
  return None