From 7ca3e5b08ae6e6f062b5065475ffb07cb08a7610 Mon Sep 17 00:00:00 2001 From: Matthew Booth Date: Thu, 25 Jun 2009 14:33:26 +0100 Subject: [PATCH] Add yaml output for virt-inspector --- inspector/virt-inspector.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/inspector/virt-inspector.pl b/inspector/virt-inspector.pl index 28bee77..fc9b68e 100755 --- a/inspector/virt-inspector.pl +++ b/inspector/virt-inspector.pl @@ -29,6 +29,7 @@ use File::Temp qw/tempdir/; eval "use Sys::Virt;"; eval "use XML::XPath;"; eval "use XML::XPath::XMLParser;"; +eval "use YAML::Any;"; =encoding utf8 @@ -134,6 +135,11 @@ Produce no output at all. If you select I<--xml> then you get XML output which can be fed to other programs. +=item B<--yaml> + +If you select I<--yaml> then you get YAML output which can be fed +to other programs. + =item B<--perl> If you select I<--perl> then you get Perl structures output which @@ -183,6 +189,7 @@ GetOptions ("help|?" => \$help, "text" => sub { $output = "text" }, "none" => sub { $output = "none" }, "xml" => sub { $output = "xml" }, + "yaml" => sub { $output = "yaml" }, "perl" => sub { $output = "perl" }, "fish" => sub { $output = "fish" }, "guestfish" => sub { $output = "fish" }, @@ -930,6 +937,14 @@ elsif ($output eq "perl") { print Dumper(\%oses); } +# YAML output +elsif ($output eq "yaml") { + die "virt-inspector: no YAML support\n" + unless exists $INC{"YAML/Any.pm"}; + + print Dump(\%oses); +} + # Plain text output (the default). elsif ($output eq "text") { output_text (); -- 1.8.3.1