From 5ead8c1b0c74f45514af5ccc1defcaabe0dc657a Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Mon, 1 Sep 2014 21:57:35 +0200 Subject: 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 Signed-off-by: Pavel Hrdina --- libvirt-override-virConnect.py | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'libvirt-override-virConnect.py') 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 -- cgit v1.2.1