storage: make Pool.{size,usage} integers

And return None (instead of raising KeyError) when pool driver
does not provide such information.
This commit is contained in:
Marek Marczykowski-Górecki 2018-03-18 23:10:48 +01:00
parent 034e9b3a24
commit 4638a019e5
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -286,12 +286,20 @@ class Pool(object):
@property
def size(self):
''' Storage pool size, in bytes'''
return self.config['size']
try:
return int(self.config['size'])
except KeyError:
# pool driver does not provide size information
return None
@property
def usage(self):
''' Space used in the pool, in bytes '''
return self.config['usage']
try:
return int(self.config['usage'])
except KeyError:
# pool driver does not provide usage information
return None
@property
def driver(self):