commit 075ff30d7d8bbeca1af634718f3cb19099bc44b3
Author: Abhiram Moturi <abhiram.moturi@oracle.com>
Date: Mon Aug 10 14:23:09 2015 +0000
ZFSSA driver to return project 'available' space
This fix allows the iSCSI driver to return the 'available' space
property at project level instead of the pool level which is more
accurate in cases when storage is not thin provisioned.
Change-Id: I52dec5e527eab393fd464fbc7f4f910fafb67268
Closes-Bug: #1479342
--- cinder-2015.1.2/cinder/volume/drivers/zfssa/zfssaiscsi.py.~1~ 2016-02-01 00:58:28.817737350 -0800
+++ cinder-2015.1.2/cinder/volume/drivers/zfssa/zfssaiscsi.py 2016-02-01 00:58:28.883666429 -0800
@@ -322,7 +322,8 @@ class ZFSSAISCSIDriver(driver.ISCSIDrive
data["storage_protocol"] = self.protocol
lcfg = self.configuration
- (avail, total) = self.zfssa.get_pool_stats(lcfg.zfssa_pool)
+ (avail, total) = self.zfssa.get_project_stats(lcfg.zfssa_pool,
+ lcfg.zfssa_project)
if avail is None or total is None:
return
--- cinder-2015.1.2/cinder/volume/drivers/zfssa/zfssarest.py.~1~ 2015-10-13 09:27:35.000000000 -0700
+++ cinder-2015.1.2/cinder/volume/drivers/zfssa/zfssarest.py 2016-02-01 00:59:32.842959922 -0800
@@ -69,36 +69,30 @@ class ZFSSAApi(object):
if self.rclient and not self.rclient.islogin():
self.rclient.login(auth_str)
- def get_pool_stats(self, pool):
- """Get space available and total properties of a pool
+ def get_project_stats(self, pool, project):
+ """Get project stats.
+
+ Get available space and total space of a project
returns (avail, total).
"""
- svc = '/api/storage/v1/pools/' + pool
+ svc = '/api/storage/v1/pools/%s/projects/%s' % (pool, project)
ret = self.rclient.get(svc)
if ret.status != restclient.Status.OK:
- exception_msg = (_('Error Getting Pool Stats: '
+ exception_msg = (_('Error Getting Project Stats: '
'Pool: %(pool)s '
+ 'Project: %(project)s '
'Return code: %(ret.status)d '
'Message: %(ret.data)s.')
% {'pool': pool,
+ 'project': project,
'ret.status': ret.status,
'ret.data': ret.data})
LOG.error(exception_msg)
- raise exception.InvalidVolume(reason=exception_msg)
+ raise exception.VolumeBackendAPIException(data=exception_msg)
val = json.loads(ret.data)
-
- if not self._is_pool_owned(val):
- exception_msg = (_('Error Pool ownership: '
- 'Pool %(pool)s is not owned '
- 'by %(host)s.')
- % {'pool': pool,
- 'host': self.host})
- LOG.error(exception_msg)
- raise exception.InvalidInput(reason=pool)
-
- avail = val['pool']['usage']['available']
- total = val['pool']['usage']['total']
+ avail = val['project']['space_available']
+ total = avail + val['project']['space_total']
return avail, total