pf-tools/pf-tools: 3 new changesets

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Tue Dec 16 10:12:21 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/a5b887812150
changeset: 1394:a5b887812150
user:      melkor <melkor at sitadelle.com>
date:      Tue Dec 16 10:02:23 2014 +0100
description:
add interfaces template

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/542ccf700e53
changeset: 1395:542ccf700e53
user:      melkor <melkor at sitadelle.com>
date:      Tue Dec 16 11:11:54 2014 +0100
description:
add tests for interfaces.tpl

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/ccbee86be4fc
changeset: 1396:ccbee86be4fc
user:      melkor <melkor at sitadelle.com>
date:      Tue Dec 16 11:12:18 2014 +0100
description:
merge

diffstat:

 debian/control                                      |    2 +-
 doc/updatefile-syntax                               |   14 +-
 lib/PFTools/Parser.pm                               |    2 +-
 lib/PFTools/Update/ADDMOUNT.pm                      |   52 ++--
 t/13.conf.cfg1/config-export/COMMON/private-network |   16 +-
 t/13.conf.t                                         |   89 ++++++++-
 t/20.files.t                                        |   11 +
 t/21.interfaces.input                               |   48 ++++
 t/21.interfaces.input.1                             |   15 +
 t/21.interfaces.output                              |   46 ++++
 t/21.interfaces.tpl.t                               |  220 ++++++++++++++++++++
 t/31.addmount.t                                     |   18 +-
 templates/interfaces.tpl                            |   75 ++++++
 13 files changed, 576 insertions(+), 32 deletions(-)

diffs (813 lines):

diff -r 5ec9718235d3 -r ccbee86be4fc debian/control
--- a/debian/control	Mon Dec 15 15:45:31 2014 +0100
+++ b/debian/control	Tue Dec 16 11:12:18 2014 +0100
@@ -8,7 +8,7 @@
 
 Package: pf-tools
 Architecture: all
-Depends: perl, perl (>= 5.10.0) | libmd5-perl, libclone-perl, libconfig-inifiles-perl, liblist-moreutils-perl, libhash-merge-simple-perl, libmodule-runtime-perl, libnetaddr-ip-perl, libnet-dns-perl, libproc-reliable-perl, libreadonly-xs-perl, libreadonly-xs-perl, libregexp-common-perl, libtemplate-tiny-perl, libtext-diff-perl, mercurial | subversion | cvs , ssh, iproute | iproute2, debconf, psmisc
+Depends: perl, perl (>= 5.10.0) | libmd5-perl, libclone-perl, libconfig-inifiles-perl, liblist-moreutils-perl, libhash-merge-simple-perl, libmodule-runtime-perl, libnetaddr-ip-perl, libnet-dns-perl, libproc-reliable-perl, libreadonly-xs-perl, libreadonly-xs-perl, libregexp-common-perl, libtemplate-perl, libtemplate-tiny-perl, libtext-diff-perl, mercurial | subversion | cvs , ssh, iproute | iproute2, debconf, psmisc
 Description: Outils de gestion de la plateforme
  Mise a jour automatique et generation de conf.
  Deploiement de machines.
diff -r 5ec9718235d3 -r ccbee86be4fc doc/updatefile-syntax
--- a/doc/updatefile-syntax	Mon Dec 15 15:45:31 2014 +0100
+++ b/doc/updatefile-syntax	Tue Dec 16 11:12:18 2014 +0100
@@ -177,7 +177,6 @@
 	! action		::= include
 						there are some shortcut defined that resolve to path relatively to VCS root
 						and 'module' defined in pf-tool.conf file
-						 - AUTO:                  try to resolve in order to: 
 						 - CONFIG:                resolve to	/module/CONFIG/
 						 - CONFIGSITE:            resolve to	/module/SITE/pop/CONFIG/	(if the hosttype of machine is pop-bar)
 						 - CONFIGSITE_foo:        resolve to	/module/SITE/foo/CONFIG/
@@ -203,3 +202,16 @@
 						 - SHORTHOSTNAMESITE:     resolve to	/module/SITE/pop/FILE/bar00/	(if the hostname of machine is pop-bar00)
 						 - SHORTHOSTNAMESITE_foo: resolve to	/module/SITE/foo/FILE/bar00/	(if the hostname of machine is pop-bar00)
 						 - ROOT:                  resolve to	/module/
+
+						 - AUTO:                  try to resolve in order to:
+								HOSTNAMESITE:		/SITE/pop/FILE/pop-bar00/
+								HOSTSITE:		/SITE/pop/FILE/pop-bar/
+								HOSTNAME:		/FILE/pop-bar00/
+								HOST:			/FILE/pop-bar/
+								SHORTHOSTNAMESITE:	/SITE/pop/FILE/bar00/
+								SHORTHOSTSITE:		/SITE/pop/FILE/bar
+								FILESITE:common		/SITE/pop/FILE/common/
+								SHORTHOSTNAME: 		/FILE/bar00/
+								SHORTHOST:		/FILE/bar/
+								FILE:common		/FILE/common/
+
diff -r 5ec9718235d3 -r ccbee86be4fc lib/PFTools/Parser.pm
--- a/lib/PFTools/Parser.pm	Mon Dec 15 15:45:31 2014 +0100
+++ b/lib/PFTools/Parser.pm	Tue Dec 16 11:12:18 2014 +0100
@@ -30,7 +30,7 @@
 
 our @EXPORT_OK = qw( parse_ini );
 
-my $trailing_comment_regex = qr{ \s+ [#] .* \z }xms;
+my $trailing_comment_regex = qr{  \s+ (:? [#] .* )? \z }xms;
 
 sub parse_ini {
     my ($file) = @_;
diff -r 5ec9718235d3 -r ccbee86be4fc lib/PFTools/Update/ADDMOUNT.pm
--- a/lib/PFTools/Update/ADDMOUNT.pm	Mon Dec 15 15:45:31 2014 +0100
+++ b/lib/PFTools/Update/ADDMOUNT.pm	Tue Dec 16 11:12:18 2014 +0100
@@ -72,20 +72,15 @@
 sub __get_ip_host_from_global {
     my ( $host, $global_config ) = @_;
 
-    my ( $zone, $hostshort, $hostvlan );
-
     if ( isipaddr($host) ) {
         return $host;
     }
 
-    if ( $host =~ m{\A ([^.]+)\.}xms ) {
-        $host = $1;
-    }
+    my ( $zone, $hostshort, $hostvlan );
+    my $ip = $host;
 
-    my $hosttype = get_hosttype_from_hostname( $host, $global_config );
-    my $site_list = get_site_list_from_hostname( $host, $global_config );
-    my $site = shift @{$site_list};
-
+    my $pf_config = init_pf_config();
+    my $site      = $pf_config->{'location'}->{'site'};
     if ( $host =~ m{\A ( [^.]+ ) (?: [.].* )? \z}xms ) {
         $zone = get_zone_from_hostname( $1, $global_config, $site );
     }
@@ -94,23 +89,34 @@
         return;
     }
 
-    my $resolved = resolve_hostname_from_global_config(
-        {   hostname      => $host,
-            global_config => $global_config,
-            site_name     => $site,
-            zone_name     => $zone,
-            hosttype      => $hosttype,
+    $ip =~ s{[.]$zone \z}{}xms;
+    if ( $ip =~ m{\A ( [^.]+ ) (?: [.]([^.]+) )? \z}xms ) {
+        ( $hostshort, $hostvlan ) = ( $1, $3 );
+    }
+    else {
+        carp qq{ERROR: can't extract hostshort and hostvlan from $ip};
+    }
+    my $hosttype = get_hosttype_from_hostname( $hostshort, $global_config );
 
-            # FIXME ip_type => ????,
+    if ( !isipaddr($ip) ) {
+        my $resolved = resolve_hostname_from_global_config(
+            {   hostname      => $ip,
+                global_config => $global_config,
+                site_name     => $site,
+                zone_name     => $zone,
+                hosttype      => $hosttype,
+
+                # FIXME ip_type => ????,
+            }
+        );
+        if ( !defined $resolved || scalar @{$resolved} > 1 ) {
+            carp qq{ERROR: Unknown or multiple IPs for $host};
+            return;
         }
-    );
-    if ( !defined $resolved || scalar @{$resolved} > 1 ) {
-        carp qq{ERROR: Unknown or multiple IPs for $host};
-        return;
+        else {
+            $ip = shift @{$resolved};
+        }
     }
-
-    my $ip = shift @{$resolved};
-
     return $ip;
 }
 
diff -r 5ec9718235d3 -r ccbee86be4fc t/13.conf.cfg1/config-export/COMMON/private-network
--- a/t/13.conf.cfg1/config-export/COMMON/private-network	Mon Dec 15 15:45:31 2014 +0100
+++ b/t/13.conf.cfg1/config-export/COMMON/private-network	Tue Dec 16 11:12:18 2014 +0100
@@ -41,7 +41,7 @@
 [vip-spawn]
     type                = server
     site                = cbv4-pfds
-    comment             = VIP for spawn services
+    comment             = VIP for spawn services 
     order               = 2
     number              = 1
     ipv4.vlan-systeme   = 1.254
@@ -51,8 +51,9 @@
     alias.cvs           = vlan-systeme
     alias.nsprivate     = vlan-systeme
     alias.nscache       = vlan-systeme
-    alias.mf            = vlan-systeme
-    alias.vip-deploy    = vlan-systeme
+    alias.mf            = vlan-systeme # with trailing comment
+    # with trailing space
+    alias.vip-deploy    = vlan-systeme  
 
 [cbv4-pfds-filer%%]
     type                = server
@@ -81,6 +82,15 @@
     ipv4.vlan-systeme   = 2.20
     shortname           = vlan-systeme
 
+[filer-other%%]
+    type                = server
+    site                = cbv4
+    comment             = filer with ip public on other site
+    order               = 2
+    number              = 2
+    ipv4.vlan-public2   = 30
+    shortname           = vlan-public2
+
 [COMMON:/network-common]
     type    = include
 
diff -r 5ec9718235d3 -r ccbee86be4fc t/13.conf.t
--- a/t/13.conf.t	Mon Dec 15 15:45:31 2014 +0100
+++ b/t/13.conf.t	Tue Dec 16 11:12:18 2014 +0100
@@ -523,6 +523,7 @@
         'cbv4-pfds-filer%%',
         'filer-all%%',
         'filer-several%%',
+        'filer-other%%',
         'vlan-systeme',
         'vlan-pfds-int',
         'vlan-public',
@@ -596,6 +597,15 @@
         'site'              => 'cbv4-pfds, cbv4',
         'type'              => 'server',
     },
+    'filer-other%%' => {
+        'comment'           => 'filer with ip public on other site',
+        'ipv4.vlan-public2' => '30',
+        'number'            => '2',
+        'order'             => '2',
+        'shortname'         => 'vlan-public2',
+        'site'              => 'cbv4',
+        'type'              => 'server',
+    },
     'private' => {
         '@mx' => [
             '1	mf.private.',
@@ -1387,6 +1397,34 @@
                                     }
                             },
                         },
+                        'filer-other' => {
+                            'filer-other01' => {
+                                'interfaces' => {
+                                    'eth0' => {
+                                        'ipv4' => '80.125.164.31/24',
+                                        'vlan' => 'vlan-public2'
+                                    },
+                                },
+                                'deployment' => {
+                                    'hosttype'       => 'filer-other',
+                                    'order'          => '2',
+                                    'hostname_model' => 'filer-other%%'
+                                }
+                            },
+                            'filer-other00' => {
+                                'interfaces' => {
+                                    'eth0' => {
+                                        'ipv4' => '80.125.164.30/24',
+                                        'vlan' => 'vlan-public2',
+                                    },
+                                },
+                                'deployment' => {
+                                    'hosttype'       => 'filer-other',
+                                    'order'          => '2',
+                                    'hostname_model' => 'filer-other%%'
+                                }
+                            },
+                        },
                         'filer-all' => {
                             'filer-all01' => {
                                 'interfaces' => {
@@ -1424,6 +1462,8 @@
                         '10.1.2.11/16' => 'filer-all01.vlan-systeme',
                         '10.1.2.20/16' => 'filer-several00.vlan-systeme',
                         '10.1.2.21/16' => 'filer-several01.vlan-systeme',
+                        '80.125.164.30/24' => 'filer-other00.vlan-public2',
+                        '80.125.164.31/24' => 'filer-other01.vlan-public2',
                         '10.1.167.0/16' => 'cbv4-rdeploy00.vlan-systeme',
                         '10.1.167.1/16' => 'cbv4-rdeploy01.vlan-systeme',
                         '80.125.163.42/24' => 'cbv4-rdeploy00.vlan-public',
@@ -1504,6 +1544,7 @@
                 'ALL_SITES' => {
                     '__hostclass_order' => [
                         'vip-spawn',
+                        'filer-other',
                         'cbv4-spawn',
                         'cbv4-rdeploy',
                     ],
@@ -1560,6 +1601,19 @@
                                                 'A	80.125.164.44',
                         ],
                     },
+                    'filer-other' => {
+                        'filer-other' => 'CNAME	filer-other.vlan-public2',
+                        'filer-other00' => 'CNAME	filer-other00.vlan-public2',
+                        'filer-other01' => 'CNAME	filer-other01.vlan-public2',
+                        'filer-other00.vlan-public2' => 'A	80.125.164.30',
+                        'filer-other01.vlan-public2' => 'A	80.125.164.31',
+                        'number'    => 2,
+                        'comment'   => 'filer with ip public on other site',
+                        'filer-other.vlan-public2'   => [
+                            'A	80.125.164.30',
+                            'A	80.125.164.31',
+                        ],
+                    },
                 },
                 'BY_SITE' => {
                     'cbv4-pfds' => {
@@ -1802,8 +1856,11 @@
             'cbv4-rdeploy'      => 'cbv4',
         },
         'vlan-public2' => {
-            'cbv4-rdeploy'    => 'cbv4',
+            'cbv4-rdeploy'      => 'cbv4',
             'cbv4-rdeploy00'    => 'cbv4',
+            'filer-other'       => 'cbv4',
+            'filer-other01'     => 'cbv4',
+            'filer-other00'     => 'cbv4',
         },
     }
 };
@@ -2380,6 +2437,34 @@
                     }
                 },
             },
+            'filer-other' => {
+                'filer-other01' => {
+                    'interfaces' => {
+                        'eth0' => {
+                            'ipv4' => '80.125.164.31/24',
+                            'vlan' => 'vlan-public2'
+                        },
+                    },
+                    'deployment' => {
+                        'hosttype'       => 'filer-other',
+                        'order'          => '2',
+                        'hostname_model' => 'filer-other%%'
+                    }
+                },
+                'filer-other00' => {
+                    'interfaces' => {
+                        'eth0' => {
+                            'ipv4' => '80.125.164.30/24',
+                            'vlan' => 'vlan-public2',
+                        },
+                    },
+                    'deployment' => {
+                        'hosttype'       => 'filer-other',
+                        'order'          => '2',
+                        'hostname_model' => 'filer-other%%'
+                    }
+                },
+            },
         },
 
         '__hostclass_pxe' => [
@@ -2390,6 +2475,8 @@
             '10.1.2.11/16' => 'filer-all01.vlan-systeme',
             '10.1.2.20/16' => 'filer-several00.vlan-systeme',
             '10.1.2.21/16' => 'filer-several01.vlan-systeme',
+            '80.125.164.30/24' => 'filer-other00.vlan-public2',
+            '80.125.164.31/24' => 'filer-other01.vlan-public2',
             '10.1.167.0/16' => 'cbv4-rdeploy00.vlan-systeme',
             '10.1.167.1/16' => 'cbv4-rdeploy01.vlan-systeme',
             '80.125.163.42/24' => 'cbv4-rdeploy00.vlan-public',
diff -r 5ec9718235d3 -r ccbee86be4fc t/20.files.t
--- a/t/20.files.t	Mon Dec 15 15:45:31 2014 +0100
+++ b/t/20.files.t	Tue Dec 16 11:12:18 2014 +0100
@@ -258,6 +258,17 @@
     qq{spawn00\tIN CNAME\tcbv4-spawn00.vlan-systeme},
     qq{spawn01\tIN CNAME\tcbv4-spawn01.vlan-systeme},
     q{},
+    q{; filer-other: filer with ip public on other site},
+    q{; number: 2},
+    q{;----------------------------------------------------------------------------},
+    qq{filer-other\tIN CNAME\tfiler-other.vlan-public2},
+    qq{filer-other.vlan-public2\tIN A\t80.125.164.30},
+    qq{filer-other.vlan-public2\tIN A\t80.125.164.31},
+    qq{filer-other00\tIN CNAME\tfiler-other00.vlan-public2},
+    qq{filer-other00.vlan-public2\tIN A\t80.125.164.30},
+    qq{filer-other01\tIN CNAME\tfiler-other01.vlan-public2},
+    qq{filer-other01.vlan-public2\tIN A\t80.125.164.31},
+    q{},
     q{; cbv4-rdeploy: Rdeploy server},
     q{; number: 2},
     q{;----------------------------------------------------------------------------},
diff -r 5ec9718235d3 -r ccbee86be4fc t/21.interfaces.input
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/t/21.interfaces.input	Tue Dec 16 11:12:18 2014 +0100
@@ -0,0 +1,48 @@
+#
+# This file was auto-generated by mk_interfaces -- DO NOT EDIT!
+#
+
+auto lo
+iface lo inet loopback
+
+auto eth0
+iface eth0 inet static
+    address     10.128.2.3
+    netmask     255.255.0.0
+    network     10.128.0.0
+    broadcast   10.128.255.255
+    dns-search  private
+    dns-nameservers 10.128.2.5
+
+auto eth1
+iface eth1 inet static
+    address     10.144.2.3
+    netmask     255.255.0.0
+    network     10.144.0.0
+    broadcast   10.144.255.255
+
+auto eth2
+iface eth2 inet static
+    address     109.3.20.226
+    netmask     255.255.255.224
+    network     109.3.20.224
+    broadcast   109.3.20.255
+    gateway     109.3.20.254
+
+iface eth2 inet6 static
+    address     2001:db8::c0ca:1eaf
+    netmask     64
+    gateway     2001:db8::1ead:ed:beef
+
+auto bond0
+iface bond0 inet static
+    address 10.31.1.5
+    netmask 255.255.255.0
+    network 10.31.1.0
+    gateway 10.31.1.254
+    slaves eth0 eth1
+    bond_mode active-backup
+    bond_miimon 100
+    bond_downdelay 200
+    bond_updelay 200
+
diff -r 5ec9718235d3 -r ccbee86be4fc t/21.interfaces.input.1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/t/21.interfaces.input.1	Tue Dec 16 11:12:18 2014 +0100
@@ -0,0 +1,15 @@
+#
+# This file was auto-generated by mk_interfaces -- DO NOT EDIT!
+#
+
+auto lo
+iface lo inet loopback
+
+auto eth0
+iface eth0 inet static
+    address     10.128.2.3
+    netmask     255.255.0.0
+    network     10.128.0.0
+    broadcast   10.128.255.255
+    dns-search  private
+    dns-nameservers 10.128.2.5
diff -r 5ec9718235d3 -r ccbee86be4fc t/21.interfaces.output
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/t/21.interfaces.output	Tue Dec 16 11:12:18 2014 +0100
@@ -0,0 +1,46 @@
+#
+# This file was auto-generated by mk_interfaces -- DO NOT EDIT!
+#
+
+auto lo
+iface lo inet loopback
+
+auto eth0
+iface eth0 inet static
+    address 10.128.2.3
+    netmask 255.255.0.0
+    network 10.128.0.0
+    broadcast 10.128.255.255
+    dns-search  private
+    dns-nameservers 10.128.2.5
+
+auto eth1
+iface eth1 inet static
+    address 10.144.2.3
+    netmask 255.255.0.0
+    network 10.144.0.0
+    broadcast 10.144.255.255
+
+auto eth2
+iface eth2 inet static
+    address 109.3.20.226
+    netmask 255.255.255.224
+    network 109.3.20.224
+    broadcast 109.3.20.255
+    gateway 109.3.20.254
+iface eth2 inet6 static
+    address 2001:db8::c0ca:1eaf
+    netmask 64
+    gateway 2001:db8::1ead:ed:beef
+
+auto bond0
+iface bond0 inet static
+    address 10.31.1.5
+    netmask 255.255.255.0
+    network 10.31.1.0
+    gateway 10.31.1.254
+    slaves eth0 eth1
+    bond_mode active-backup
+    bond_miimon 100
+    bond_downdelay 200
+    bond_updelay 200
\ No newline at end of file
diff -r 5ec9718235d3 -r ccbee86be4fc t/21.interfaces.tpl.t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/t/21.interfaces.tpl.t	Tue Dec 16 11:12:18 2014 +0100
@@ -0,0 +1,220 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Cwd;
+use Data::Dumper;
+use English qw( -no_match_vars );    # Avoids regex performance penalty
+use File::Basename;
+use File::Copy;
+use Sys::Hostname;
+use Test::Exception;
+use Test::More qw( no_plan );
+use Text::Diff;
+
+use Template;
+
+# example
+#my $args_ref = {
+#    interfaces_list => [
+#        {
+#            name    => q{lo},
+#            auto    => 1,
+##            allow   => [
+##                q{hotplug},
+##            ],
+##            mapping_rules => [
+##                q{map HOME lo-home},
+##                q{map NOTHOME lo-home},
+##            ],
+#            ip => [
+#                {
+#                    type    => q{loopback},
+#                },
+#            ],
+#        },
+#        {
+#            name    => q{eth0},
+#            ip => [
+#                {
+#                    address     => q{10.128.2.3},
+#                    netmask     => q{255.255.0.0},
+#                    network     => q{10.144.0.0},
+#                    broadcast   => q{10.144.255.255},
+#                    custom_rules => [
+#                        q{dns-search  private},
+#                        q{dns-nameservers 10.128.2.5},
+#                    ],
+#                },
+#            ],
+#        },
+#        {
+#            name    => q{eth1},
+#            ip => [
+#                {
+#                    address     => q{10.144.2.3},
+#                    netmask     => q{255.255.0.0},
+#                    network     => q{10.144.0.0},
+#                    broadcast   => q{10.144.255.255},
+#                },
+#            ],
+#        },
+#        {
+#            name    => q{eth2},
+#            ip => [
+#                {
+#                    address     => q{109.3.20.226},
+#                    netmask     => q{255.255.255.224},
+#                    network     => q{109.3.20.224},
+#                    broadcast   => q{109.3.20.255},
+#                    gateway     => q{109.3.20.254},
+#                },
+#                {
+#                    version     => q{inet6},
+#                    address     => q{2002:c000:0203::1},
+#                    netmask     => q{64},
+#                },
+#            ],
+#        },
+#        {
+#            name    => q{eth3},
+#            ip  => [
+#                {
+#                    type    => q{static},
+#                },
+#            ],
+#        },
+#        {
+#            name    => q{eth4},
+#            ip  => [
+#                {
+#                    type    => q{static},
+#                },
+#            ],
+#        },
+#        {
+#            name    => q{bond0},
+#            ip  => [
+#                {
+#                    address     => q{109.3.20.227},
+#                    netmask     => q{255.255.255.224},
+#                    network     => q{109.3.20.224},
+#                    broadcast   => q{109.3.20.255},
+#                    gateway     => q{109.3.20.254},
+#                    custom_rules => [
+#                        q{slaves eth3 eth4},
+#                        q{bond_mode active-backup},
+#                        q{bond_miimon 100},
+#                        q{bond_downdelay 200},
+#                        q{bond_updelay 200},
+#                    ],
+#                },
+#            ],
+#        },
+#    ],
+#    sources_list => [
+#        q{source.d/fichier},
+#    ],
+#    sources_directories_list => [
+#        q{directorie},
+#    ],
+#};
+
+my $template_file = q{templates/interfaces.tpl};
+open my $FH_TPL, '<', $template_file or die $!;
+my $file;
+{
+    local $/;
+    $file = <$FH_TPL>;
+}
+close $FH_TPL;
+
+my $template = Template->new(
+    TRIM => 1,
+);
+
+my $args_ref = {
+    interfaces_list => [
+        {
+            name    => q{lo},
+            auto    => 1,
+            ip => [
+                {
+                    type    => q{loopback},
+                },
+            ],
+        },
+        {
+            name    => q{eth0},
+            ip => [
+                {
+                    address     => q{10.128.2.3},
+                    netmask     => q{255.255.0.0},
+                    network     => q{10.128.0.0},
+                    broadcast   => q{10.128.255.255},
+                    custom_rules => [
+                        q{dns-search  private},
+                        q{dns-nameservers 10.128.2.5},
+                    ],
+                },
+            ],
+        },
+        {
+            name    => q{eth1},
+            ip => [
+                {
+                    address     => q{10.144.2.3},
+                    netmask     => q{255.255.0.0},
+                    network     => q{10.144.0.0},
+                    broadcast   => q{10.144.255.255},
+                },
+            ],
+        },
+        {
+            name    => q{eth2},
+            ip => [
+                {
+                    address     => q{109.3.20.226},
+                    netmask     => q{255.255.255.224},
+                    network     => q{109.3.20.224},
+                    broadcast   => q{109.3.20.255},
+                    gateway     => q{109.3.20.254},
+                },
+                {
+                    version     => q{inet6},
+                    address     => q{2001:db8::c0ca:1eaf},
+                    netmask     => q{64},
+                    gateway     => q{2001:db8::1ead:ed:beef},
+                },
+            ],
+        },
+        {
+            name    => q{bond0},
+            ip  => [
+                {
+                    address     => q{10.31.1.5},
+                    netmask     => q{255.255.255.0},
+                    network     => q{10.31.1.0},
+                    gateway     => q{10.31.1.254},
+                    custom_rules => [
+                        q{slaves eth0 eth1},
+                        q{bond_mode active-backup},
+                        q{bond_miimon 100},
+                        q{bond_downdelay 200},
+                        q{bond_updelay 200},
+                    ],
+                },
+            ],
+        },
+    ],
+};
+
+my $input_file_name     = 't/21.interfaces.input';
+my $output_file_name    = 't/21.interfaces.output';
+
+$template->process(\$file, $args_ref, $output_file_name) or die $template->error();
+
+my $diff = `diff -ubB $input_file_name $output_file_name`;
+
+ok (!$diff, qq{generated $output_file_name looks like $input_file_name});
diff -r 5ec9718235d3 -r ccbee86be4fc t/31.addmount.t
--- a/t/31.addmount.t	Mon Dec 15 15:45:31 2014 +0100
+++ b/t/31.addmount.t	Tue Dec 16 11:12:18 2014 +0100
@@ -111,6 +111,20 @@
     => q{get ip of single site server on specified default network}
         or diag explain $result;
 
+$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'filer-other00', $global_config);
+$expected_result = q{80.125.164.30};
+
+is $result, $expected_result
+    => q{get ip of other site server on default network}
+        or diag explain $result;
+
+$result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( 'filer-other00.vlan-public2.private', $global_config);
+$expected_result = q{80.125.164.30};
+
+is $result, $expected_result
+    => q{get ip of other site server on specified default network}
+        or diag explain $result;
+
 $result = PFTools::Update::ADDMOUNT::__get_ip_host_from_global( '10.128.1.2', $global_config);
 $expected_result = q{10.128.1.2};
 
@@ -188,7 +202,7 @@
         or diag explain $result;
 
 
-my $dest = q{/var/tmp/php-sessions};
+$dest = q{/var/tmp/php-sessions};
 $result = PFTools::Update::ADDMOUNT::__build_fstab_entry_from_config({
     'dest'          => $dest,
     'global_config' => $global_config,
@@ -213,7 +227,7 @@
 is_deeply $result, $expected_result
     => q{built fstab entry from generated conf (tmpfs)}
         or diag explain $result;
-my $fstab_result = build_fstab_from_structure({ $dest => $result, '__mnt_order' => [$dest] });
+$fstab_result = build_fstab_from_structure({ $dest => $result, '__mnt_order' => [$dest] });
 
 $expected_result = [
   qq{###################################################},
diff -r 5ec9718235d3 -r ccbee86be4fc templates/interfaces.tpl
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/interfaces.tpl	Tue Dec 16 11:12:18 2014 +0100
@@ -0,0 +1,75 @@
+#
+# This file was auto-generated by mk_interfaces -- DO NOT EDIT!
+#
+[% IF sources_list -%]
+
+[% FOREACH source IN sources_list -%]
+source [% source %]
+[% END -%]
+[% END -%]
+[% IF sources_directories_list -%]
+
+[% FOREACH source_directories IN sources_directories_list -%]
+source-directory [% source_directories %]
+[% END -%]
+[% END -%]
+[% FOREACH interface IN interfaces_list -%]
+[% DEFAULT interface.auto = 1 -%]
+
+[% IF interface.auto -%]
+auto [% interface.name %]
+[% END -%]
+[% FOREACH allow IN interface.allow -%]
+allow-[% allow %] [% interface.name %]
+[% END -%]
+[% IF interface.mapping_rules -%]
+
+mapping [% interface.name %]
+[% FOREACH mapping_rule IN interface.mapping_rules -%]
+    [% mapping_rule %]
+[% END -%]
+
+[% END -%]
+[% FOREACH ip IN interface.ip -%]
+[% DEFAULT ip.version = 'inet' -%]
+[% DEFAULT ip.type = 'static' -%]
+[% DEFAULT ip.name = interface.name -%]
+iface [% ip.name %] [% ip.version %] [% ip.type %]
+[% IF ip.address -%]
+    address [% ip.address %]
+[% END -%]
+[% IF ip.netmask -%]
+    netmask [% ip.netmask %]
+[% END -%]
+[% IF ip.network -%]
+    network [% ip.network %]
+[% END -%]
+[% IF ip.broadcast -%]
+    broadcast [% ip.broadcast %]
+[% END -%]
+[% IF ip.gateway -%]
+    gateway [% ip.gateway %]
+[% END -%]
+[% FOREACH pre_up IN ip.pre_up -%]
+    pre-up [% pre_up %]
+[% END -%]
+[% FOREACH post_up IN ip.post_up -%]
+    post-up [% post_up %]
+[% END -%]
+[% FOREACH up IN ip.up -%]
+    up [% up %]
+[% END -%]
+[% FOREACH pre_down IN ip.pre_down -%]
+    pre-down [% pre_down %]
+[% END -%]
+[% FOREACH post_down IN ip.post_down -%]
+    post-down [% post_down %]
+[% END -%]
+[% FOREACH down IN ip.down -%]
+    down [% down %]
+[% END -%]
+[% FOREACH rule IN ip.custom_rules -%]
+    [% rule %]
+[% END -%]
+[% END -%]
+[% END -%]



More information about the pf-tools-commits mailing list