Output the config filename containing a modprobe alias in XML
authorMatthew Booth <mbooth@redhat.com>
Mon, 29 Jun 2009 14:34:29 +0000 (15:34 +0100)
committerMatthew Booth <mbooth@redhat.com>
Mon, 29 Jun 2009 14:55:51 +0000 (15:55 +0100)
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

index b5d62ae..553c36a 100755 (executable)
@@ -672,6 +672,7 @@ sub assign_mount_points
                } else {
                    $fs->{used} = 1
                }
                } 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 ) {
         @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');
 
             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) {
        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" ],
         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]};
         }
             $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) {
        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");
        }
            }
             $xml->endTag("modprobealiases");
        }