def _info(self): """ Fetches the info (see Volume Driver API) for the vDisk. """ if self.volume_id and self.vpool: try: vdiskinfo = self.storagedriver_client.info_volume( str(self.volume_id)) except: vdiskinfo = StorageDriverClient.EMPTY_INFO() else: vdiskinfo = StorageDriverClient.EMPTY_INFO() vdiskinfodict = {} for key, value in vdiskinfo.__class__.__dict__.items(): if type(value) is property: objectvalue = getattr(vdiskinfo, key) if key == 'object_type': vdiskinfodict[key] = str(objectvalue) elif key == 'metadata_backend_config': vdiskinfodict[key] = {} if hasattr(objectvalue, 'node_configs') and callable( objectvalue.node_configs): vdiskinfodict[key] = [] for nodeconfig in objectvalue.node_configs(): vdiskinfodict[key].append({ 'ip': nodeconfig.address(), 'port': nodeconfig.port() }) else: vdiskinfodict[key] = objectvalue return vdiskinfodict
def _info(self): """ Fetches the info (see Volume Driver API) for the vDisk. """ vdiskinfo = StorageDriverClient.EMPTY_INFO() vdisk_state = VDisk.STATUSES.RUNNING if self.volume_id and self.vpool: try: try: vdiskinfo = self.storagedriver_client.info_volume( str(self.volume_id), req_timeout_secs=2) except VolumeRestartInProgressException: time.sleep(0.5) vdiskinfo = self.storagedriver_client.info_volume( str(self.volume_id), req_timeout_secs=2) except MaxRedirectsExceededException: vdisk_state = VDisk.STATUSES.NON_RUNNING # @todo replace RuntimeError with NodeNotReachableException except (ClusterNotReachableException, RuntimeError) as exception: if isinstance(exception, ClusterNotReachableException) or ( isinstance(exception, RuntimeError) and 'failed to send XMLRPC request' in str(exception)): self._logger.debug( 'VDisk {0} status has been set to UNKNOWN'.format( self.name)) vdisk_state = VDisk.STATUSES.UNKNOWN except Exception as ex: self._logger.debug( 'Uncaught exception occurred when requesting the volume info for vDisk {0}: {1}' .format(self.name, ex)) vdiskinfodict = {} for key, value in vdiskinfo.__class__.__dict__.items(): if type(value) is property: objectvalue = getattr(vdiskinfo, key) if key == 'object_type': vdiskinfodict[key] = str(objectvalue) elif key == 'metadata_backend_config': vdiskinfodict[key] = {} if hasattr(objectvalue, 'node_configs') and callable( objectvalue.node_configs): vdiskinfodict[key] = [] for nodeconfig in objectvalue.node_configs(): vdiskinfodict[key].append({ 'ip': nodeconfig.address(), 'port': nodeconfig.port() }) elif key == 'halted' and objectvalue is True: self._logger.debug( 'VDisk {0} status has been set to HALTED'.format( self.name)) vdisk_state = VDisk.STATUSES.HALTED else: vdiskinfodict[key] = objectvalue vdiskinfodict['live_status'] = vdisk_state return vdiskinfodict
def fetch_statistics(self): """ Loads statistics from this vDisk - returns unprocessed data """ # Load data from volumedriver if self.volume_id and self.vpool: try: vdiskstats = self.storagedriver_client.statistics_volume(str(self.volume_id)) vdiskinfo = self.storagedriver_client.info_volume(str(self.volume_id)) except: vdiskstats = StorageDriverClient.EMPTY_STATISTICS() vdiskinfo = StorageDriverClient.EMPTY_INFO() else: vdiskstats = StorageDriverClient.EMPTY_STATISTICS() vdiskinfo = StorageDriverClient.EMPTY_INFO() # Load volumedriver data in dictionary vdiskstatsdict = {} try: pc = vdiskstats.performance_counters vdiskstatsdict['backend_data_read'] = pc.backend_read_request_size.sum() vdiskstatsdict['backend_data_written'] = pc.backend_write_request_size.sum() vdiskstatsdict['backend_read_operations'] = pc.backend_read_request_size.events() vdiskstatsdict['backend_write_operations'] = pc.backend_write_request_size.events() vdiskstatsdict['data_read'] = pc.read_request_size.sum() vdiskstatsdict['data_written'] = pc.write_request_size.sum() vdiskstatsdict['read_operations'] = pc.read_request_size.events() vdiskstatsdict['write_operations'] = pc.write_request_size.events() for key in ['cluster_cache_hits', 'cluster_cache_misses', 'metadata_store_hits', 'metadata_store_misses', 'sco_cache_hits', 'sco_cache_misses']: vdiskstatsdict[key] = getattr(vdiskstats, key) # Do some more manual calculations block_size = vdiskinfo.lba_size * vdiskinfo.cluster_multiplier if block_size == 0: block_size = 4096 vdiskstatsdict['4k_read_operations'] = vdiskstatsdict['data_read'] / block_size vdiskstatsdict['4k_write_operations'] = vdiskstatsdict['data_written'] / block_size # Pre-calculate sums for key, items in StorageDriverClient.STAT_SUMS.iteritems(): vdiskstatsdict[key] = 0 for item in items: vdiskstatsdict[key] += vdiskstatsdict[item] except: pass return vdiskstatsdict
def _info(self): """ Fetches the info (see Volume Driver API) for the vDisk. """ vdiskinfo = StorageDriverClient.EMPTY_INFO() max_redirects = False if self.volume_id and self.vpool: try: try: vdiskinfo = self.storagedriver_client.info_volume( str(self.volume_id), req_timeout_secs=2) except VolumeRestartInProgressException: time.sleep(0.5) vdiskinfo = self.storagedriver_client.info_volume( str(self.volume_id), req_timeout_secs=2) except MaxRedirectsExceededException: max_redirects = True except: pass vdiskinfodict = {} for key, value in vdiskinfo.__class__.__dict__.items(): if type(value) is property: objectvalue = getattr(vdiskinfo, key) if key == 'object_type': vdiskinfodict[key] = str(objectvalue) elif key == 'metadata_backend_config': vdiskinfodict[key] = {} if hasattr(objectvalue, 'node_configs') and callable( objectvalue.node_configs): vdiskinfodict[key] = [] for nodeconfig in objectvalue.node_configs(): vdiskinfodict[key].append({ 'ip': nodeconfig.address(), 'port': nodeconfig.port() }) else: vdiskinfodict[key] = objectvalue vdiskinfodict[ 'live_status'] = 'NON-RUNNING' if max_redirects is True else ( 'RUNNING' if vdiskinfodict['halted'] is False else 'HALTED') return vdiskinfodict