pf-tools/pf-tools: 10 new changesets

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Mon Oct 11 09:39:19 UTC 2010


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/b292bfed81eb
changeset: 849:b292bfed81eb
user:      Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date:      Fri Oct 01 07:53:09 2010 +0200
description:
Parser_ini(): new test with a real configuration file

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/cb0f942c6f46
changeset: 850:cb0f942c6f46
user:      Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date:      Fri Oct 01 09:39:24 2010 +0200
description:
PFTools::Conf::Init_PF_CONFIG() is now idempotent.

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/44949725ec8d
changeset: 851:44949725ec8d
user:      Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date:      Fri Oct 01 09:55:36 2010 +0200
description:
Remove a superfluous "my" in t/13.conf.t

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/fdef2a8378da
changeset: 852:fdef2a8378da
user:      Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date:      Fri Oct 01 09:59:09 2010 +0200
description:
Style

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/d7a651c4ebaf
changeset: 853:d7a651c4ebaf
user:      Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date:      Thu Oct 07 18:14:08 2010 +0200
description:
Remove trailing comments

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/1b3ecc048017
changeset: 854:1b3ecc048017
user:      Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date:      Mon Oct 11 07:37:20 2010 +0200
description:
Load_conf() now automagically resolves $file with Get_source(), using $hash_subst->{'HOSTNAME'} as the hostname.

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/dc722b4b8035
changeset: 855:dc722b4b8035
user:      Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date:      Mon Oct 11 07:43:16 2010 +0200
description:
Regexp style

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/40112a8bad7b
changeset: 856:40112a8bad7b
user:      Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date:      Mon Oct 11 08:16:10 2010 +0200
description:
More tests for Load_conf()

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/78afe5b45a89
changeset: 857:78afe5b45a89
user:      Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date:      Mon Oct 11 08:16:53 2010 +0200
description:
Add the needed config files for the new tests

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/5471a7ec2b40
changeset: 858:5471a7ec2b40
user:      Thomas Parmelan <tom+pf-tools at ankh.fr.EU.org>
date:      Mon Oct 11 11:37:16 2010 +0200
description:
Unbreak make test after last merge

diffstat:

15 files changed, 167 insertions(+), 8 deletions(-)
debian/changelog                                                       |    2 
lib/PFTools/Conf.pm                                                    |    1 
lib/PFTools/Parser.pm                                                  |    1 
lib/PFTools/VCS.pm                                                     |    3 
t/00.load.t                                                            |    6 -
t/10.parse.cfg2                                                        |    5 -
t/10.parse.t                                                           |    2 
t/13.conf.cfg1/config-export/COMMON/network-common                     |    7 +
t/13.conf.cfg1/config-export/COMMON/private-network                    |   49 ++++++++++
t/13.conf.cfg1/config-export/COMMON/update-common                      |    3 
t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/hostfile-cbv4-spawn |   25 +++++
t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/update-cbv4-spawn   |   37 +++++++
t/13.conf.cfg1/config-export/SITE/cbv4-pfds/MODEL/model-cbv4-pfds      |   18 +++
t/13.conf.cfg1/etc/pf-tools.1.conf                                     |   15 +++
t/13.conf.t                                                            |    1 

diffs (1186 lines):

diff -r 92e3151737a4 -r 5471a7ec2b40 debian/changelog
--- a/debian/changelog	Mon Oct 04 19:29:19 2010 +0200
+++ b/debian/changelog	Mon Oct 11 11:37:16 2010 +0200
@@ -9,6 +9,10 @@
   * Use English
   * Don't call mkdir, use File::Path's make_path() instead.
   * Start writing some tests in t/*.t (run with "make test" or "prove -l").
+  * PFTools::Conf::Init_PF_CONFIG() is now idempotent.
+  * Parser_ini() now removes trailing comments.
+  * Load_conf() now automagically resolves $file with Get_source(), using
+    $hash_subst->{'HOSTNAME'} as the hostname.
 
   [ Christophe Caillet ]
   * use remove_tree with keep_root option instead of remove_tree + make_path
@@ -27,7 +31,7 @@
   * using Module::Runtime for handling actions with a common API
   * using Module::Runtime for handling packages functions with a common API 
 
- -- Christophe Caillet <quadchris at free.fr>  Mon, 04 Oct 2010 18:33:39 +0200
+ -- Thomas Parmelan <tom at sitadelle.com>  Mon, 11 Oct 2010 07:36:25 +0200
 
 pf-tools (1.0-1) unstable; urgency=low
 
diff -r 92e3151737a4 -r 5471a7ec2b40 debian/control
--- a/debian/control	Mon Oct 04 19:29:19 2010 +0200
+++ b/debian/control	Mon Oct 11 11:37:16 2010 +0200
@@ -8,7 +8,7 @@
 
 Package: pf-tools
 Architecture: all
-Depends: perl, perl (>= 5.10.0) | libmd5-perl, libconfig-inifiles-perl, libnetaddr-ip-perl, libnet-dns-perl, libtemplate-tiny-perl, libtext-diff-perl, libmodule-runtime-perl, cvs, ssh, iproute, debconf, psmisc
+Depends: perl, perl (>= 5.10.0) | libmd5-perl, libclone-perl, libconfig-inifiles-perl, libmodule-runtime-perl, libnetaddr-ip-perl, libnet-dns-perl, libreadonly-xs-perl, libtemplate-tiny-perl, libtext-diff-perl, cvs, ssh, iproute, debconf, psmisc
 Description: Outils de gestion de la plateforme
  Mise a jour automatique et generation de conf.
  Deploiement de machines.
diff -r 92e3151737a4 -r 5471a7ec2b40 lib/PFTools/Conf.pm
--- a/lib/PFTools/Conf.pm	Mon Oct 04 19:29:19 2010 +0200
+++ b/lib/PFTools/Conf.pm	Mon Oct 11 11:37:16 2010 +0200
@@ -26,9 +26,11 @@
 
 use base qw( Exporter);
 use Carp;
+use Clone qw( clone );
 use English qw( -no_match_vars );    # Avoids regex performance penalty
 use Fcntl ':mode';
 use Net::Domain qw( hostname hostdomain );
+use Readonly;
 use Storable;
 
 use PFTools::Conf::Host;
@@ -75,7 +77,7 @@
 
 =cut
 
-our $PF_CONFIG = {
+Readonly our $DEFAULT_PF_CONFIG => {
     'path' => {
         'status_dir'     => '/var/lib/pftools',
         'distrib_dir'    => '/distrib',
@@ -97,15 +99,15 @@
     'vcs' => {
         'type'     => 'cvs',
         'user'     => 'cvsguest',
-        'password' => '',
+        'password' => q{},
         'method'   => 'rsh',
         'rsh'      => '/usr/local/sbin/cvs_rsh',
         'server'   => 'cvs.private',
         'vcsroot'  => '/var/lib/cvs/repository',
         'module'   => 'config',
         'umask'    => '0077',
-        'command'  => '',
-        'branche'  => '',
+        'command'  => q{},
+        'branche'  => q{},
     },
     'debian' => {
         'preseed'          => 'standard-preseed',
@@ -130,13 +132,15 @@
         'hostname'       => $HOST_CONFIG_REGEX,
         'hosttype'       => $HOSTTYPE_CONFIG_REGEX,
         'deploy_hosts'   => $DEPLOY_CONFIG_REGEX,
-        'network_fstype' => '(nfs|cifs)',
+        'network_fstype' => qr{(nfs|cifs)},
     },
     'location' => {
-        'site' => '',
-        'zone' => '',
+        'site' => q{},
+        'zone' => q{},
     },
 };
+
+our $PF_CONFIG = {};
 
 =head2 Subst_vars( $text, $variables_ref )
 
@@ -153,15 +157,16 @@
     return $text unless $text;
     return $text unless ref $variables_ref eq 'HASH';
 
-    $text =~ s{ % ([^%]+) % }{ $variables_ref->{$1} || '' }xmsge;
+    $text =~ s{ % ([^%]+) % }{ $variables_ref->{$1} || q{} }xmsge;
     return $text;
 }
 
 =head2 Init_PF_CONFIG( $filename )
 
 Parses $filename and merges known sections/keys with the default
-configuration as found in $PF_CONFIG.
-Returns $PF_CONFIG if no $filename specified.
+configuration as found in $DEFAULT_PF_CONFIG, and stores the result
+in $PF_CONFIG.
+Uses the default configuration if no $filename specified.
 Returns the result of the merge if $filename parses correctly.
 croak() on fatal error.
 
@@ -169,6 +174,8 @@
 
 sub Init_PF_CONFIG {
     my ($config_file) = @_;
+
+    $PF_CONFIG = clone($DEFAULT_PF_CONFIG);
 
     return $PF_CONFIG unless $config_file;
 
@@ -191,10 +198,9 @@
 
     # FIXME use Hash::Merge::Simple instead ?
     # (it would allow unknown sections/keys, is that a problem ?)
-    # (would also need to separate $DEFAULT_PF_CONFIG and $PF_CONFIG)
-    foreach my $section ( keys %{$PF_CONFIG} ) {
+    foreach my $section ( keys %{$DEFAULT_PF_CONFIG} ) {
         next if !defined $conf_parsed->{$section};
-        foreach my $key ( keys %{ $PF_CONFIG->{$section} } ) {
+        foreach my $key ( keys %{ $DEFAULT_PF_CONFIG->{$section} } ) {
             next if !defined $conf_parsed->{$section}->{$key};
             $PF_CONFIG->{$section}->{$key} = $conf_parsed->{$section}->{$key};
         }
@@ -295,21 +301,21 @@
     my $result = $source;
 
     $result
-        =~ s{ \A MODSITE_([^:]+) [:] }{$vcs_work_dir/$module/SITE/$1/MODEL}xms;
-    $result =~ s{ \A MOD [:] }{$vcs_work_dir/$module/MODEL}xms;
+        =~ s{ \A MODSITE_([^:]+) [:] }{$vcs_work_dir/$module/SITE/$1/MODEL/}xms;
+    $result =~ s{ \A MOD [:] }{$vcs_work_dir/$module/MODEL/}xms;
     $result
-        =~ s{ \A CONFSITE_([^:]+) [:] }{$vcs_work_dir/$module/SITE/$1/CONFIG}xms;
-    $result =~ s{ \A CONF [:] }{$vcs_work_dir/$module/CONFIG}xms;
-    $result =~ s{ \A SITE_([^:]+) [:] }{$vcs_work_dir/$module/SITE/$1}xms;
-    $result =~ s{ \A SITE [:] }{$vcs_work_dir/$module/SITE}xms;
+        =~ s{ \A CONFSITE_([^:]+) [:] }{$vcs_work_dir/$module/SITE/$1/CONFIG/}xms;
+    $result =~ s{ \A CONF [:] }{$vcs_work_dir/$module/CONFIG/}xms;
+    $result =~ s{ \A SITE_([^:]+) [:] }{$vcs_work_dir/$module/SITE/$1/}xms;
+    $result =~ s{ \A SITE [:] }{$vcs_work_dir/$module/SITE/}xms;
     $result
-        =~ s{ \A HOSTSITE_([^:]+) [:] }{$vcs_work_dir/$module/SITE/$1/%HOSTTYPE%}xms;
+        =~ s{ \A HOSTSITE_([^:]+) [:] }{$vcs_work_dir/$module/SITE/$1/%HOSTTYPE%/}xms;
     $result
-        =~ s{ \A HOST [:] }{$vcs_work_dir/$module/%HOSTTYPE%}xms;
-    $result =~ s{ \A COMMON [:] }{$vcs_work_dir/$module/COMMON}xms;
+        =~ s{ \A HOST [:] }{$vcs_work_dir/$module/%HOSTTYPE%/}xms;
+    $result =~ s{ \A COMMON [:] }{$vcs_work_dir/$module/COMMON/}xms;
     $result =~ s{ \A CONFIG [:] }{$vcs_work_dir/$module/}xms;
     $result =~ s{ \A CVS [:] }{$vcs_work_dir/}xms;
-    $result =~ s{ \A GLOBAL [:] }{$vcs_work_dir/$module/GLOBAL}xms;
+    $result =~ s{ \A GLOBAL [:] }{$vcs_work_dir/$module/GLOBAL/}xms;
 
     $result = Subst_vars( $result, $hash_subst );
 
@@ -346,12 +352,16 @@
         croak q{ERROR: Invalid non-hashref $pf_config};
     }
 
-    if ( $context !~ m/^$ALLOWED_PARSING_CONTEXT$/ ) {
-        croak qq{ERROR: Invalid context $context for file $file doesn't match $ALLOWED_PARSING_CONTEXT};
+    if ( $context !~ m{ \A $ALLOWED_PARSING_CONTEXT \z }xms ) {
+        croak qq{ERROR: Invalid context $context for file $file: doesn't match $ALLOWED_PARSING_CONTEXT};
     }
 
+    # Automagically resolve $file with Get_source()
+    my $hostname = $hash_subst->{'HOSTNAME'}; # FIXME or croak ?
+    my $real_file = Get_source( $file, $hostname, $hash_subst, $pf_config );
+
     # this will croak() on error
-    my $parsed = Parser_ini($file);
+    my $parsed = Parser_ini($real_file);
 
     my $select = $context eq 'config' ? 'action' : 'type'; # compute it only once
 
@@ -361,10 +371,7 @@
     if ( $context eq 'host' or $context eq 'model' ) {
         if ( defined $parsed->{'hostgroup'}->{'model'} ) {
             $parsed->{'hostgroup'}->{'__model'} = Load_conf(
-                Get_source(
-                    $parsed->{'hostgroup'}->{'model'},
-                    "", $hash_subst, $pf_config
-                ),
+                Get_source( $parsed->{'hostgroup'}->{'model'}, q{}, $hash_subst, $pf_config), # FIXME auto
                 $hash_subst,
                 'model',
                 $pf_config
@@ -385,8 +392,8 @@
                 # We need to dive into deep ...
                 $parsed->{$section}->{'__content'}
                     = Load_conf(
-                    Get_source( $section, q{}, $hash_subst, $pf_config ),
-                    $hash_subst, $context, $pf_config
+                        Get_source( $section, q{}, $hash_subst, $pf_config ), # FIXME auto
+                        $hash_subst, $context, $pf_config
                     );
             }
         }
@@ -483,7 +490,7 @@
                     ->{'BY_NAME'};
                 foreach my $host ( @{ $net_parsed->{$section}->{'@host'} } ) {
                     my $hostfile
-                        = Get_source( $host, "", $hash_subst, $pf_config );
+                        = Get_source( $host, q{}, $hash_subst, $pf_config );
                     my $host_parsed
                         = Load_conf(
                         $hostfile, $hash_subst, 'host',
@@ -557,6 +564,7 @@
 
     # Common configuration file e.g. update-common
     my $global_host_conf = Load_conf(
+        # FIXME test if the auto-Get_source() with $hash_subst->{'HOSTNAME}' is OK here
         Get_source(
             'COMMON:/' . $pf_config->{'path'}->{'common_config'},
             $hostname, $hash_subst, $pf_config
diff -r 92e3151737a4 -r 5471a7ec2b40 lib/PFTools/Conf/Syntax.pm
--- a/lib/PFTools/Conf/Syntax.pm	Mon Oct 04 19:29:19 2010 +0200
+++ b/lib/PFTools/Conf/Syntax.pm	Mon Oct 11 11:37:16 2010 +0200
@@ -46,7 +46,7 @@
 
 # FIXME: $CONFIG_REGEX->{'foo'} instead of $FOO_CONFIG_REGEX
 
-our $ALLOWED_PARSING_CONTEXT = qr{host|network|config|model};
+our $ALLOWED_PARSING_CONTEXT = qr{ (?:host|network|config|model) }xms;
 our $HOSTTYPE_CONFIG_REGEX   = qr{
     \A
     (?<HOSTTYPE>                # HOSTTYPE
diff -r 92e3151737a4 -r 5471a7ec2b40 lib/PFTools/Parser.pm
--- a/lib/PFTools/Parser.pm	Mon Oct 04 19:29:19 2010 +0200
+++ b/lib/PFTools/Parser.pm	Mon Oct 11 11:37:16 2010 +0200
@@ -30,6 +30,8 @@
 
 our @EXPORT_OK = qw( Parser_ini );
 
+my $trailing_comment_regex = qr{ \s+ [#] .* \z }xms;
+
 sub Parser_ini {
     my ($file) = @_;
 
@@ -52,12 +54,28 @@
         my $section = $refined->{$section_name};
         foreach my $key_name ( keys %{$section} ) {
             my $value = $section->{$key_name};
+
+            # First, only keys starting with '@' can be arrays...
             if ( ref $value eq 'ARRAY' and $key_name !~ m{ \A @ }xms ) {
                 $section->{$key_name} = pop @{$value};
             }
+
+            # ..and .all keys starting with '@' must be arrays
             elsif ( $key_name =~ m{ \A @ }xms and ref $value ne 'ARRAY' ) {
                 $section->{$key_name} = [ $value ];
             }
+
+            # Second, remove trailing spaces in arrays...
+            if ( ref $section->{$key_name} eq 'ARRAY' ) {
+                map { $_ =~ s{$trailing_comment_regex}{}; }
+                    @{ $section->{$key_name} };
+            }
+
+            # ...and in scalars
+            else {
+                $section->{$key_name} =~ s{$trailing_comment_regex}{};
+            }
+
         }
     }
 
diff -r 92e3151737a4 -r 5471a7ec2b40 lib/PFTools/Utils.pm
--- a/lib/PFTools/Utils.pm	Mon Oct 04 19:29:19 2010 +0200
+++ b/lib/PFTools/Utils.pm	Mon Oct 11 11:37:16 2010 +0200
@@ -427,7 +427,7 @@
     my $domain = Get_zone_from_hostname( $hostname, $global_config, $site );
     if ( !defined $domain ) {
         Warn( $CODE->{'UNDEF_KEY'},
-            "Unable to get domain from hostname " . $domain );
+            "Unable to get domain from hostname " . $hostname );
         return 0;
     }
 
diff -r 92e3151737a4 -r 5471a7ec2b40 lib/PFTools/VCS.pm
--- a/lib/PFTools/VCS.pm	Mon Oct 04 19:29:19 2010 +0200
+++ b/lib/PFTools/VCS.pm	Mon Oct 11 11:37:16 2010 +0200
@@ -24,14 +24,15 @@
 use base qw( Exporter );
 use Carp;
 use English qw( -no_match_vars );    # Avoids regex performance penalty
-use File::Path qw( make_path remove_tree );
-use Module::Runtime qw ( use_module );
+use Module::Runtime qw( use_module );
 
 use PFTools::Logger;
 
 our @EXPORT = qw(
     VCS_checkout
 );
+
+our @EXPORT_OK = qw();
 
 sub VCS_checkout ($$$) {
     my ( $hostname, $pf_config, $options ) = @_;
diff -r 92e3151737a4 -r 5471a7ec2b40 t/00.load.t
--- a/t/00.load.t	Mon Oct 04 19:29:19 2010 +0200
+++ b/t/00.load.t	Mon Oct 11 11:37:16 2010 +0200
@@ -24,16 +24,16 @@
     use_ok('PFTools::Packages::DEB');
     use_ok('PFTools::Parser');
     use_ok('PFTools::Structqueries');
-    use_ok('PFTools::Update::Addfile');
-    use_ok('PFTools::Update::Addlink');
-    use_ok('PFTools::Update::Addmount');
+    use_ok('PFTools::Update::ADDFILE');
+    use_ok('PFTools::Update::ADDLINK');
+    use_ok('PFTools::Update::ADDMOUNT');
     use_ok('PFTools::Update::Common');
-    use_ok('PFTools::Update::Createfile');
-    use_ok('PFTools::Update::Installpkg');
-    use_ok('PFTools::Update::Mkdir');
-    use_ok('PFTools::Update::Purgepkg');
-    use_ok('PFTools::Update::Removedir');
-    use_ok('PFTools::Update::Removefile');
+    use_ok('PFTools::Update::CREATEFILE');
+    use_ok('PFTools::Update::INSTALLPKG');
+    use_ok('PFTools::Update::MKDIR');
+    use_ok('PFTools::Update::PURGEPKG');
+    use_ok('PFTools::Update::REMOVEDIR');
+    use_ok('PFTools::Update::REMOVEFILE');
     use_ok('PFTools::Update');
     use_ok('PFTools::Utils');
     use_ok('PFTools::VCS');
diff -r 92e3151737a4 -r 5471a7ec2b40 t/10.parse.cfg2
--- a/t/10.parse.cfg2	Mon Oct 04 19:29:19 2010 +0200
+++ b/t/10.parse.cfg2	Mon Oct 11 11:37:16 2010 +0200
@@ -1,12 +1,12 @@
+# This is a comment
+
 [section1]
-    key1 = 1
+    key1 = 1	# comment about key1
     key2 = 2
-    @key3 = a
-    @key3 = b
-    key4 = c
-    key4 = d
-
-# This is a comment
+    @key3 = a	# comment about @key3-a
+    @key3 = b	# comment about @key3-b
+    key4 = c	# comment about key4-c
+    key4 = d	# comment about key4-d
 
 [section2]
     key_21 = 21
diff -r 92e3151737a4 -r 5471a7ec2b40 t/10.parse.t
--- a/t/10.parse.t	Mon Oct 04 19:29:19 2010 +0200
+++ b/t/10.parse.t	Mon Oct 11 11:37:16 2010 +0200
@@ -28,9 +28,10 @@
     qr{\A ERROR: }xms
     => 'Dies on non-ini file';
 
-$cfg = Parser_ini('t/10.parse.cfg2');
+my $file = 't/10.parse.cfg2';
+$cfg = Parser_ini($file);
 ok defined($cfg)
-    => 'Returns something on real ini file';
+    => qq{Returns something on real ini file $file};
 
 my $expected_cfg = {
   '__sections_order' => [
@@ -52,6 +53,52 @@
   },
 };
 is_deeply $cfg, $expected_cfg
-    => 'Returns the correct hash on real ini file'
+    => qq{Returns the correct hash on real ini file t/10.parse.cfg2}
     or note explain $cfg;
 
+$expected_cfg = {
+    '__sections_order' => [
+        'path',
+        'features',
+        'vcs',
+        'location',
+        'foo',
+    ],
+    'features' => {
+        'ipv4'   => '1',
+        'ipv6'   => '0',
+        'update' => '1',
+    },
+    'foo' => {
+        'ignored' => '1',
+    },
+    'location' => {
+        'foo'  => 'bar',
+        'site' => 'cbv4-pfds',
+        'zone' => 'private',
+    },
+    'path' => {
+        'checkout_dir'   => '/tmp/pf-test/var/lib/cvsguest',
+        'common_config'  => 'update-common',
+        'deploy_docroot' => '/tmp/pf-test/var/www',
+        'distrib_dir'    => '/tmp/pf-test/distrib',
+        'global_struct'  => '/tmp/pf-test/var/lib/pf-tools/global.stor',
+        'preseed_dir'    => '/tmp/pf-test/var/www/preseed',
+        'pxefiles_dir'   => '/tmp/pf-test/distrib/tftpboot/pxelinux.cfg',
+        'start_file'     => 'private-network',
+        'status_dir'     => '/tmp/pf-test/var/lib/pf-tools',
+        'templates_dir'  => '/tmp/pf-test/usr/share/pf-tools/templates',
+        'tftp_dir'       => '/tmp/pf-test/distrib/tftpboot',
+    },
+    'vcs' => {
+        'module'  => 'config',
+        'type'    => 'cvs',
+        'vcsroot' => '/tmp/pf-test/var/lib/cvs/repository',
+    },
+};
+$file = 't/13.conf.cfg1/etc/pf-tools.1.conf';
+$cfg = Parser_ini($file);
+is_deeply $cfg, $expected_cfg
+    => qq{Returns the correct hash on real ini file $file}
+    or note explain $cfg;
+
diff -r 92e3151737a4 -r 5471a7ec2b40 t/13.conf.cfg1/config-export/COMMON/network-common
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/t/13.conf.cfg1/config-export/COMMON/network-common	Mon Oct 11 11:37:16 2010 +0200
@@ -0,0 +1,15 @@
+[vlan-systeme]
+type    = network
+tag     = 13
+# @site ?
+site    = cbv4, cbv4-pfds
+network = 10.1.0.0/16
+scope   = private
+
+[vlan-pfds-int]
+type    = network
+site    = cbv4-pfds
+tag     = 39
+network = 10.2.0.0/16
+scope   = private
+
diff -r 92e3151737a4 -r 5471a7ec2b40 t/13.conf.cfg1/config-export/COMMON/private-network
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/t/13.conf.cfg1/config-export/COMMON/private-network	Mon Oct 11 11:37:16 2010 +0200
@@ -0,0 +1,99 @@
+# This is were it all begins!
+
+[private]
+type            = zone
+comment         = Internal management zone
+serial          = AUTO
+soa             = Deploy00.private.
+mail            = dnsmaster at private
+refresh         = 6H      ; Refresh (6 hours)
+retry           = 1H      ; Retry (1 hour)
+expire          = 7D      ; Expire (7 days)
+negttl          = 1H      ; Negative TTL (1 hours)
+ttl             = 1D      ; TTL (1 day)
+ at ns             = deploy00.vlan-systeme.private.
+ at ns             = deploy01.vlan-systeme.private.
+ at mx             = 1       mf.private.
+ at mx             = 2       mf00.private.
+ at mx             = 2       mf01.private.
+console         = ttyS0,115200n8
+
+[cbv4-pfds]
+    type        = site
+    coment      = CBV4-PFDS root site
+    location    = Courbevoie
+    room        = CBV4-PFDS Room Name
+    state       = ROOT
+    dhcpvlan    = vlan-systeme
+    console     = default
+    zone        = private
+
+[cbv4]
+    type        = site
+    coment      = CBV4 POP
+    location    = Courbevoie
+    room        = CBV4 Room Name
+    state       = EDGE
+    dhcpvlan    = vlan-systeme
+    console     = default
+    zone        = private
+
+[vip-spawn]
+    type                = server
+    site                = cbv4-pfds
+    comment             = VIP for spawn services
+    order               = 2
+    number              = 1
+    ipv4.vlan-systeme   = 1.254
+    ipv4.vlan-pfds-ext  = 99
+    shortname           = vlan-systeme
+    alias.mirrors       = vlan-systeme
+    alias.cvs           = vlan-systeme
+    alias.nsprivate     = vlan-systeme
+    alias.nscache       = vlan-systeme
+    alias.mf            = vlan-systeme
+    alias.vip-deploy    = vlan-systeme
+
+[cbv4-pfds-filer%%]
+    type                = server
+    site                = cbv4-pfds
+    comment             = NAS for CBV4-PFDS site
+    order               = 2
+    number              = 2
+    ipv4.vlan-systeme   = 2.0
+    shortname           = vlan-systeme 
+
+[COMMON:/network-common]
+    type    = include
+
+[vlan-pfds-ext]
+    type    = network
+    site    = cbv4-pfds
+    comment = something really interesting
+    network = 192.168.1.0/24
+    tag     = 40
+    scope   = public
+    gateway = 254
+
+[vlan-admindsi]
+    type    = network
+    site    = cbv4-pfds
+    network = 10.3.1.0/24
+    tag     = 302
+    scope   = private
+    gateway = 254
+
+[vlan-middledsi]
+    type    = network
+    site    = cbv4-pfds
+    network = 10.3.2.0/24
+    tag     = 372
+    scope   = private
+    gateway = 254
+
+[admins]
+    type    = service
+    comment = Administration hosts
+    site    = cbv4-pfds
+    @host   = CONFSITE_cbv4-pfds:/hostfile-cbv4-spawn
+
diff -r 92e3151737a4 -r 5471a7ec2b40 t/13.conf.cfg1/config-export/COMMON/update-common
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/t/13.conf.cfg1/config-export/COMMON/update-common	Mon Oct 11 11:37:16 2010 +0200
@@ -0,0 +1,6 @@
+# Sample update-common file
+
+[pf-tools]
+    action	 = apt-get
+    after_change = echo "Re-run update-config"; killall -KILL update-config
+
diff -r 92e3151737a4 -r 5471a7ec2b40 t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/hostfile-cbv4-spawn
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/hostfile-cbv4-spawn	Mon Oct 11 11:37:16 2010 +0200
@@ -0,0 +1,51 @@
+#[boot]
+#	kernel = vmlinuz-2.6.26.5-universal-grm2.1.12
+#	kerneluml = linux-uml-elf-2.4.26-gr1.9.15
+#	pxefilename = pxelinux.0
+#	console = default
+##	cmdline = pci=bfsort
+
+[dns]
+#	shortname = vlan-systeme
+	alias.ntp = vlan-systeme
+#	resolver = nsprivate.private,spawn.private
+	alias.spawn = vlan-systeme
+
+[interface::eth5]
+	ipv4 = 41
+#	vlan = vlan-middledsi
+
+#[deployment]
+#	mode = debian
+#	arch = amd64
+#	distrib = lenny
+
+[interface::eth0]
+	ipv4 = 167.0
+	mac.1 = 00:1e:c9:ff:42:0a
+	mac.0 = 00:1e:c9:ff:08:e3
+#	vlan = vlan-systeme
+
+#[interface::eth0.TAG1]
+#	vlan	= vlan-pfds-int
+#	ipv4	= 167.0
+
+[hostgroup]
+	model		= MODSITE_cbv4-pfds:/model-cbv4-pfds
+	number		= 2
+	comment		= Spawning server
+	order 		= 1
+	hostname	= cbv4-spawn%%
+#	site		= cbv4-pfds
+
+[interface::eth4]
+	ipv4 = 41
+#	vlan = vlan-admindsi
+
+[interface::bond0]
+#	options = miimon=100
+	ipv4 = 97
+#	mode = active-backup
+#	slaves = eth1,eth2
+#	@route = default via GATEWAY
+#	vlan = vlan-pfds-ext
diff -r 92e3151737a4 -r 5471a7ec2b40 t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/update-cbv4-spawn
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/t/13.conf.cfg1/config-export/SITE/cbv4-pfds/CONFIG/update-cbv4-spawn	Mon Oct 11 11:37:16 2010 +0200
@@ -0,0 +1,74 @@
+#
+# Sample update-cbv4-spawn
+#
+
+[CONFSITE_cbv4-pfds:/include-spawn-common]
+        action          = include
+
+[CONFSITE_cbv4-pfds:/include-distrib-custom]
+        action          = include
+
+[/distrib]
+        action          = addmount
+        source          = cbv4-pfds-filer00.vlan-systeme.private:/vol/volmirror/distrib
+        fstype          = nfs
+        options         = rw,nodev,tcp,nosuid,hard,intr,bg
+        mode            = 0750
+
+[/var/lib/cvs/repository]
+        action          = addmount
+        source          = cbv4-pfds-filer00.vlan-systeme.private:/vol/volvcs/cvs
+        fstype          = nfs
+        options         = rw,nodev,tcp,nosuid,noexec,hard,intr,bg
+
+
+#
+# Apache config
+#
+
+[/etc/apache2/ports.conf]
+        action          = addfile
+        source          = CONFIG:spawn%SECTIONNAME%
+        filter          = filter_privateresolve %SOURCE% %HOSTNAME% %DESTINATION%
+        mode            = 0644
+        owner           = root
+        group           = root
+        on_noaction     = true
+        after_change    = /etc/init.d/apache2 reload
+
+[/etc/apache2/sites-available/default]
+        depends         = /etc/apache2/ports.conf
+        action          = addfile
+        source          = CONFIG:spawn%SECTIONNAME%
+        filter          = filter_privateresolve %SOURCE% %HOSTNAME% %DESTINATION%
+        mode            = 0644
+        owner           = root
+        group           = root
+        on_noaction     = true
+        after_change    = /etc/init.d/apache2 reload
+
+[/var/www/debian]
+        depends         = /etc/apache2/sites-available/default /distrib
+        action          = addlink
+        source          = /distrib/official-mirrors/debian
+
+[/var/www/debian-security]
+        depends         = /etc/apache2/sites-available/default /distrib
+        action          = addlink
+        source          = /distrib/official-mirrors/debian-security
+
+[/var/www/debian-custom]
+        depends         = /etc/apache2/sites-available/default /distrib
+        action          = addlink
+        source          = /distrib/debian-custom
+
+[/var/www/debian-backports]
+        depends         = /etc/apache2/sites-available/default /distrib
+        action          = addlink
+        source          = /distrib/official-mirrors/debian-backports
+        
+[dhcp]
+        action          = actiongroup
+        on_noaction     = umask 022; mk_pxelinuxcfg GLOBAL:private-network /distrib/tftpboot/pxelinux.cfg/template
+        after_change    = umask 022; mk_pxelinuxcfg GLOBAL:private-network /distrib/tftpboot/pxelinux.cfg/template && /etc/init.d/dhcp3-server restart
+
diff -r 92e3151737a4 -r 5471a7ec2b40 t/13.conf.cfg1/config-export/SITE/cbv4-pfds/MODEL/model-cbv4-pfds
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/t/13.conf.cfg1/config-export/SITE/cbv4-pfds/MODEL/model-cbv4-pfds	Mon Oct 11 11:37:16 2010 +0200
@@ -0,0 +1,36 @@
+[boot]
+    kernel      = vmlinuz-2.6.26.5-universal-grm2.1.12
+    kerneluml   = linux-uml-elf-2.4.26-gr1.9.15
+    pxefilename = pxelinux.0
+    console     = default
+#   cmdline     = pci=bfsort
+
+[dns]
+    shortname   = vlan-systeme
+    resolver    = nsprivate.private,spawn.private
+
+[interface::eth5]
+    vlan        = vlan-middledsi
+
+[deployment]
+    mode        = debian
+    arch        = amd64
+    distrib     = lenny
+
+[interface::eth0]
+    vlan        = vlan-systeme
+
+[hostgroup]
+    comment     = Model for cbv4-pfds servers
+    site        = cbv4-pfds
+
+[interface::eth4]
+    vlan        = vlan-admindsi
+
+[interface::bond0]
+    options     = miimon=100
+    mode        = active-backup
+    slaves      = eth2,eth3
+    @route      = default via GATEWAY
+    vlan        = vlan-pfds-ext
+
diff -r 92e3151737a4 -r 5471a7ec2b40 t/13.conf.cfg1/etc/pf-tools.1.conf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/t/13.conf.cfg1/etc/pf-tools.1.conf	Mon Oct 11 11:37:16 2010 +0200
@@ -0,0 +1,31 @@
+[path]
+    status_dir      = /tmp/pf-test/var/lib/pf-tools
+    distrib_dir     = /tmp/pf-test/distrib
+    tftp_dir        = /tmp/pf-test/distrib/tftpboot
+    pxefiles_dir    = /tmp/pf-test/distrib/tftpboot/pxelinux.cfg
+    global_struct   = /tmp/pf-test/var/lib/pf-tools/global.stor
+    deploy_docroot  = /tmp/pf-test/var/www
+    preseed_dir     = /tmp/pf-test/var/www/preseed
+    checkout_dir    = /tmp/pf-test/var/lib/cvsguest
+    templates_dir   = /tmp/pf-test/usr/share/pf-tools/templates
+    common_config   = update-common
+    start_file      = private-network
+
+[features]
+    ipv4            = 1
+    ipv6            = 0
+    update          = 1
+
+[vcs]
+    type            = cvs
+    vcsroot         = /tmp/pf-test/var/lib/cvs/repository
+    module          = config
+
+[location]
+    site            = cbv4-pfds
+    zone            = private
+    foo             = bar
+
+[foo]
+    ignored         = 1
+
diff -r 92e3151737a4 -r 5471a7ec2b40 t/13.conf.t
--- a/t/13.conf.t	Mon Oct 04 19:29:19 2010 +0200
+++ b/t/13.conf.t	Mon Oct 11 11:37:16 2010 +0200
@@ -3,11 +3,13 @@
 use strict;
 use warnings;
 
+use Cwd;
 use English qw( -no_match_vars );    # Avoids regex performance penalty
 use File::Copy;
 use File::Path qw( make_path remove_tree );
 use Hash::Merge::Simple qw( clone_merge merge );
 use IO::File;
+use Sys::Hostname;
 use Test::Exception;
 use Test::More qw( no_plan );
 
@@ -47,7 +49,7 @@
 note('Testing PFTools::Conf::Init_PF_CONFIG');
 can_ok( 'PFTools::Conf', qw( Init_PF_CONFIG ) );
 
-my $default_pf_config = $PFTools::Conf::PF_CONFIG;
+my $default_pf_config = $PFTools::Conf::DEFAULT_PF_CONFIG;
 ok defined $default_pf_config
     => '$PF_CONFIG defined';
 ok ref $default_pf_config eq 'HASH'
@@ -55,8 +57,10 @@
 ok keys %{$default_pf_config}
     => '$PF_CONFIG is a non-empty hashref';
 
-is_deeply Init_PF_CONFIG(), $default_pf_config
-    => 'Returns the default config';
+my $config = Init_PF_CONFIG();
+is_deeply $config, $default_pf_config
+    => q{Returns the default config}
+        or note explain $config;
 
 throws_ok { Init_PF_CONFIG( '/non-existent-file' ) }
     qr{\A ERROR: }xms
@@ -87,7 +91,7 @@
     => 'Dies with error message if configuration file has bad permissions';
 
 chmod 0600, $test_config_file
-    or die "chmod: $OS_ERROR";
+    or die qq{chmod $test_config_file: $OS_ERROR};
 
 my $parsed_configuration = Init_PF_CONFIG( $test_config_file );
 ok ref $parsed_configuration eq 'HASH' && keys %{$parsed_configuration}
@@ -100,6 +104,47 @@
 
 unlink $test_config_file
     or die "unlink $test_config_file: $OS_ERROR";
+
+$test_config_file = 't/13.conf.cfg1/etc/pf-tools.1.conf';
+
+# Make sure the permissions are correct before using it
+chmod 0600, $test_config_file
+    or die qq{chmod $test_config_file: $OS_ERROR};
+
+$test_configuration = {
+    path => {
+        status_dir      => q{/tmp/pf-test/var/lib/pf-tools},
+        distrib_dir     => q{/tmp/pf-test/distrib},
+        tftp_dir        => q{/tmp/pf-test/distrib/tftpboot},
+        pxefiles_dir    => q{/tmp/pf-test/distrib/tftpboot/pxelinux.cfg},
+        global_struct   => q{/tmp/pf-test/var/lib/pf-tools/global.stor},
+        deploy_docroot  => q{/tmp/pf-test/var/www},
+        preseed_dir     => q{/tmp/pf-test/var/www/preseed},
+        checkout_dir    => q{/tmp/pf-test/var/lib/cvsguest},
+        templates_dir   => q{/tmp/pf-test/usr/share/pf-tools/templates},
+        common_config   => q{update-common},
+        start_file      => q{private-network},
+    },
+    vcs => {
+        vcsroot         => q{/tmp/pf-test/var/lib/cvs/repository},
+    },
+    location => {
+        site            => q{cbv4-pfds},
+        zone            => q{private},
+    },
+};
+$expected_configuration = merge( $default_pf_config, $test_configuration );
+$parsed_configuration = Init_PF_CONFIG( $test_config_file );
+is_deeply $parsed_configuration, $expected_configuration
+    => qq{File $test_config_file correctly merged with the default configuration}
+    or note explain $parsed_configuration;
+
+# Restore the default configuration for the other tests
+$parsed_configuration = Init_PF_CONFIG();
+is_deeply $parsed_configuration, $default_pf_config
+    => q{Correctly restores the default configuration}
+    or note explain $parsed_configuration;
+
 
 ########################################################################
 note('Testing PFTools::Conf::Init_SUBST');
@@ -360,9 +405,308 @@
     qr{ \A ERROR: [ ] Invalid [ ] context [ ] }xms
     => q{Dies if invalid $context};
 
-throws_ok { Load_conf( 'inexistent file', {}, 'config', {} ) }
+throws_ok { Load_conf( 'inexistent file', {}, 'config', $pf_config ) }
     qr{ \A ERROR: [ ] Unable [ ] to [ ] load [ ] }xms
     => q{Dies if inexistent $file};
 
-diag( 'FIXME: other tests needed here for Load_conf() with real files and contexts' );
+# Let's go back to our test configuration
+$test_config_file = 't/13.conf.cfg1/etc/pf-tools.1.conf';
+my $test_pf_config = Init_PF_CONFIG( $test_config_file ); # already tested OK above
 
+my $cwd = getcwd;
+my $test_config_dir = qq{$cwd/t/13.conf.cfg1};
+my $test_hostname = hostname;
+my $test_hash_subst = Init_SUBST($test_hostname, undef, $test_pf_config, 'private');
+
+# FIXME bypass cvs/svn/whatever for the moment
+unlink q{/tmp/pf-test/var/lib/cvsguest/config};
+make_path( q{/tmp/pf-test/var/lib/cvsguest} );
+symlink qq{$cwd/t/13.conf.cfg1/config-export}, q{/tmp/pf-test/var/lib/cvsguest/config}
+    or diag qq{symlink: $OS_ERROR};
+
+$parsed_configuration = Load_conf( q{COMMON:private-network}, $test_hash_subst,
+    q{network}, $test_pf_config );
+
+ok ref $parsed_configuration eq 'HASH'
+    => q{Returns a hashref};
+
+$expected_configuration = {
+    '__sections_order' => [
+        'private',
+        'cbv4-pfds',
+        'cbv4',
+        'vip-spawn',
+        'cbv4-pfds-filer%%',
+        'vlan-systeme',
+        'vlan-pfds-int',
+        'vlan-pfds-ext',
+        'vlan-admindsi',
+        'vlan-middledsi',
+        'admins',
+    ],
+    'admins' => {
+        '@host' => [
+            'CONFSITE_cbv4-pfds:/hostfile-cbv4-spawn',
+        ],
+        'comment' => 'Administration hosts',
+        'site'    => 'cbv4-pfds',
+        'type'    => 'service',
+    },
+    'cbv4' => {
+        'coment'   => 'CBV4 POP',
+        'console'  => 'default',
+        'dhcpvlan' => 'vlan-systeme',
+        'location' => 'Courbevoie',
+        'room'     => 'CBV4 Room Name',
+        'state'    => 'EDGE',
+        'type'     => 'site',
+        'zone'     => 'private',
+    },
+    'cbv4-pfds' => {
+        'coment'   => 'CBV4-PFDS root site',
+        'console'  => 'default',
+        'dhcpvlan' => 'vlan-systeme',
+        'location' => 'Courbevoie',
+        'room'     => 'CBV4-PFDS Room Name',
+        'state'    => 'ROOT',
+        'type'     => 'site',
+        'zone'     => 'private',
+    },
+    'cbv4-pfds-filer%%' => {
+        'comment'           => 'NAS for CBV4-PFDS site',
+        'ipv4.vlan-systeme' => '2.0',
+        'number'            => '2',
+        'order'             => '2',
+        'shortname'         => 'vlan-systeme ',
+        'site'              => 'cbv4-pfds',
+        'type'              => 'server',
+    },
+    'private' => {
+        '@mx' => [
+            '1       mf.private.',
+            '2       mf00.private.',
+            '2       mf01.private.',
+        ],
+        '@ns' => [
+            'deploy00.vlan-systeme.private.',
+            'deploy01.vlan-systeme.private.',
+        ],
+        'comment' => 'Internal management zone',
+        'console' => 'ttyS0,115200n8',
+        'expire'  => '7D      ; Expire (7 days)',
+        'mail'    => 'dnsmaster at private',
+        'negttl'  => '1H      ; Negative TTL (1 hours)',
+        'refresh' => '6H      ; Refresh (6 hours)',
+        'retry'   => '1H      ; Retry (1 hour)',
+        'serial'  => 'AUTO',
+        'soa'     => 'Deploy00.private.',
+        'ttl'     => '1D      ; TTL (1 day)',
+        'type'    => 'zone',
+    },
+    'vip-spawn' => {
+        'alias.cvs'          => 'vlan-systeme',
+        'alias.mf'           => 'vlan-systeme',
+        'alias.mirrors'      => 'vlan-systeme',
+        'alias.nscache'      => 'vlan-systeme',
+        'alias.nsprivate'    => 'vlan-systeme',
+        'alias.vip-deploy'   => 'vlan-systeme',
+        'comment'            => 'VIP for spawn services',
+        'ipv4.vlan-pfds-ext' => '99',
+        'ipv4.vlan-systeme'  => '1.254',
+        'number'             => '1',
+        'order'              => '2',
+        'shortname'          => 'vlan-systeme',
+        'site'               => 'cbv4-pfds',
+        'type'               => 'server',
+    },
+    'vlan-admindsi' => {
+        'gateway' => '254',
+        'network' => '10.3.1.0/24',
+        'scope'   => 'private',
+        'site'    => 'cbv4-pfds',
+        'tag'     => '302',
+        'type'    => 'network',
+    },
+    'vlan-middledsi' => {
+        'gateway' => '254',
+        'network' => '10.3.2.0/24',
+        'scope'   => 'private',
+        'site'    => 'cbv4-pfds',
+        'tag'     => '372',
+        'type'    => 'network',
+    },
+    'vlan-pfds-ext' => {
+        'comment' => 'something really interesting',
+        'gateway' => '254',
+        'network' => '192.168.1.0/24',
+        'scope'   => 'public',
+        'site'    => 'cbv4-pfds',
+        'tag'     => '40',
+        'type'    => 'network',
+    },
+    'vlan-pfds-int' => {
+        'network' => '10.2.0.0/16',
+        'scope'   => 'private',
+        'site'    => 'cbv4-pfds',
+        'tag'     => '39',
+        'type'    => 'network',
+    },
+    'vlan-systeme' => {
+        'network' => '10.1.0.0/16',
+        'scope'   => 'private',
+        'site'    => 'cbv4, cbv4-pfds',
+        'tag'     => '13',
+        'type'    => 'network',
+    },
+};
+
+is_deeply $parsed_configuration, $expected_configuration
+    => q{Returns the expected configuration hash in network context}
+    or note explain $parsed_configuration;
+
+
+$parsed_configuration = Load_conf( q{CONFSITE_cbv4-pfds:/hostfile-cbv4-spawn}, $test_hash_subst,
+    q{host}, $test_pf_config );
+$expected_configuration = {
+    '__sections_order' => [
+        'boot',
+        'dns',
+        'interface::eth5',
+        'deployment',
+        'interface::eth0',
+        'hostgroup',
+        'interface::eth4',
+        'interface::bond0',
+    ],
+    'boot' => {
+        'console'     => 'default',
+        'kernel'      => 'vmlinuz-2.6.26.5-universal-grm2.1.12',
+        'kerneluml'   => 'linux-uml-elf-2.4.26-gr1.9.15',
+        'pxefilename' => 'pxelinux.0',
+    },
+    'deployment' => {
+        'arch'    => 'amd64',
+        'distrib' => 'lenny',
+        'mode'    => 'debian',
+    },
+    'dns' => {
+        'alias.ntp'   => 'vlan-systeme',
+        'alias.spawn' => 'vlan-systeme',
+        'resolver'    => 'nsprivate.private,spawn.private',
+        'shortname'   => 'vlan-systeme',
+    },
+    'hostgroup' => {
+        'comment'  => 'Spawning server',
+        'hostname' => 'cbv4-spawn%%',
+        'model'    => 'MODSITE_cbv4-pfds:/model-cbv4-pfds',
+        'number'   => '2',
+        'order'    => '1',
+        'site'     => 'cbv4-pfds',
+    },
+    'interface::bond0' => {
+        '@route' => [
+            'default via GATEWAY',
+        ],
+        'ipv4'    => '97',
+        'mode'    => 'active-backup',
+        'options' => 'miimon=100',
+        'slaves'  => 'eth2,eth3',
+        'vlan'    => 'vlan-pfds-ext',
+    },
+    'interface::eth0' => {
+        'ipv4'  => '167.0',
+        'mac.0' => '00:1e:c9:ff:08:e3',
+        'mac.1' => '00:1e:c9:ff:42:0a',
+        'vlan'  => 'vlan-systeme',
+    },
+    'interface::eth4' => {
+        'ipv4' => '41',
+        'vlan' => 'vlan-admindsi',
+    },
+    'interface::eth5' => {
+        'ipv4' => '41',
+        'vlan' => 'vlan-middledsi',
+    },
+};
+
+is_deeply $parsed_configuration, $expected_configuration
+    => q{Returns the expected configuration hash in host context}
+    or note explain $parsed_configuration;
+
+$parsed_configuration = Load_conf( q{MODSITE_cbv4-pfds:/model-cbv4-pfds}, $test_hash_subst,
+    q{model}, $test_pf_config );
+$expected_configuration = {
+    '__sections_order' => [
+        'boot',
+        'dns',
+        'interface::eth5',
+        'deployment',
+        'interface::eth0',
+        'hostgroup',
+        'interface::eth4',
+        'interface::bond0',
+    ],
+    'boot' => {
+        'console'     => 'default',
+        'kernel'      => 'vmlinuz-2.6.26.5-universal-grm2.1.12',
+        'kerneluml'   => 'linux-uml-elf-2.4.26-gr1.9.15',
+        'pxefilename' => 'pxelinux.0',
+    },
+    'deployment' => {
+        'arch'    => 'amd64',
+        'distrib' => 'lenny',
+        'mode'    => 'debian',
+    },
+    'dns' => {
+        'resolver'  => 'nsprivate.private,spawn.private',
+        'shortname' => 'vlan-systeme',
+    },
+    'hostgroup' => {
+        'comment' => 'Model for cbv4-pfds servers',
+        'site'    => 'cbv4-pfds',
+    },
+    'interface::bond0' => {
+        '@route' => [
+            'default via GATEWAY',
+        ],
+        'mode'    => 'active-backup',
+        'options' => 'miimon=100',
+        'slaves'  => 'eth2,eth3',
+        'vlan'    => 'vlan-pfds-ext',
+    },
+    'interface::eth0' => {
+        'vlan' => 'vlan-systeme',
+    },
+    'interface::eth4' => {
+        'vlan' => 'vlan-admindsi',
+    },
+    'interface::eth5' => {
+        'vlan' => 'vlan-middledsi',
+    },
+};
+is_deeply $parsed_configuration, $expected_configuration
+    => q{Returns the expected configuration hash in model context}
+    or note explain $parsed_configuration;
+
+
+# FIXME contexts: config
+diag( qq{FIXME: add other files in $test_config_dir to test Load_conf() with real files and other contexts} );
+
+remove_tree( q{/tmp/pf-test} );
+
+__END__
+
+# Directories referenced in the test configuration
+my @test_dirs = qw(
+    /tmp/pf-test/var/lib/pf-tools
+    /tmp/pf-test/distrib
+    /tmp/pf-test/distrib/tftpboot
+    /tmp/pf-test/distrib/tftpboot/pxelinux.cfg
+    /tmp/pf-test/var/www
+    /tmp/pf-test/var/www/preseed
+    /tmp/pf-test/var/lib/cvsguest
+    /tmp/pf-test/usr/share/pf-tools/templates
+);
+make_path( @test_dirs );
+remove_tree( q{/tmp/pf-test} );
+



More information about the pf-tools-commits mailing list