Esempio n. 1
0
 def shrink_share(self, share, new_size, share_server=None):
     """Shrinks size of existing share."""
     dataset_name = self._get_dataset_name(share)
     consumed_space = self.get_zfs_option(dataset_name, 'used')
     consumed_space = utils.translate_string_size_to_float(consumed_space)
     if consumed_space >= new_size:
         raise exception.ShareShrinkingPossibleDataLoss(
             share_id=share['id'])
     self.zfs('set', 'quota=%sG' % new_size, dataset_name)
Esempio n. 2
0
 def _get_pools_info(self):
     """Returns info about all pools used by backend."""
     pools = []
     for zpool in self.zpool_list:
         free_size = self.get_zpool_option(zpool, 'free')
         free_size = utils.translate_string_size_to_float(free_size)
         total_size = self.get_zpool_option(zpool, 'size')
         total_size = utils.translate_string_size_to_float(total_size)
         pool = {
             'pool_name': zpool,
             'total_capacity_gb': float(total_size),
             'free_capacity_gb': float(free_size),
             'reserved_percentage':
                 self.configuration.reserved_share_percentage,
         }
         if self.configuration.replication_domain:
             pool['replication_type'] = 'readable'
         pools.append(pool)
     return pools
Esempio n. 3
0
    def _get_directory_usage(self, share):
        share_dir = '/' + share['name']

        args = ('--xml', 'volume', 'quota', self.gluster_manager.volume,
                'list', share_dir)

        try:
            out, err = self.gluster_manager.gluster_call(*args)
        except exception.GlusterfsException:
            LOG.error('Unable to get quota share %s', share['name'])
            raise

        volxml = etree.fromstring(out)
        usage_byte = volxml.find('./volQuota/limit/used_space').text
        usage = utils.translate_string_size_to_float(usage_byte)

        return usage
Esempio n. 4
0
 def test_translate_string_size_to_float_negative(self, string, multiplier):
     actual = utils.translate_string_size_to_float(string, multiplier)
     self.assertIsNone(actual)
Esempio n. 5
0
 def test_translate_string_size_to_float_positive(self, request, expected):
     actual = utils.translate_string_size_to_float(*request)
     self.assertEqual(expected, actual)
Esempio n. 6
0
 def test_translate_string_size_to_float_negative(self, string, multiplier):
     actual = utils.translate_string_size_to_float(string, multiplier)
     self.assertIsNone(actual)
Esempio n. 7
0
 def test_translate_string_size_to_float_positive(self, request, expected):
     actual = utils.translate_string_size_to_float(*request)
     self.assertEqual(expected, actual)