Skip to content
Snippets Groups Projects
Commit 2b914b59 authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Fixed a bug in partitions test (refs #26179).

parent e7441f97
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ def read_file(fname): ...@@ -24,6 +24,7 @@ def read_file(fname):
with open(fname, 'r') as f: with open(fname, 'r') as f:
return f.read() return f.read()
paths = [ paths = [
{ {
'mount_point': '/', 'mount_point': '/',
...@@ -67,8 +68,8 @@ def get_swap_gbytes(): ...@@ -67,8 +68,8 @@ def get_swap_gbytes():
def get_path(path): def get_path(path):
# Filesystem Type 1B-blocks Used Available Use% Mounted on # Filesystem Type 1B-blocks Used Available
# /dev/loop2 ext4 52710469632 38253940736 11755397120 77% / # /dev/loop2 ext4 52710469632 38253940736 11755397120
status, output = subprocess.getstatusoutput('df --output="source,fstype,size,avail" -B 1 %s | tail -n 1' % path) status, output = subprocess.getstatusoutput('df --output="source,fstype,size,avail" -B 1 %s | tail -n 1' % path)
if status == 0: if status == 0:
dev, fstype, size, available = output.split() dev, fstype, size, available = output.split()
...@@ -79,6 +80,8 @@ def get_path(path): ...@@ -79,6 +80,8 @@ def get_path(path):
def check_allocation(dev): def check_allocation(dev):
root_dev = os.path.basename(dev)[:3] root_dev = os.path.basename(dev)[:3]
if not root_dev:
return True
d = read_file('/proc/partitions') d = read_file('/proc/partitions')
dev_partitions = list() dev_partitions = list()
for l in d.split('\n'): for l in d.split('\n'):
...@@ -101,6 +104,7 @@ def check_allocation(dev): ...@@ -101,6 +104,7 @@ def check_allocation(dev):
return False return False
return True return True
error = False error = False
warning = False warning = False
...@@ -119,7 +123,7 @@ def check_path(p): ...@@ -119,7 +123,7 @@ def check_path(p):
if fstype not in p.get('recommended_types'): if fstype not in p.get('recommended_types'):
print('Warning, partition of %s fs type not recommended %s(current: %s, recommended: %s)%s.' % (name, YELLOW, fstype, p['recommended_types'], DEF)) print('Warning, partition of %s fs type not recommended %s(current: %s, recommended: %s)%s.' % (name, YELLOW, fstype, p['recommended_types'], DEF))
warning = True warning = True
if 'nfs' not in dev: if 'nfs' not in fstype:
warning = not check_allocation(dev) warning = not check_allocation(dev)
min_available_gbytes = p.get('min_available_gbytes') min_available_gbytes = p.get('min_available_gbytes')
if min_available_gbytes and available < min_available_gbytes: if min_available_gbytes and available < min_available_gbytes:
...@@ -141,6 +145,7 @@ def check_path(p): ...@@ -141,6 +145,7 @@ def check_path(p):
print('Partition of %s is smaller than the recommended size %s(%s GB < %s GB)%s.' % (name, YELLOW, psize, p['reco_size_gbytes'], DEF)) print('Partition of %s is smaller than the recommended size %s(%s GB < %s GB)%s.' % (name, YELLOW, psize, p['reco_size_gbytes'], DEF))
warning = True warning = True
for p in paths: for p in paths:
check_path(p) check_path(p)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment