added all_conf which return all configuration variables for single IP address
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 27 Aug 2009 14:30:55 +0000 (14:30 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 27 Aug 2009 14:30:55 +0000 (14:30 +0000)
lib/PXElator/client.pm
lib/PXElator/t/client.t

index 7f268d3..e7909a1 100644 (file)
@@ -66,6 +66,17 @@ sub conf {
        return $value;
 }
 
+sub all_conf {
+       my $ip = shift;
+       my $path = ip_path $ip || return;
+       my $conf;
+       foreach my $file ( glob("$path/*") ) {
+               my $name = $file;
+               $name =~ s{^.+/([^/]+)$}{$1};
+               $conf->{ $name } = read_file $file;
+       }
+       return $conf;
+}
 sub next_ip($) {
        my $mac = shift;
 
index 6ef054d..912c7f5 100755 (executable)
@@ -4,7 +4,7 @@ use warnings;
 use strict;
 use autodie;
 
-use Test::More tests => 14;
+use Test::More tests => 15;
 use Data::Dump qw/dump/;
 use English;
 
@@ -34,6 +34,9 @@ ok( my $mac_from_ip = client::mac_from_ip( $ip ), 'mac_from_ip' );
 diag $mac_from_ip;
 cmp_ok( $mac_from_ip, 'eq', $mac );
 
+ok( my $conf = client::all_conf( $ip ), 'all_conf' );
+diag dump $conf;
+
 diag "cleanup";
 ok( unlink( $_ ), "unlink $_" ) foreach ( glob("$dir/ip/$host/*"), "$dir/mac/$mac" );
 ok( rmdir "$dir/ip/$host", 'rmdir' );