[python][RFC] more python bulk stats API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I was wondering if there is room in libvirt-python for a couple of new APIs
which could make life easier for python developers.
It is not just a theoretical thing, when developing VDSM, part of oVirt, I
found myself repeating these patterns long enough.

1. return dict from getAllDomainStats and domainListGetStats
both bulk stats API returns on success a list of tuples, each tuple being (DomainReference, DictOfStats) ,
and I often find myself in need to translate them into a dict like {VMUUID:DictOfStats} , using some code like

def _translate(bulk_stats):
    return dict((dom.UUIDString(), stats)
                for dom, stats in bulk_stats)

So I'd like to suggest new APIs:

  virConnection.getAllDomainStatsMap()
  virConnection.domainListGetStatsMap()

which directly return the dict()s above; arguments should be like getAllDomainStats and domainListGetStats,
respectively.

2. get all the bulk stats from a single VM
it is trival and efficient to do this in C, but to do that in python means to use throwaway temporary lists,
one for the domain and one for the result
No big deal, but again, why to waste? I'd like to have

  virDomain.getBulkStats(stats)  # stats is like in getAllDomainStats

that should return just the DictOfStats on success.

For performance reasons, all of the above should be done in C.

Just in case, I have proof of concept code for all the above. I can post a tentative patch if maintainers like
these ideas.

Thanks,

Thoughts welcome

-- 
Francesco Romani
RedHat Engineering Virtualization R & D
Phone: 8261328
IRC: fromani

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]