From 7feecb76c8813615b933602d4f810de997c46761 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 27 Aug 2009 14:30:55 +0000 Subject: [PATCH] added all_conf which return all configuration variables for single IP address --- lib/PXElator/client.pm | 11 +++++++++++ lib/PXElator/t/client.t | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/PXElator/client.pm b/lib/PXElator/client.pm index 7f268d3..e7909a1 100644 --- a/lib/PXElator/client.pm +++ b/lib/PXElator/client.pm @@ -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; diff --git a/lib/PXElator/t/client.t b/lib/PXElator/t/client.t index 6ef054d..912c7f5 100755 --- a/lib/PXElator/t/client.t +++ b/lib/PXElator/t/client.t @@ -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' ); -- 2.20.1