'fetch and update stats.'

@proxy._trace_time
def _update_stats(self):

    LOG.debug('Entered    XIVProxy::_update_stats:')
    self.meta['stat'] = {}
    connection_type = self._get_connection_type()
    backend_name = None
    if self.driver:
        backend_name = self.driver.configuration.safe_get('volume_backend_name')
    self.meta['stat']['volume_backend_name'] = (backend_name or ('%s_%s_%s_%s' % (strings.XIV_BACKEND_PREFIX, self.storage_info[storage.FLAG_KEYS['address']], self.storage_info[storage.FLAG_KEYS['storage_pool']], connection_type)))
    self.meta['stat']['vendor_name'] = 'IBM'
    self.meta['stat']['driver_version'] = self.full_version
    self.meta['stat']['storage_protocol'] = connection_type
    self.meta['stat']['multiattach'] = False
    self.meta['stat']['group_replication_enabled'] = True
    self.meta['stat']['consistent_group_replication_enabled'] = True
    self.meta['stat']['QoS_support'] = self._check_storage_version_for_qos_support()
    self.meta['stat']['location_info'] = ('%(destination)s:%(hostname)s:%(pool)s' % {'destination': strings.XIV_BACKEND_PREFIX, 'hostname': self.storage_info[storage.FLAG_KEYS['address']], 'pool': self.storage_info[storage.FLAG_KEYS['storage_pool']]})
    pools = self._call_xiv_xcli('pool_list', pool=self.storage_info[storage.FLAG_KEYS['storage_pool']]).as_list
    if (len(pools) != 1):
        LOG.error('_update_stats:    Pool    %(pool)s    not    available    on    storage', {'pool': self.storage_info[storage.FLAG_KEYS['storage_pool']]})
        return
    pool = pools[0]
    soft_size = pool.get('soft_size')
    if (soft_size is None):
        soft_size = pool.get('size')
        hard_size = 0
    else:
        hard_size = pool.hard_size
    self.meta['stat']['total_capacity_gb'] = int(soft_size)
    self.meta['stat']['free_capacity_gb'] = int(pool.get('empty_space_soft', pool.get('empty_space')))
    self.meta['stat']['reserved_percentage'] = self.driver.configuration.safe_get('reserved_percentage')
    self.meta['stat']['consistent_group_snapshot_enabled'] = True
    self.meta['stat']['thin_provision'] = ('True' if (soft_size > hard_size) else 'False')
    if self.targets:
        self.meta['stat']['replication_enabled'] = True
        self.meta['stat']['replication_type'] = [SYNC, ASYNC]
        self.meta['stat']['rpo'] = repl.Replication.get_supported_rpo()
        self.meta['stat']['replication_count'] = len(self.targets)
        self.meta['stat']['replication_targets'] = [target for target in six.iterkeys(self.targets)]
    self.meta['stat']['timestamp'] = datetime.datetime.utcnow()
    LOG.debug('Exiting    XIVProxy::_update_stats:    %(stat)s', {'stat': self.meta['stat']})
