Francesco Romani has uploaded a new change for review. Change subject: virt: stats: return empty dict when stats disabled ......................................................................
virt: stats: return empty dict when stats disabled Return empty statistics dict when disk sampling is disabled. This for greater consistency, for consistency with the network sampling code and to save a TypeError on the caller. Change-Id: I749c1d502f96c8c8064f36c0c5edf0798e748dd9 Signed-off-by: Francesco Romani <[email protected]> --- M vdsm/virt/vm.py 1 file changed, 9 insertions(+), 13 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/90/26790/1 diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index 38d524b..d8112ad 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -227,28 +227,24 @@ return cpuStats[0] def _sampleDisk(self): - if not self._vm.isDisksStatsCollectionEnabled(): - # Avoid queries from storage during recovery process - return - diskSamples = {} - for vmDrive in self._vm._devices[DISK_DEVICES]: - diskSamples[vmDrive.name] = self._vm._dom.blockStats(vmDrive.name) - + # Avoid queries from storage during recovery process + if self._vm.isDisksStatsCollectionEnabled(): + for vmDrive in self._vm._devices[DISK_DEVICES]: + diskSamples[vmDrive.name] = self._vm._dom.blockStats(vmDrive.name) return diskSamples def _sampleDiskLatency(self): - if not self._vm.isDisksStatsCollectionEnabled(): - # Avoid queries from storage during recovery process - return # {'wr_total_times': 0L, 'rd_operations': 9638L, # 'flush_total_times': 0L,'rd_total_times': 7622718001L, # 'rd_bytes': 85172430L, 'flush_operations': 0L, # 'wr_operations': 0L, 'wr_bytes': 0L} diskLatency = {} - for vmDrive in self._vm._devices[DISK_DEVICES]: - diskLatency[vmDrive.name] = self._vm._dom.blockStatsFlags( - vmDrive.name, flags=libvirt.VIR_TYPED_PARAM_STRING_OKAY) + # Avoid queries from storage during recovery process + if self._vm.isDisksStatsCollectionEnabled(): + for vmDrive in self._vm._devices[DISK_DEVICES]: + diskLatency[vmDrive.name] = self._vm._dom.blockStatsFlags( + vmDrive.name, flags=libvirt.VIR_TYPED_PARAM_STRING_OKAY) return diskLatency def _sampleNet(self): -- To view, visit http://gerrit.ovirt.org/26790 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I749c1d502f96c8c8064f36c0c5edf0798e748dd9 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
