pf-tools/pf-tools: 2 new changesets

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Mon Dec 15 19:13:59 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/46fbe9437b90
changeset: 1391:46fbe9437b90
user:      shad
date:      Mon Dec 15 19:41:57 2014 +0100
description:
fix test

details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/7580c35b3d2b
changeset: 1392:7580c35b3d2b
user:      shad
date:      Mon Dec 15 20:13:55 2014 +0100
description:
revert to previous version and fetch the  earlier from the global conf

diffstat:

 lib/PFTools/Update/ADDMOUNT.pm |  52 +++++++++++++++++++++++------------------
 t/31.addmount.t                |   2 +-
 2 files changed, 30 insertions(+), 24 deletions(-)

diffs (89 lines):

diff -r edd211f7c1d4 -r 7580c35b3d2b lib/PFTools/Update/ADDMOUNT.pm
--- a/lib/PFTools/Update/ADDMOUNT.pm	Mon Dec 15 19:40:28 2014 +0100
+++ b/lib/PFTools/Update/ADDMOUNT.pm	Mon Dec 15 20:13:55 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 edd211f7c1d4 -r 7580c35b3d2b t/31.addmount.t
--- a/t/31.addmount.t	Mon Dec 15 19:40:28 2014 +0100
+++ b/t/31.addmount.t	Mon Dec 15 20:13:55 2014 +0100
@@ -118,7 +118,7 @@
     => 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-systeme.private', $global_config);
+$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



More information about the pf-tools-commits mailing list