mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 12:21:26 -07:00
added block device info gathering, full for linux, partial for freebsd added prettyfing byte function Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
moved moutns out of devices Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
This commit is contained in:
parent
171a01deac
commit
0e8627b7e8
2 changed files with 142 additions and 4 deletions
|
@ -740,6 +740,22 @@ class AnsibleModule(object):
|
|||
self.fail_json(cmd=args, rc=rc, stdout=out, stderr=err, msg=msg)
|
||||
return (rc, out, err)
|
||||
|
||||
def pretty_bytes(self,size):
|
||||
ranges = (
|
||||
(1<<50L, 'ZB'),
|
||||
(1<<50L, 'EB'),
|
||||
(1<<50L, 'PB'),
|
||||
(1<<40L, 'TB'),
|
||||
(1<<30L, 'GB'),
|
||||
(1<<20L, 'MB'),
|
||||
(1<<10L, 'KB'),
|
||||
(1, 'Bytes')
|
||||
)
|
||||
for limit, suffix in ranges:
|
||||
if size >= limit:
|
||||
break
|
||||
return '%.2f %s' % (float(size)/ limit, suffix)
|
||||
|
||||
# == END DYNAMICALLY INSERTED CODE ===
|
||||
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue