4 # -------------------------- check required progs/files---------------------
5 def check_requirements(reqprogs, reqfiles): # we need these programs/files
7 (status, output) = commands.getstatusoutput('which %s' % arg)
8 if status != 0 or len(output)==0:
9 return (-1, 'error: command %s not found' % arg)
11 if not os.path.isfile(arg) and not os.path.isdir(arg):
12 return (-1, 'error: %s not found' % arg)
15 def check_linux26(): # we need linux-2.6
16 (status, output) = commands.getstatusoutput('uname -r')
18 print 'Cannot check the linux version running'
20 if output[0:3] != '2.6':
21 print 'This support only linux-2.6 or newer'
25 def check_lvmprogs(): # we need the lvm tools version 2
26 lvmvers=mod_lvm.get_lvm_version()
27 if lvmvers[0:2]=='2.':
30 return (-1, 'Cannot find lvm-tools version 2 (type "lvm version" for details)')
32 def check_lvm_status(status): # check the lvm status is as said in argument
33 for lv in mod_lvm.list_lv():
34 if mod_lvm.get_lv_status(lv).lower()!=status:
35 return -1 # wrong status