|
1 From 075ff30d7d8bbeca1af634718f3cb19099bc44b3 Mon Sep 17 00:00:00 2001 |
|
2 From: Abhiram Moturi <[email protected]> |
|
3 Date: Mon, 10 Aug 2015 14:23:09 +0000 |
|
4 Subject: [PATCH] ZFSSA driver to return project 'available' space |
|
5 |
|
6 This fix allows the iSCSI driver to return the 'available' space |
|
7 property at project level instead of the pool level which is more |
|
8 accurate in cases when storage is not thin provisioned. |
|
9 |
|
10 Change-Id: I52dec5e527eab393fd464fbc7f4f910fafb67268 |
|
11 Closes-Bug: #1479342 |
|
12 --- |
|
13 --- cinder-2014.2.2/cinder/volume/drivers/zfssa/zfssarest.py.~1~ 2015-11-08 22:01:48.358042338 -0800 |
|
14 +++ cinder-2014.2.2/cinder/volume/drivers/zfssa/zfssarest.py 2015-11-08 22:02:05.691920138 -0800 |
|
15 @@ -82,7 +82,7 @@ |
|
16 'ret.status': ret.status, |
|
17 'ret.data': ret.data}) |
|
18 LOG.error(exception_msg) |
|
19 - raise exception.InvalidVolume(reason=exception_msg) |
|
20 + raise exception.VolumeBackendAPIException(data=exception_msg) |
|
21 |
|
22 val = json.loads(ret.data) |
|
23 |
|
24 @@ -95,10 +95,31 @@ |
|
25 LOG.error(exception_msg) |
|
26 raise exception.InvalidInput(reason=pool) |
|
27 |
|
28 - avail = val['pool']['usage']['available'] |
|
29 total = val['pool']['usage']['total'] |
|
30 |
|
31 - return avail, total |
|
32 + return total |
|
33 + |
|
34 + def get_project_stats(self, pool, project): |
|
35 + """Get available space of a project.""" |
|
36 + svc = '/api/storage/v1/pools/%s/projects/%s' % (pool, project) |
|
37 + ret = self.rclient.get(svc) |
|
38 + if ret.status != restclient.Status.OK: |
|
39 + exception_msg = (_('Error Getting Project Stats: ' |
|
40 + 'Pool: %(pool)s ' |
|
41 + 'Project: %(project)s ' |
|
42 + 'Return code: %(ret.status)d ' |
|
43 + 'Message: %(ret.data)s.') |
|
44 + % {'pool': pool, |
|
45 + 'project': project, |
|
46 + 'ret.status': ret.status, |
|
47 + 'ret.data': ret.data}) |
|
48 + LOG.error(exception_msg) |
|
49 + raise exception.VolumeBackendAPIException(data=exception_msg) |
|
50 + |
|
51 + val = json.loads(ret.data) |
|
52 + avail = val['project']['space_available'] |
|
53 + |
|
54 + return avail |
|
55 |
|
56 def create_project(self, pool, project, compression=None, logbias=None): |
|
57 """Create a project on a pool |