提交 78c9d753 编写于 作者: P Praveen K Pandey

Added new disk utility in avcoado lib

added disk utility
1- get_disk_blocksize -- this function return block size of given disk(path)
2- get_disks -- this function return all disk present in system
Signed-off-by: NPraveen K Pandey <praveen@linux.vnet.ibm.com>
上级 f8f5caa4
......@@ -12,15 +12,33 @@
# This code was inspired in the autotest project,
#
# client/base_utils.py
#
# Copyright: 2018 IBM
# Authors : Praveen K Pandey <praveen@linux.vnet.ibm.com>
"""
Disk utilities
"""
import os
import json
from . import process
def freespace(path):
fs_stats = os.statvfs(path)
return fs_stats.f_bsize * fs_stats.f_bavail
def get_disk_blocksize(path):
"""Return the disk block size, in bytes"""
fs_stats = os.statvfs(path)
return fs_stats.f_bsize
def get_disks():
json_result = process.run('lsblk --json')
json_data = json.loads(json_result.stdout_text)
return ['/dev/%s' % str(disk['name']) for disk in json_data['blockdevices']]
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册