[pve-devel] [PATCH ha-manager 2/6] sim: use JSON instead of Dumper for manager status view

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Jan 12 15:51:55 CET 2017


This gives a little cleaner output, we can omit the Data::Dumper use
completely and need not 'sort dumper key' hack to keep the output
stable

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

 src/PVE/HA/Sim/RTHardware.pm | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/PVE/HA/Sim/RTHardware.pm b/src/PVE/HA/Sim/RTHardware.pm
index 5fe0cd4..12b0f2b 100644
--- a/src/PVE/HA/Sim/RTHardware.pm
+++ b/src/PVE/HA/Sim/RTHardware.pm
@@ -5,10 +5,9 @@ package PVE::HA::Sim::RTHardware;
 
 use strict;
 use warnings;
+
 use POSIX qw(strftime EINTR);
-use Data::Dumper;
-$Data::Dumper::Sortkeys = 1; # fixes 'random' output behaviour of manager status
-use JSON; 
+use JSON;
 use IO::File;
 use IO::Select;
 use Fcntl qw(:DEFAULT :flock);
@@ -619,8 +618,8 @@ sub run {
 	    $sl->set_text($text);
 	}
 
-	if (my $sv = $self->{gui}->{stat_view}) { 
-	    my $text = Dumper($mstatus);
+	if (my $sv = $self->{gui}->{stat_view}) {
+	    my $text = to_json($mstatus, { pretty => 1, canonical => 1});
 	    my $textbuf = $sv->get_buffer();
 	    $textbuf->set_text($text, -1);
 	}
-- 
2.1.4





More information about the pve-devel mailing list