From 103fb55e6b1428366ab31a0f17484ef1baa68e96 Mon Sep 17 00:00:00 2001 From: Matthew Booth Date: Mon, 29 Jun 2009 15:34:29 +0100 Subject: [PATCH] Output the config filename containing a modprobe alias in XML This change affects the XML output: /operatingsystems/operatingsystem/modprobealiases/alias/text() => /operatingsystems/operatingsystem/modprobealiases/alias/modulename/text() Additionally there are two new elements: /operatingsystems/operatingsystem/modprobealiases/alias/augeas /operatingsystems/operatingsystem/modprobealiases/alias/file These contain information about the location of the alias directive. /augeas is an augeas path. /file is the path of the file containing the directive. --- inspector/virt-inspector.pl | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/inspector/virt-inspector.pl b/inspector/virt-inspector.pl index b5d62ae..553c36a 100755 --- a/inspector/virt-inspector.pl +++ b/inspector/virt-inspector.pl @@ -672,6 +672,7 @@ sub assign_mount_points } else { $fs->{used} = 1 } + $fs->{spec} = $spec; } } } @@ -884,13 +885,22 @@ sub check_for_modprobe_aliases @results = $g->aug_match($pattern); for my $path ( @results ) { + $path =~ m{^/files(.*)/alias(?:\[\d*\])?$} + or die("$path doesn't match augeas pattern"); + my $file = $1; + my $alias; $alias = $g->aug_get($path); my $modulename; $modulename = $g->aug_get($path.'/modulename'); - $modprobe_aliases{$alias} = $modulename; + my %aliasinfo; + $aliasinfo{modulename} = $modulename; + $aliasinfo{augeas} = $path; + $aliasinfo{file} = $file; + + $modprobe_aliases{$alias} = \%aliasinfo; } } @@ -1040,7 +1050,7 @@ sub output_text_os if (@keys) { print " Modprobe aliases:\n"; foreach (@keys) { - printf " %-30s %s\n", $_, $aliases{$_} + printf " %-30s %s\n", $_, $aliases{$_}->{modulename} } } } @@ -1122,7 +1132,8 @@ sub output_xml_os foreach my $field ( [ "label" => "label" ], [ "uuid" => "uuid" ], [ "type" => "fstype" ], - [ "content" => "content" ] ) { + [ "content" => "content" ], + [ "spec" => "spec" ] ) { $xml->dataElement($field->[0], $filesystems->{$_}{$field->[1]}) if exists $filesystems->{$_}{$field->[1]}; } @@ -1137,7 +1148,15 @@ sub output_xml_os if (@keys) { $xml->startTag("modprobealiases"); foreach (@keys) { - $xml->dataElement("alias", $aliases{$_}, "device" => $_); + $xml->startTag("alias", "device" => $_); + + foreach my $field ( [ "modulename" => "modulename" ], + [ "augeas" => "augeas" ], + [ "file" => "file" ] ) { + $xml->dataElement($field->[0], $aliases{$_}->{$field->[1]}); + } + + $xml->endTag("alias"); } $xml->endTag("modprobealiases"); } -- 1.8.3.1