Fix div by zero in blockdev available check

Some blockdevices make report a size of zero; don't
explode when calculating percent free.

Signed-off-by: Ryan Harper <ryan.harper@canonical.com>
This commit is contained in:
Ryan Harper 2015-10-26 10:37:01 -05:00
parent e442350213
commit 0b3170bae8
1 changed files with 3 additions and 0 deletions

View File

@ -242,6 +242,9 @@ class Blockdev():
@property
def percent_free(self):
''' return the device free percentage of the whole device'''
if self.size == 0:
return 0
percent = (int((1.0 - (self.usedspace / self.size)) * 100))
return percent