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:
Brian Coca 2013-01-01 23:52:27 -05:00 committed by Michael DeHaan
parent 171a01deac
commit 0e8627b7e8
2 changed files with 142 additions and 4 deletions

View file

@ -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 ===
"""