components/openstack/cinder/patches/05-launchpad-1479342.patch
changeset 5405 66fd59fecd68
equal deleted inserted replaced
5404:55e409ba4e72 5405:66fd59fecd68
       
     1 commit 075ff30d7d8bbeca1af634718f3cb19099bc44b3
       
     2 Author: Abhiram Moturi <[email protected]>
       
     3 Date:   Mon Aug 10 14:23:09 2015 +0000
       
     4 
       
     5     ZFSSA driver to return project 'available' space
       
     6     
       
     7     This fix allows the iSCSI driver to return the 'available' space
       
     8     property at project level instead of the pool level which is more
       
     9     accurate in cases when storage is not thin provisioned.
       
    10     
       
    11     Change-Id: I52dec5e527eab393fd464fbc7f4f910fafb67268
       
    12     Closes-Bug: #1479342
       
    13 
       
    14 --- cinder-2015.1.2/cinder/volume/drivers/zfssa/zfssaiscsi.py.~1~	2016-02-01 00:58:28.817737350 -0800
       
    15 +++ cinder-2015.1.2/cinder/volume/drivers/zfssa/zfssaiscsi.py	2016-02-01 00:58:28.883666429 -0800
       
    16 @@ -322,7 +322,8 @@ class ZFSSAISCSIDriver(driver.ISCSIDrive
       
    17          data["storage_protocol"] = self.protocol
       
    18  
       
    19          lcfg = self.configuration
       
    20 -        (avail, total) = self.zfssa.get_pool_stats(lcfg.zfssa_pool)
       
    21 +        (avail, total) = self.zfssa.get_project_stats(lcfg.zfssa_pool,
       
    22 +                                                      lcfg.zfssa_project)
       
    23          if avail is None or total is None:
       
    24              return
       
    25  
       
    26 --- cinder-2015.1.2/cinder/volume/drivers/zfssa/zfssarest.py.~1~	2015-10-13 09:27:35.000000000 -0700
       
    27 +++ cinder-2015.1.2/cinder/volume/drivers/zfssa/zfssarest.py	2016-02-01 00:59:32.842959922 -0800
       
    28 @@ -69,36 +69,30 @@ class ZFSSAApi(object):
       
    29          if self.rclient and not self.rclient.islogin():
       
    30              self.rclient.login(auth_str)
       
    31  
       
    32 -    def get_pool_stats(self, pool):
       
    33 -        """Get space available and total properties of a pool
       
    34 +    def get_project_stats(self, pool, project):
       
    35 +        """Get project stats.
       
    36 +
       
    37 +           Get available space and total space of a project
       
    38             returns (avail, total).
       
    39          """
       
    40 -        svc = '/api/storage/v1/pools/' + pool
       
    41 +        svc = '/api/storage/v1/pools/%s/projects/%s' % (pool, project)
       
    42          ret = self.rclient.get(svc)
       
    43          if ret.status != restclient.Status.OK:
       
    44 -            exception_msg = (_('Error Getting Pool Stats: '
       
    45 +            exception_msg = (_('Error Getting Project Stats: '
       
    46                                 'Pool: %(pool)s '
       
    47 +                               'Project: %(project)s '
       
    48                                 'Return code: %(ret.status)d '
       
    49                                 'Message: %(ret.data)s.')
       
    50                               % {'pool': pool,
       
    51 +                                'project': project,
       
    52                                  'ret.status': ret.status,
       
    53                                  'ret.data': ret.data})
       
    54              LOG.error(exception_msg)
       
    55 -            raise exception.InvalidVolume(reason=exception_msg)
       
    56 +            raise exception.VolumeBackendAPIException(data=exception_msg)
       
    57  
       
    58          val = json.loads(ret.data)
       
    59 -
       
    60 -        if not self._is_pool_owned(val):
       
    61 -            exception_msg = (_('Error Pool ownership: '
       
    62 -                               'Pool %(pool)s is not owned '
       
    63 -                               'by %(host)s.')
       
    64 -                             % {'pool': pool,
       
    65 -                                'host': self.host})
       
    66 -            LOG.error(exception_msg)
       
    67 -            raise exception.InvalidInput(reason=pool)
       
    68 -
       
    69 -        avail = val['pool']['usage']['available']
       
    70 -        total = val['pool']['usage']['total']
       
    71 +        avail = val['project']['space_available']
       
    72 +        total = avail + val['project']['space_total']
       
    73  
       
    74          return avail, total
       
    75