[libvirt-php][PATCH 1/2] examples: Sort domains

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

 



In the examples/index.php we list all domains/networks/.. defined
for the connection we have. However, the objects are printed out
in the order as provided by libvirt, so basically a random order.
It may be more user friendly if we sort the array of objects
before printing it out.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 examples/libvirt.php | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/examples/libvirt.php b/examples/libvirt.php
index f65c50e..286bf4d 100644
--- a/examples/libvirt.php
+++ b/examples/libvirt.php
@@ -426,6 +426,8 @@ class Libvirt {
 
     function get_storagepools() {
         $tmp = libvirt_list_storagepools($this->conn);
+        if ($tmp)
+            sort($tmp, SORT_NATURAL);
         return ($tmp) ? $tmp : $this->_set_last_error();
     }
 
@@ -635,6 +637,8 @@ class Libvirt {
 
     function get_domains() {
         $tmp = libvirt_list_domains($this->conn);
+        if ($tmp)
+            sort($tmp, SORT_NATURAL);
         return ($tmp) ? $tmp : $this->_set_last_error();
     }
 
@@ -645,6 +649,8 @@ class Libvirt {
 
     function get_networks($type = VIR_NETWORKS_ALL) {
         $tmp = libvirt_list_networks($this->conn, $type);
+        if ($tmp)
+            sort($tmp, SORT_NATURAL);
         return ($tmp) ? $tmp : $this->_set_last_error();
     }
 
@@ -714,6 +720,8 @@ class Libvirt {
 
     function get_node_devices($dev = false) {
         $tmp = ($dev == false) ? libvirt_list_nodedevs($this->conn) : libvirt_list_nodedevs($this->conn, $dev);
+        if ($tmp)
+            sort($tmp, SORT_NATURAL);
         return ($tmp) ? $tmp : $this->_set_last_error();
     }
 
-- 
2.8.4

--
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]