1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-07-05 08:59:36 +03:00
Commit Graph

7 Commits

Author SHA1 Message Date
fbc1a5e8d3 examples/nodestat: Show memory pinning information again
Resurrect the logic after it has been occasionally broken during fixing
the syntax complains from python.

Fixes: c588ba9 ("examples/nodestat: Fix None comparison")

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
2024-06-11 17:00:23 +03:00
74a78fa42c examples: Fix white space
indent by 4 spaces
one spaces around assignments

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-05 07:43:02 +00:00
b801ff31fa examples: Replace sys.exit() with exit()
No need to import sys.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-05 07:43:02 +00:00
9cf539a2a8 examples: Add/fix PEP 484 type annotation
Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-05 07:43:02 +00:00
c588ba982e examples/nodestat: Fix None comparison
"is" compares for "points to the same object", which for strings is the
same as comparing the byte sequence itself as Python hashes each strings
to only stores a unique copy of each string.

> examples/nodestats.py:86:43: F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple)
> examples/nodestats.py:91:12: F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple)
> examples/nodestats.py:94:40: F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple)

Use "==" and "!=" for string comparsion.

Signed-off-by: Philipp Hahn <hahn@univention.de>
2020-08-05 07:43:02 +00:00
b22e4f2441 Drop support for python 2
python2 will be end of life by the time of the next
libvirt release. All our supported build targets, including
CentOS7, have a python3 build available.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-12-04 12:14:51 +00:00
fa21f3d927 examples: Introduce nodestats example
So, this is an exercise to show libvirt capabilities. Firstly, for
each host NUMA nodes some statistics are printed out, i.e. total
memory and free memory. Then, for each running domain, that has memory
strictly bound to certain host nodes, a small statistics of how much
memory it takes is printed out too. For instance:

        # ./examples/nodestats.py
        NUMA stats
        NUMA nodes:     0       1       2       3
        MemTotal:       3950    3967    3937    3943
        MemFree:        66      56      42      41
        Domain 'fedora':
                Overall memory: 1536 MiB
        Domain 'fedora22':
                Overall memory: 2048 MiB
        Domain 'fedora21':
                Overall memory: 1024 MiB nodes 0-1
                Node 0: 1024 MiB nodes 0-1
        Domain 'gentoo':
                Overall memory: 4096 MiB nodes 0-3
                Node 0: 1024 MiB nodes 0
                Node 1: 1024 MiB nodes 1
                Node 2: 1024 MiB nodes 2
                Node 3: 1024 MiB nodes 3

We can see 4 host NUMA nodes, all of them having roughly 4GB of RAM.
Yeah, all of them has nearly all the memory consumed. Then, there are
four domains running. For instance, domain 'fedora' has 1.5GB memory
which is not pinned onto any specific host NUMA node. Domain 'gentoo' on
the other hand has 4GB memory and has 4 NUMA nodes which are pinned 1:1
to host nodes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-07-17 11:42:44 +02:00