def test_update_share_stats(self, connection): stat_dict = copy.deepcopy(res_mock.STATS) connection.update_share_stats(stat_dict) self.assertEqual(5, len(stat_dict)) pool = stat_dict['pools'][0] self.assertEqual('pool_1', pool['pool_name']) self.assertEqual(enas_utils.bytes_to_gb(500000.0), pool['total_capacity_gb']) self.assertEqual(False, pool['qos']) self.assertEqual(enas_utils.bytes_to_gb(30000.0), pool['provisioned_capacity_gb']) self.assertEqual(20, pool['max_over_subscription_ratio']) self.assertEqual(enas_utils.bytes_to_gb(10000.0), pool['allocated_capacity_gb']) self.assertEqual(0, pool['reserved_percentage']) self.assertTrue(pool['thin_provisioning']) self.assertEqual(enas_utils.bytes_to_gb(490000.0), pool['free_capacity_gb'])
def update_share_stats(self, stats_dict): """Communicate with EMCNASClient to get the stats.""" stats_dict['driver_version'] = VERSION stats_dict['pools'] = [] for pool in self.client.get_pool(): if pool.name in self.pool_set: # the unit of following numbers are GB total_size = float(pool.size_total) used_size = float(pool.size_used) pool_stat = { 'pool_name': pool.name, 'thin_provisioning': True, 'total_capacity_gb': enas_utils.bytes_to_gb(total_size), 'free_capacity_gb': enas_utils.bytes_to_gb(total_size - used_size), 'allocated_capacity_gb': enas_utils.bytes_to_gb(used_size), 'provisioned_capacity_gb': enas_utils.bytes_to_gb(pool.size_subscribed), 'qos': False, 'reserved_percentage': self.reserved_percentage, 'reserved_snapshot_percentage': self.reserved_snapshot_percentage, 'max_over_subscription_ratio': self.max_over_subscription_ratio, } stats_dict['pools'].append(pool_stat) if not stats_dict.get('pools'): message = _("Failed to update storage pool.") LOG.error(message) raise exception.EMCUnityError(err=message)
def test_bytes_to_gb(self, size_in_bytes, size_in_gb): self.assertEqual(size_in_gb, utils.bytes_to_gb(size_in_bytes))