diff options
author | Pavel Hrdina <phrdina@redhat.com> | 2014-09-01 21:57:35 +0200 |
---|---|---|
committer | Pavel Hrdina <phrdina@redhat.com> | 2014-09-01 22:12:46 +0200 |
commit | 5ead8c1b0c74f45514af5ccc1defcaabe0dc657a (patch) | |
tree | 3c2103a56ef5d35300226306921bb7587a7b0fca /libvirt-override-virConnect.py | |
parent | 285487954f13365dee2d6b522e14983b1d0f9190 (diff) | |
download | libvirt-python-5ead8c1b0c74f45514af5ccc1defcaabe0dc657a.tar.gz |
API: Implement bindings for virDomainListGetStats
Implement the function by returning a list of tuples instead the array
of virDomainStatsRecords and store the typed parameters as dict.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Diffstat (limited to 'libvirt-override-virConnect.py')
-rw-r--r-- | libvirt-override-virConnect.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py index c4c400a..218f266 100644 --- a/libvirt-override-virConnect.py +++ b/libvirt-override-virConnect.py @@ -436,3 +436,50 @@ retlist.append(record) return retlist + + def domainListGetStats(self, doms, stats=0, flags=0): + """ Query statistics for given domains. + + Report statistics of various parameters for a running VM according to @stats + field. The statistics are returned as an array of structures for each queried + domain. The structure contains an array of typed parameters containing the + individual statistics. The typed parameter name for each statistic field + consists of a dot-separated string containing name of the requested group + followed by a group specific description of the statistic value. + + The statistic groups are enabled using the @stats parameter which is a + binary-OR of enum virDomainStatsTypes. The following groups are available + (although not necessarily implemented for each hypervisor): + + VIR_DOMAIN_STATS_STATE: Return domain state and reason for entering that + state. The typed parameter keys are in this format: + "state.state" - state of the VM, returned as int from virDomainState enum + "state.reason" - reason for entering given state, returned as int from + virDomain*Reason enum corresponding to given state. + + Using 0 for @stats returns all stats groups supported by the given + hypervisor. + + Specifying VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS as @flags makes + the function return error in case some of the stat types in @stats were + not recognized by the daemon. + + Get statistics about domains provided as a list in @doms. @stats is + a bit field selecting requested statistics types.""" + domlist = list() + for dom in doms: + if not isinstance(dom, virDomain): + raise libvirtError("domain list contains non-domain elements", conn=self) + + domlist.append(dom._o) + + ret = libvirtmod.virDomainListGetStats(self._o, domlist, stats, flags) + if ret is None: + raise libvirtError("virDomainListGetStats() failed", conn=self) + + retlist = list() + for elem in ret: + record = (virDomain(self, _obj=elem[0]) , elem[1]) + retlist.append(record) + + return retlist |