pf-tools/pf-tools: 2 new changesets

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Mon Jan 2 10:45:16 UTC 2012


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/3fc2a876b165
changeset: 1180:3fc2a876b165
user:      "Christophe Caillet <quadchris at free.fr>"
date:      Fri Jul 22 14:20:06 2011 +0200
description:
Adding bridge handlers into TODO-list

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/eeaa592fd056
changeset: 1181:eeaa592fd056
user:      "Christophe Caillet <quadchris at free.fr>"
date:      Mon Jan 02 11:35:45 2012 +0100
description:
Merging from central repository

diffstat:

 TODO                         |    1 +
 lib/PFTools/Disk.pm          |    5 +
 lib/PFTools/Structqueries.pm |    8 ++
 lib/PFTools/Utils.pm         |   32 ++--------
 t/13.conf.t                  |  126 ++++++++++++++++++++++++++++++++++++++++--
 t/20.files.t                 |    6 +-
 templates/standard-preseed   |    2 +-
 7 files changed, 145 insertions(+), 35 deletions(-)

diffs (292 lines):

diff -r c2a3bab3aa84 -r eeaa592fd056 TODO
--- a/TODO	Mon Mar 07 17:18:58 2011 +0100
+++ b/TODO	Mon Jan 02 11:35:45 2012 +0100
@@ -1,6 +1,7 @@
 /--Priority: Low/Medium/Urgent
 |/-Difficulty: Easy/Medium/Hard
 ||
+UM adding handlers for bridge interface on hostfile definitions
 LH implementing udev rules for naming iface accordingly with hostfile
    definition if a key mac is defined for the specified hostname
 MH implementing scope for network when building zones
diff -r c2a3bab3aa84 -r eeaa592fd056 lib/PFTools/Disk.pm
--- a/lib/PFTools/Disk.pm	Mon Mar 07 17:18:58 2011 +0100
+++ b/lib/PFTools/Disk.pm	Mon Jan 02 11:35:45 2012 +0100
@@ -125,6 +125,11 @@
         next if $line =~ m/^$/;
         my ( $src_mnt, $mnt_pt, $type, $opt_mnt, $dump, $pass )
             = split /\s+/, $line;
+
+        # Linux >= 2.6.39 (or around) adds a slash at the end of an NFS
+        # mount source in /proc/mounts, we need to remove it.
+        $src_mnt =~ s{ / \z }{}xms;
+
         push @{ $struct->{'__mnt_order'} }, $mnt_pt;
         $struct->{$mnt_pt} = {
             'source'  => $src_mnt,
diff -r c2a3bab3aa84 -r eeaa592fd056 lib/PFTools/Structqueries.pm
--- a/lib/PFTools/Structqueries.pm	Mon Mar 07 17:18:58 2011 +0100
+++ b/lib/PFTools/Structqueries.pm	Mon Jan 02 11:35:45 2012 +0100
@@ -293,6 +293,10 @@
 sub get_mode_from_host_ref {
     my ($host_ref) = @_;
 
+    if ( ref $host_ref ne 'HASH' ) {
+        croak q{ERROR: Invalid non-hash reference host_ref};
+    }
+
     return $host_ref->{'deployment'}->{'mode'};
 }
 
@@ -422,6 +426,10 @@
 
     @site_list = uniq @site_list;
 
+    if ( not @site_list ) {
+        croak qq{ERROR: Unknown hostname '$hostname'};
+    }
+
     return \@site_list;
 }
 
diff -r c2a3bab3aa84 -r eeaa592fd056 lib/PFTools/Utils.pm
--- a/lib/PFTools/Utils.pm	Mon Mar 07 17:18:58 2011 +0100
+++ b/lib/PFTools/Utils.pm	Mon Jan 02 11:35:45 2012 +0100
@@ -2058,43 +2058,25 @@
 
 =head2 __get_kpkg_from_kernel( $pxefilename, $deploymode )
 
-This functions computes the name of the kernel package to install, base on the
+This functions computes the name of the kernel package to install, based on the
 I<$pxefilename> and I<$deploymode> values.
 
-FIXME: the -grsec thing should be moved out of the pf-tools source code, to
-keep it generic.
-
 =cut
 
 sub __get_kpkg_from_kernel {
     my ( $pxefilename, $deploymode ) = @_;
 
-    # FIXME why special-case this to Ubuntu!?
-    if ( $deploymode =~ m{ \A ubuntu }xms ) {
+    my $package_name;
+
+    if ( $deploymode =~ m{ \A (?: debian | ubuntu ) }xms ) {
         my ($version) = $pxefilename =~ m{ vmlinuz-(.+) \z }xms;
-        return "linux-image-$version";
-    }
-
-    # FIXME I think this special case should be moved out of the pf-tools
-    # source code to keep it generic
-    if ( $pxefilename =~ m{ pxe }xms ) {
-        my ( $vm, $type, $pxe, $version, @append )
-            = split qr{ [-] }xms, $pxefilename;
-        return
-            qq{linux-image-$version-$type-}
-            . join( q{-}, @append )
-            . q{-grsec};
+        $package_name = qq{linux-image-$version};
     }
     else {
-        my ( $vm, $version, $type, $append_version )
-            = split qr{ [-] }xms, $pxefilename;
-        return
-            qq{linux-image-$version-$type-}
-            . $append_version
-            . q{-grsec};
+        croak qq{ERROR: Unknown deploymode '$deploymode'};
     }
 
-    return;
+    return $package_name;
 }
 
 =head2 __get_md5sum_for_preseedfile( $filename, $pf_config )
diff -r c2a3bab3aa84 -r eeaa592fd056 t/13.conf.t
--- a/t/13.conf.t	Mon Mar 07 17:18:58 2011 +0100
+++ b/t/13.conf.t	Mon Jan 02 11:35:45 2012 +0100
@@ -1981,7 +1981,7 @@
     => q{Correct result for cbv4-rdeploy01}
     or note explain \@result;
 
-my $host_ref = get_host_config( q{cbv4-spawn01}, $global_config, q{cbv4-pfds} );
+$host_ref = get_host_config( q{cbv4-spawn01}, $global_config, q{cbv4-pfds} );
 @result = get_cmdline_from_host_ref($host_ref);
 @expected_result = ( q{}, q{bonding.mode=active-backup bonding.miimon=100} );
 is_deeply \@result, \@expected_result
@@ -2062,13 +2062,127 @@
 qr{ \A ERROR: [ ] Unknown [ ] hostname [ ] 'hostname' [ ] }xms
     => q{Unknown hostname};
 
-#$result = get_host_config( q{cbv4-rdeploy01}, $global_config, q{cbv4} );
-#$expected_result = q{lenny};
+$result = get_host_config( q{cbv4-rdeploy01}, $global_config, q{cbv4} );
+$expected_result = {
+    'boot' => {
+        'cmdline'     => 'pci=bfsort',
+        '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',
+        'dhcpvlan'       => 'vlan-systeme',
+        'distrib'        => 'lenny',
+        'hostname_model' => 'cbv4-rdeploy%%',
+        'hosttype'       => 'cbv4-rdeploy',
+        'mode'           => 'debian',
+        'order'          => '1',
+    },
+    'dns' => {
+        'resolver' => 'nsprivate.private',
+    },
+    'interfaces' => {
+        'eth0' => {
+            'ipv4' => '10.1.167.1/16',
+            'mac'  => '00:1e:c9:ff:42:0b',
+            'vlan' => 'vlan-systeme',
+        },
+    },
+};
 
-#is $result, $expected_result
-#    => q{cbv4-rdeploy01}
-#    or diag explain $result;
+is_deeply $result, $expected_result
+    => q{cbv4-rdeploy01}
+    or diag explain $result;
 
+########################################################################
+note('Testing PFTools::Structqueries::get_mode_from_host_ref');
+can_ok( 'PFTools::Structqueries', qw( get_mode_from_host_ref ) );
+
+throws_ok { get_mode_from_host_ref(); }
+qr{ \A ERROR: [ ] Invalid [ ] non-hash [ ] reference [ ] host_ref }xms
+    => 'No argument';
+
+$host_ref = get_host_config( q{cbv4-rdeploy01}, $global_config, q{cbv4} );
+$result = get_mode_from_host_ref($host_ref);
+$expected_result = q{debian};
+
+is $result, $expected_result
+    => q{cbv4-rdeploy01}
+    or diag explain $result;
+
+########################################################################
+note('Testing PFTools::Structqueries::get_pkgtype_from_hostname');
+can_ok( 'PFTools::Structqueries', qw( get_pkgtype_from_hostname ) );
+
+ at args = ();
+throws_ok { get_pkgtype_from_hostname(@args); }
+qr{ \A ERROR: [ ] Invalid [ ] empty [ ] hostname }xms
+    => q{No arguments};
+
+ at args = ( {} );
+throws_ok { get_pkgtype_from_hostname(@args); }
+qr{ \A ERROR: [ ] Invalid [ ] non-scalar [ ] hostname }xms
+    => q{Non-scalar hostname};
+
+ at args = qw( hostname );
+throws_ok { get_pkgtype_from_hostname(@args); }
+qr{ \A ERROR: [ ] Invalid [ ] non-hash [ ] reference [ ] global_config }xms
+    => q{No global_config};
+
+ at args = ( q{hostname}, q{global_config} );
+throws_ok { get_pkgtype_from_hostname(@args); }
+qr{ \A ERROR: [ ] Invalid [ ] non-hash [ ] reference [ ] global_config }xms
+    => q{No global_config};
+
+ at args = ( q{hostname}, $global_config, { site => q{name} } );
+throws_ok { get_pkgtype_from_hostname(@args); }
+qr{ \A ERROR: [ ] Invalid [ ] non-scalar [ ] site_name }xms
+    => q{Non-scalar site_name};
+
+ at args = ( q{hostname}, $global_config );
+throws_ok { get_pkgtype_from_hostname(@args); }
+qr{ \A ERROR: [ ] Unknown [ ] hostname [ ] 'hostname' [ ] }xms
+    => q{Unknown hostname};
+
+$result = get_pkgtype_from_hostname( q{cbv4-rdeploy01}, $global_config, q{cbv4} );
+$expected_result = q{deb};
+
+is $result, $expected_result
+    => q{cbv4-rdeploy01}
+    or diag explain $result;
+
+########################################################################
+note('Testing PFTools::Structqueries::get_site_list_from_hostname');
+can_ok( 'PFTools::Structqueries', qw( get_site_list_from_hostname ) );
+
+throws_ok { get_site_list_from_hostname() }
+qr{ \A ERROR: [ ] Invalid [ ] empty [ ] hostname }xms
+    => 'Dies if no hostname';
+
+throws_ok { get_site_list_from_hostname( {} ) }
+qr{ \A ERROR: [ ] Invalid [ ] non-scalar [ ] hostname }xms
+    => q{Dies if non-scalar $hostname};
+
+throws_ok { get_site_list_from_hostname('hostname') }
+qr{ \A ERROR: [ ] Invalid [ ] non-hash [ ] reference [ ] global_config }xms
+    => 'Dies if no global_config';
+
+throws_ok { get_site_list_from_hostname( 'hostname', 'global_config' ) }
+qr{ \A ERROR: [ ] Invalid [ ] non-hash [ ] reference [ ] global_config }xms
+    => q{Dies if non-hashref $global_config};
+
+throws_ok { get_site_list_from_hostname( 'hostname', {} ) }
+qr{ \A ERROR: [ ] Unknown [ ] hostname }xms
+    => q{Dies if unknown hostname};
+
+$expected_result
+    = get_site_list_from_hostname( 'cbv4-spawn00', $global_config );
+
+is_deeply $expected_result, [ q{cbv4-pfds} ]
+    => q{Returns the correct site list}
+    or diag explain $parsed_configuration;
 
 #TODO: {
 #    local $TODO = 'Depends on other, still failing, tests';
diff -r c2a3bab3aa84 -r eeaa592fd056 t/20.files.t
--- a/t/20.files.t	Mon Mar 07 17:18:58 2011 +0100
+++ b/t/20.files.t	Mon Jan 02 11:35:45 2012 +0100
@@ -736,7 +736,7 @@
 d-i partman/confirm boolean true
 
 ### Base system installation
-d-i base-installer/kernel/image string linux-image-2.6.26.5-universal-grm2.1.12-grsec
+d-i base-installer/kernel/image string linux-image-2.6.26.5-universal-grm2.1.12
 
 ### Account setup
 d-i passwd/root-login boolean false
@@ -790,7 +790,7 @@
 #d-i grub-installer/bootdev  string (hd0,0) (hd1,0) (hd2,0)
 
 ### Post-install command before reboot
-d-i preseed/late_command string apt-install linux-image-2.6.26.5-universal-grm2.1.12-grsec ; apt-install nfs-common ; apt-install pf-tools ; in-target wget http://mirrors.private//path/to/some/script -O /tmp//path/to/some/script ; in-target sh /tmp//path/to/some/script 
+d-i preseed/late_command string apt-install linux-image-2.6.26.5-universal-grm2.1.12 ; apt-install nfs-common ; apt-install pf-tools ; in-target wget http://mirrors.private//path/to/some/script -O /tmp//path/to/some/script ; in-target sh /tmp//path/to/some/script
 
 ### Finishing up the installation
 # Avoid that last message about the install being complete.
@@ -876,7 +876,7 @@
 
 LABEL install
 \tkernel debian-installer/lenny/amd64/linux
-\tappend DEBCONF_PRIORITY=critical vga=normal auto=true initrd=debian-installer/lenny/amd64/initrd.gz interface=eth0 netcfg/no_default_route=true url=http://vip-deploy.vlan-systeme.private/preseed_cbv4-rdeploy01 url/checksum=aa03e0e1599f6da3149aa94027d116a0 -- default pci=bfsort
+\tappend DEBCONF_PRIORITY=critical vga=normal auto=true initrd=debian-installer/lenny/amd64/initrd.gz interface=eth0 netcfg/no_default_route=true url=http://vip-deploy.vlan-systeme.private/preseed_cbv4-rdeploy01 url/checksum=e09982b86a653dd4602033e14255f6a7 -- default pci=bfsort
 
 LABEL linux
 \tkernel vmlinuz-2.6.26.5-universal-grm2.1.12
diff -r c2a3bab3aa84 -r eeaa592fd056 templates/standard-preseed
--- a/templates/standard-preseed	Mon Mar 07 17:18:58 2011 +0100
+++ b/templates/standard-preseed	Mon Jan 02 11:35:45 2012 +0100
@@ -120,7 +120,7 @@
 #d-i grub-installer/bootdev  string (hd0,0) (hd1,0) (hd2,0)
 
 ### Post-install command before reboot
-d-i preseed/late_command string apt-install [% kernelpkg %] ; apt-install nfs-common ; apt-install pf-tools ; in-target wget http://mirrors.private/[% config_script %] -O /tmp/[% config_script %] ; in-target sh /tmp/[% config_script %] 
+d-i preseed/late_command string apt-install [% kernelpkg %] ; apt-install nfs-common ; apt-install pf-tools ; in-target wget http://mirrors.private/[% config_script %] -O /tmp/[% config_script %] ; in-target sh /tmp/[% config_script %]
 
 ### Finishing up the installation
 # Avoid that last message about the install being complete.



More information about the pf-tools-commits mailing list