components/openstack/cinder/patches/10-zfssa-free-space.patch
author saurabh.vyas@oracle.com
Tue, 26 Jan 2016 11:13:13 -0800
changeset 5340 d02afa922d41
permissions -rw-r--r--
21241934 ZFSSA driver should return free (vs available) space 22158523 Can't boot zone as iscsi lun has changed

From 075ff30d7d8bbeca1af634718f3cb19099bc44b3 Mon Sep 17 00:00:00 2001
From: Abhiram Moturi <[email protected]>
Date: Mon, 10 Aug 2015 14:23:09 +0000
Subject: [PATCH] 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-2014.2.2/cinder/volume/drivers/zfssa/zfssarest.py.~1~	2015-11-08 22:01:48.358042338 -0800
+++ cinder-2014.2.2/cinder/volume/drivers/zfssa/zfssarest.py	2015-11-08 22:02:05.691920138 -0800
@@ -82,7 +82,7 @@
                                 '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)
 
@@ -95,10 +95,31 @@
             LOG.error(exception_msg)
             raise exception.InvalidInput(reason=pool)
 
-        avail = val['pool']['usage']['available']
         total = val['pool']['usage']['total']
 
-        return avail, total
+        return total
+
+    def get_project_stats(self, pool, project):
+        """Get available space of a project."""
+        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 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.VolumeBackendAPIException(data=exception_msg)
+ 
+        val = json.loads(ret.data)
+        avail = val['project']['space_available']
+ 
+        return avail
 
     def create_project(self, pool, project, compression=None, logbias=None):
         """Create a project on a pool