pf-tools commit: r802 [ccaillet-guest] - in /branches/next-gen: debian/changelog debian/control lib/PFTools/Update.pm tools/Display_IP_config

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Thu Aug 5 07:48:44 UTC 2010


Author: ccaillet-guest
Date: Thu Aug  5 07:48:35 2010
New Revision: 802

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=802
Log:
  - removing cvs part which are moved to lib/PFTools/VCS.pm
* lib/PFTools/VCS.pm
  - new package for VCS handler(s) for now only CVS is supported
* tools/Display_IP_list : rewrite of dumpiplist.pl

Added:
    branches/next-gen/tools/Display_IP_config
Modified:
    branches/next-gen/debian/changelog
    branches/next-gen/debian/control
    branches/next-gen/lib/PFTools/Update.pm

Modified: branches/next-gen/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/debian/changelog?rev=802&op=diff
==============================================================================
--- branches/next-gen/debian/changelog (original)
+++ branches/next-gen/debian/changelog Thu Aug  5 07:48:35 2010
@@ -48,8 +48,11 @@
     - using new packages Parser.pm et Logger.pm
   * lib/PFTools/Update.pm
     - using new packages Parser.pm et Logger.pm
+    - removing cvs part which are moved to lib/PFTools/VCS.pm
   * lib/PFTools/Utils.pm
     - new library for handling functions used by scripts, filters, and tools
+  * lib/PFTools/VCS.pm
+    - new package for VCS handler(s) for now only CVS is supported
   * sbin/mk_interfaces : rewrite according with new global structure, using
   Getopt::Long for handling command line option(s)
   * sbin/mk_sitezone : rewrite from mk_privatezone according to global structure
@@ -81,8 +84,9 @@
   Getopt::Long for handling command line option(s)
   * removing filters/filter_filname and fiilters/filter_systemmap which are
   useless and deprecated
-
- -- Christophe Caillet <quadchris at free.fr>  Wed, 04 Aug 2010 13:27:18 +0200
+  * tools/Display_IP_list : rewrite of dumpiplist.pl
+
+ -- Christophe Caillet <totof at mithrandir>  Thu, 05 Aug 2010 09:44:10 +0200
 
 pf-tools (0.34.0-0WIP) unstable; urgency=low
 

Modified: branches/next-gen/debian/control
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/debian/control?rev=802&op=diff
==============================================================================
--- branches/next-gen/debian/control (original)
+++ branches/next-gen/debian/control Thu Aug  5 07:48:35 2010
@@ -8,7 +8,7 @@
 
 Package: pf-tools
 Architecture: all
-Depends: perl, perl (>= 5.10.0) | libmd5-perl, libnetaddr-ip-perl, libnet-dns-perl, cvs, ssh, iproute, debconf, psmisc
+Depends: perl, perl (>= 5.10.0) | libmd5-perl, libnetaddr-ip-perl, libnet-dns-perl, libtemplate-tiny-perl, cvs, ssh, iproute, debconf, psmisc
 Description: Outils de gestion de la plateforme
  Mise a jour automatique et generation de conf.
  Deploiement de machines.

Modified: branches/next-gen/lib/PFTools/Update.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Update.pm?rev=802&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Update.pm (original)
+++ branches/next-gen/lib/PFTools/Update.pm Thu Aug  5 07:48:35 2010
@@ -265,8 +265,8 @@
     }
 };
 
-$FUNCTIONS{'addfile'} = sub ($$$$) {
-	my ( $ref_section, $dest, $options, $hash_subst ) = @_;
+$FUNCTIONS{'addfile'} = sub ($$$$$) {
+	my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
 	my ( $source, $tmp, $cmp );
 
 	$hash_subst->{'SECTIONNAME'} = $dest;
@@ -310,7 +310,7 @@
 	}
 
 	if ( ! -f $tmp ) {
-		Warn( $CODE->{'OPEN'}, "unable to open " . $tmp );
+		Warn( $CODE->{'OPEN'}, "Unable to open " . $tmp );
 		return 1;
 	}
 	elsif ( compare ( $tmp, $dest ) ) {
@@ -335,7 +335,7 @@
 					|| ! copy ( $tmp, $dest )
 				) {
 					Warn( $CODE->{'OPEN'},
-						"Impossible de copier " . $tmp . " vers " . $dest );
+						"Unable to copy file " . $tmp . " to " . $dest );
 					return 1;
 				}
 			}
@@ -349,11 +349,10 @@
     return 0;
 };
 
-$FUNCTIONS{'dpkg-purge'} = sub ($$$$) {
-    my ( $ref_section, $dest, $options, $hash_subst ) = @_;
+$FUNCTIONS{'dpkg-purge'} = sub ($$$$$) {
+    my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
 
 	$options->{'pkg_type'} = 'deb' if ( ! defined $options->{'pkg_type'} ) ;
-
 	my $name_filter = $ref_section->{'name_filter'};
 	if ( $name_filter ) {
 		$hash_subst->{'SECTIONNAME'} = $dest;
@@ -383,7 +382,7 @@
 		Do_before_change( $ref_section, $options, $hash_subst ) && return 1;
 		if ( !$options->{'simul'} ) {
 			if ( ! Purge_pkg ( $pkg_type, $dest ) ) {
-				Warn ( $CODE->{'OPEN'}, "Une erreur est survenue lors de la purge du paquet ".$dest ) ;
+				Warn ( $CODE->{'OPEN'}, "An error occured during purge for package ".$dest ) ;
 				return 1 ;
 			}
 		}
@@ -405,7 +404,7 @@
 	return 0;
 }
 
-$DEPENDS{'apt-get'} = sub {
+$DEPENDS{'apt-get'} = sub ($$$) {
     my ( $ref_section, $dest, $options ) = @_;
 
     $options->{'pkg_type'} = 'deb' if ( ! defined $options->{'pkg_type'} ) ;
@@ -422,8 +421,8 @@
 	}
 };
 
-$FUNCTIONS{'apt-get'} = sub ($$$$) {
-    my ( $ref_section, $dest, $options, $hash_subst ) = @_;
+$FUNCTIONS{'apt-get'} = sub ($$$$$) {
+    my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
 
     $options->{'pkg_type'} = 'deb' if ( ! defined $options->{'pkg_type'} ) ;
 	my $installed_version;
@@ -432,7 +431,7 @@
 	my $install = 0;
 
 	my $name_filter = $ref_section->{'name_filter'};
-    if ( $name_filter ) {
+	if ( $name_filter ) {
 		$hash_subst->{'SECTIONNAME'} = $dest;
 		my $newdest = deferredlogpipe ( Subst_vars ( $name_filter, $hash_subst ) );
 		unless ( defined $newdest ) {
@@ -505,7 +504,7 @@
 		}
 		if ( !$options->{'simul'} ) {
 			if ( ! Install_pkg ( $pkg_type, $dest, $ref_section->{'version'} ) ) {
-				Warn( $CODE->{'OPEN'}, "Installation de ".$dest." impossible" ) ;
+				Warn( $CODE->{'OPEN'}, "Unable to install ".$dest ) ;
 				return 1;
 			}
 		}
@@ -524,77 +523,102 @@
 	}
 };
 
-$FUNCTIONS{'addmount'} = sub ($$$$) {
-	my ( $ref_section, $dest, $options, $hash_subst ) = @_;
-
-	my ( $addmount, $source, $fstype, $opts, $sortedopts );
-	my ( $oldsource, $olddest, $oldfstype, $oldopts, $oldresolvedopts );
-	my ( $oldmsource, $oldmresolvedsource, $oldmdest, $oldmfstype, $oldmopts );
-	my $addmountfstab  = 0;
-	my $addmountmounts = 0;
-
-    my $Z;
+sub __Get_ip_host_from_GLOBAL ($$) {
+	my ( $host, $global_config ) = @_;
+
+	my $ip = $host;
+	if ( ! isipaddr ( $host ) ) {
+		my $resolved = Resolv_hostname_from_GLOBAL ( $host, $global_config );
+		if ( ! defined $resolved ) {
+			Warn ( $CODE->{'RESOLV'}, "Unknown host ".$host );
+			return undef;
+		}
+		elsif ( scalar @{$resolved} > 1 ) {
+			Warn ( $CODE->{'RESOLV'}, "Multiple response for ".$host." : unable to choose the right one" );
+			return undef;
+		}
+		else {
+			$ip = shift @{$resolved};
+		}
+	}
+	return $ip
+}
+
+$FUNCTIONS{'addmount'} = sub ($$$$$) {
+	my ( $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
 
 	$hash->{'SECTIONNAME'} = $dest;
-    $source = Subst_vars( $ref_section->{'source'}, $hash_subst );
-    my $sourceaddr	= $source;
-    $sourceaddr =~ s/^([^:]+):(.+)$/$1/;    # NFS
-    if ( defined ( $sourceaddr ) && ! isipaddr ( $sourceaddr ) ) {
-		if ( ! defined($Z) ) {
-			$Z = Init_lib_net( Get_source("GLOBAL:private-network") );
-		}
-	}
-	my $sourceip = Resolv( $sourceaddr, $Z );
-	if ( defined($sourceip) && $sourceip ne "" ) {
-	    $source =~ s/^([^:]+):(.+)$/$sourceip:$2/;
-	}
-    }
-
-    $SUBST{'SOURCE'} = $source;
-
-    $opts = defined( $ref_section->{'options'} ) ? $ref_section->{'options'} : $DEFAULT_OPTIONS;
-
-    my $optsaddr = $opts;
-    $optsaddr =~ s/^(.*,)?ip=([^,]+)(,.*)?$/$2/;
-    if ( defined($optsaddr) && !isipaddr($optsaddr) ) {
-	if ( !defined($Z) ) {
-	    $Z = Init_lib_net( Get_source("GLOBAL:private-network") );
-	}
-	my $optsip = Resolv( $optsaddr, $Z );
-	if ( defined($optsip) && $optsip ne "" ) {
-	    $opts =~ s/^(.*,)?ip=([^,]+)(,.*)?$/$1ip=$optsip$3/;
-	}
-    }
-
-    $SUBST{'OPTIONS'} = $opts;
-    $sortedopts = join( ',', sort split( ',', $opts ) );
-
-    $fstype = defined( $ref_section->{'fstype'} ) ? $ref_section->{'fstype'} : $DEFAULT_FSTYPE;
-    $SUBST{'FSTYPE'} = $fstype;
-
-    if ( !open( FSTAB, "< /etc/fstab" ) ) {
-	Warn( $CODE->{'OPEN'}, "Impossible de lire /etc/fstab" );
-	return 1;
-    }
+	# Source
+	my $source		= Subst_vars( $ref_section->{'source'}, $hash_subst );
+    my $src_addr	= $source;
+	# Checking for network file system
+    $src_addr		=~ s/^([^:]+):(.+)$/$1/;    # NFS
+    if ( defined ( $sourceaddr ) ) {
+		my $src_ip = __Get_ip_host_from_GLOBAL ( $src_addr, $global_config );
+		return 1 if ( ! defined $src_ip );
+		$source =~ s/^([^:]+):(.+)$/$src_ip:$2/;
+	}
+    $hash_subst->{'SOURCE'} = $source;
+	# Mount option(s)
+    my $mnt_opts = $ref_section->{'options'} || $DEFAULT_OPTIONS;
+	$mnt_opts =~ /^(.*,)?ip=([^,]+)(,.*)?$/;
+	my $opts_addr = $2;
+	my $opts_ip = __Get_ip_host_from_GLOBAL ( $opts_addr, $global_config ) if ( $opts_addr );
+	return 1 if ( ! defined $opts_ip );
+	$mnt_opts =~ s/^(.*,)?ip=([^,]+)(,.*)?$/$opts_ip/;
+	$hash_subst->{'OPTIONS'}	= join ( ',', sort split ( ',', $mount_opts ) );
+	# FS type
+	$fstype 					= $ref_section->{'fstype'} || $DEFAULT_FSTYPE;
+	$hash_subst->{'FSTYPE'}		= $fstype;
+
+	if ( ! open( FSTAB, "< /etc/fstab" ) ) {
+		Warn ( $CODE->{'OPEN'}, "Unable to open /etc/fstab" );
+		return 1;
+	}
+	my @current_fstab = <FSTAB>;
+	close ( FSTAB );
+
+
     while (<FSTAB>) {
-	if (m/^[ 	]*([^ 	]+)[ 	]+([^ 	]+)[ 	]+([^ 	]+)[ 	]+([^ 	]+)[ 	]+([^ 	]+)[ 	]+([^ 	]+)/
-	    )
-	{
-	    my $resolved1 = $1;
-	    {
-		my $oldsourceaddr = $1;
-		$oldsourceaddr =~ s/^([^:]+):(.+)$/$1/;    # NFS
-		if ( defined($oldsourceaddr) && !isipaddr($oldsourceaddr) ) {
-		    if ( !defined($Z) ) {
-			$Z = Init_lib_net(
-			    Get_source("GLOBAL:private-network") );
-		    }
-		    my $oldsourceip = Resolv( $oldsourceaddr, $Z );
-		    if ( defined($oldsourceip) && $oldsourceip ne "" ) {
-			$resolved1 =~ s/^([^:]+):(.+)$/$oldsourceip:$2/;
-		    }
-		}
-	    }
+		next if ( /^#/ );
+		s/^\s*//; s/\s*$//; # Removing trailing spaces
+		# <file system> <mount point>   <type>  <options>       <dump>  <pass>
+		my ( $fs, $mnt_pt, $type, $opt_mnt, $dump, $pass ) = split ( /\s+/, $_)
+		$fs =~ /^([^:]+):(.+)$/; my $fs_addr = $1;
+		if ( defined $fs_addr && ! isipaddr ( $fs_addr ) ) {
+			my $resolv_fs = Resolv_hostname_from_GLOBAL ( $fs_addr, $global_config ) if ( $fs_addr && ! isipaddr( $fs_addr) );
+			if ( ! defined $resolv_fs ) {
+				Warn ( $CODE->{'RESOLV'}, "Unknown host ".$fs_addr );
+				return 1;
+			}
+			elsif ( scalar @{$resolv_fs} > 1 ) {
+				Warn ( $CODE->{'RESOLV'}, "Multiple response for ".$fs_addr." : unable to choose the right one" );
+				return 1;
+			}
+			else {
+				my $opts_ip = shift @{$resolv_opts};
+				$mount_opts =~ s/^(.*,)?ip=([^,]+)(,.*)?$/$opts_ip/;
+			}
+		}
+	if (
+		m/^[ 	]*([^ 	]+)[ 	]+([^ 	]+)[ 	]+([^ 	]+)[ 	]+([^ 	]+)[ 	]+([^ 	]+)[ 	]+([^ 	]+)/
+	) {
+		
+		my $resolved1 = $1;
+		{
+			my $oldsourceaddr = $1;
+			$oldsourceaddr =~ s/^([^:]+):(.+)$/$1/;    # NFS
+			if ( defined($oldsourceaddr) && !isipaddr($oldsourceaddr) ) {
+				if ( !defined($Z) ) {
+				$Z = Init_lib_net(
+					Get_source("GLOBAL:private-network") );
+				}
+				my $oldsourceip = Resolv( $oldsourceaddr, $Z );
+				if ( defined($oldsourceip) && $oldsourceip ne "" ) {
+				$resolved1 =~ s/^([^:]+):(.+)$/$oldsourceip:$2/;
+				}
+			}
+		}
 
 	    my $resolved4 = $4;
 	    {
@@ -1317,10 +1341,10 @@
 	}
 }
 
-sub Exec_action ($$$$) {
-	my ( $action, $ref_section, $dest, $options ) = @_;
-
-	return $FUNCTIONS{$action}->( $ref_section, $dest, $options );
+sub Exec_action ($$$$$$) {
+	my ( $action, $ref_section, $dest, $options, $hash_subst, $global_config ) = @_;
+
+	return $FUNCTIONS{$action}->( $ref_section, $dest, $options, $hash_subst, $global_config );
 }
 
 sub Trie_prio {

Added: branches/next-gen/tools/Display_IP_config
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/tools/Display_IP_config?rev=802&op=file
==============================================================================
--- branches/next-gen/tools/Display_IP_config (added)
+++ branches/next-gen/tools/Display_IP_config Thu Aug  5 07:48:35 2010
@@ -1,0 +1,243 @@
+#!/usr/bin/perl
+##
+##  $Id: dumpiplist.pl 582 2008-03-06 16:06:00Z ccaillet-guest $
+##
+##  Copyright (C) 2008-2010 Christophe Caillet <quadchris at free.fr>
+##  Copyright (C) 2004 Stephane Pontier <shad at sitadelle.com>
+##
+##  This program is free software; you can redistribute it and/or
+##  modify it under the terms of the GNU General Public License
+##  as published by the Free Software Foundation; either version 2
+##  of the License, or (at your option) any later version.
+##
+##  This program is distributed in the hope that it will be useful,
+##  but WITHOUT ANY WARRANTY; without even the implied warranty of
+##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+##  GNU General Public License for more details.
+##
+##  You should have received a copy of the GNU General Public License
+##  along with this program; if not, write to the Free Software
+##  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+##
+
+# liste toute les adresses ip depuis le fichier private-network
+# prend le fichier private-network en argument et un 1 en second
+# argument si on souhaite avoir les adresses pour les uml (implique alteon00 surtout)
+
+use strict;
+use warnings;
+
+use Data::Dumper;
+
+use PFTools::Utils;
+use NetAddr::IP;
+use Getopt::Long qw ( :config ignore_case_always bundling ) ;
+
+####################################################
+# Vars
+
+my $HOSTCLASS			= "";
+my $SITE				= "";
+my $OUTPUT				= "";
+my $IP_TYPE				= 'ipv4';
+my $HELP				= 0 ;
+my $GLOBAL_STORE_FILE	= '';
+my $PF_CONFIG_FILE		= '';
+my $PF_CONFIG			= {};
+my $GLOBAL_STRUCT		= {};
+
+my $program = $0;
+$program =~ s%.*/%%; # cheap basename
+
+my $version = sprintf( "svn-r%s", q$Revision: 795 $ =~ /([\d.]+)/ );
+
+######################################################
+# Functions
+
+sub Do_help () {
+print STDERR << "# ENDHELP";
+    $program - version $version
+
+Usage:	$0 [options]
+	--help	: print help and exit
+	-h --host	: the hostclass for which you want to display configuration
+	-s --site	: the site where the hostname is defined
+	-t --type	: IP type (ipv4 or ipv6)
+	-o --output	: destination for modified GRUB configuration
+	--store		: path for accessing storable file containing the global configuration
+	-c --config	: path for accessing pf-tools.conf file
+# ENDHELP
+}
+
+sub _ipcomp {
+    my ( $ip1, $ip2 ) = @_;
+
+	my $ip_obj1 = new NetAddr::IP ( $ip1 );
+	my $ip_obj2 = new NetAddr::IP ( $ip2 );
+	
+	if ( $ip_obj1 < $ip_obj2 ) {
+		return -1;
+	}
+	elsif ( $ip_obj1 > $ip_obj2 ) {
+		return 1;
+	}
+	return 0;
+}
+
+sub order_servers ($) {
+	my ( $host_part ) = @_ ;
+
+	foreach my $hostclass ( keys %{$host_part} ) {
+		foreach my $hostname ( keys %{$host_part->{$hostclass}} ) {
+			my $srv_order = 
+				$host_part->{$hostclass}->{$hostname}->{'deployment'}->{'order'}
+				|| 999;
+			push ( @{$order->{$srv_order}}, $hostname );
+		}
+	}
+	return $order ;
+}
+
+sub get_srv_iface ($$$$) {
+	my ( $ip_type, $srv_name, $global_config, $site ) = @_ ;
+	my $result = {} ;
+
+	return undef if ( ! $pf_config->{'features'}->{$ip_type} );
+	my $host_props = Get_host_config_from_CONFIG ( $srv_name, $global_config, $site );
+	if ( ! defined $host_props ) {
+		Abort ( $CODE->{'UNDEF_KEY'},
+			"Unknown hostname ".$hostname." in global configuration" );
+	}
+	foreach my $iface ( keys %{$host_props->{'interfaces'}} ) {
+		$result->{$iface}->{'addr'} = $host_props->{'interfaces'}->{$iface}->{$ip_type};
+		$result->{$iface}->{'vlan'} = $host_props->{'interfaces'}->{$iface}->{'vlan'};
+	}
+	return $result ;
+}
+
+sub get_srv_ip ($$$$) {
+	my ( $ip_type, $hostclass, $host_part, $pf_config ) = @_ ;
+	my $result = {} ;
+
+	return undef if ( ! $pf_config->{'features'}->{$ip_type} );
+	foreach my $srv ( keys %{$host_part->{$hostclass}} ) {
+		my $ref_srv = $$host_part->{$hostclass}->{$srv} ;
+		foreach my $iface ( keys %{$ref_srv->{'interfaces'}} ) {
+			my $ip_if = $ref_srv->{'interfaces'}->{$iface}->{$ip_type};
+			$result->{$ip_if}->{'hostname'}	= $srv ;
+			$result->{$ip_if}->{'iface'}	= $$iface ;
+		}
+	}
+	return $result ;
+}
+
+sub get_all_ip ($$) {
+	my ( $ip_type, $host_part, $pf_config ) = @_ ;
+	my $result = {} ;
+
+	return undef if ( ! $pf_config->{'features'}->{$ip_type} );
+	foreach my $hostclass ( keys %{$host_part} ) {
+		foreach my $hostname ( keys %{$host_part->{$hostclass}} ) {
+			my $ref_srv = $host_part->{$hostclass}->{$srv} ;
+			foreach my $iface ( keys %{$ref_srv->{'interfaces'}} ) {
+				my $entry = {
+					'hostname'	=> $srv,
+					'iface'		=> $iface
+				} ;
+				push ( @{$result->{$ref_srv->{'interfaces'}->{$iface}->{$ip_type}}}, $entry ) ;
+			}
+		}
+	}
+	return $result ;
+}
+
+
+#######################################################""
+### MAIN
+
+GetOptions (
+	'help'			=> \$HELP,
+	'h|host=s'		=> \$HOSTCLASS,
+	'site|s=s'		=> \$SITE,
+	't|type=s'		=> \$IP_TYPE,		
+	'o|output=s'	=> \$OUTPUT,
+	'config|c=s'	=> \$PF_CONFIG_FILE,
+	'store=s'		=> \$GLOBAL_STORE_FILE,
+) or die "Didn't grok options (see --help).\n";
+
+if ( $HELP ) {
+	Do_help ();
+	exit 0;
+}
+
+( $PF_CONFIG, $GLOBAL_STRUCT ) = Init_TOOLS ( $PF_CONFIG_FILE, $GLOBAL_STORE_FILE );
+
+if ( $SITE eq '' && ! defined $PF_CONFIG->{'location'}->{'site'} ) {
+	my $site_list = Get_site_from_hostname ( $HOSTNAME, $GLOBAL_STRUCT );
+	if ( ! defined $site_list ) {
+		Abort ( $CODE->{'UNDEF_KEY'},
+			"Unable to retrieve site for hostname ".$HOSTNAME." : hostname not defined" );
+	}
+	elsif ( scalar @{$site_list} > 1 ) {
+		Abort ( $CODE->{'DUPLICATE_VALUE'},
+			"Unable to retrieve site for hostname ".$HOSTNAME." : hostname appeared in multiple sites : "
+			.join ( ",", @{$site_list} ).".\n"
+			."Please relaunch this command with the right site" );
+	}
+	else {
+		( $SITE ) = @{$site_list};
+	}
+}
+
+my $host_part = $GLOBAL_STRUCT->{'SITE'}->{'BY_NAME'}->{$SITE}->{'HOST'}->{'BY_NAME'};
+if ( $HOSTCLASS ne "" && ! defined $$host_part->{$HOSTCLASS} ) {
+	Abort ( $CODE->{'UNDEF_KEY'},
+		"Unexistant hostclass in global configuration" );
+}
+if ( $HOSTCLASS ) {
+	if ( $read ) {
+		foreach my $hostname ( sort keys %{$host_part->{$HOSTCLASS}} ) {
+			print "\t".$srv."\n" ;
+			my $srv_net = get_srv_iface ( $IP_TYPE, $hostname, $host_part->{$HOSTCLASS}->{$srv} ) ;
+			if ( ! defined $srv_net ) {
+				Abort ( $CODE->{'UNDEF_KEY'},
+					"IP feature ".$IP_TYPE." is deactivated in pf-tools configuration file" );
+			}
+			foreach my $iface ( sort keys %{$srv_net} ) {
+				print "\t\t".$iface."(".$srv_net->{$iface}->{'vlan'}.")\t: ".$srv_net->{$iface}->{'addr'}."\n" ;
+			}
+		}
+	}
+	else {
+		my $srv_ip = get_srv_ip ( $IP_TYPE, $HOSTCLASS, $host_part->{$HOSTCLASS} ) ;
+		foreach my $ip ( sort { _ipcomp ( $a, $b ) } keys %{$srv_ip} ) {
+			print $ip."\t".$srv_ip->{$ip}->{'hostname'}."(".$srv_ip->{$ip}->{'iface'}.")\n" ;
+		}
+	}
+} else {
+	if ( $read ) {
+		my $srv_type_list = order_servers ( $host_part ) ;
+		foreach my $prio ( sort keys %{$srv_type_list} ) {
+			print "Server with deployment priority : ".$prio."\n" ;
+			foreach my $srv_type ( sort @{$srv_type_list->{$prio}} ) {
+				foreach my $srv ( sort keys %{$host_part->{$srv_type}} ) {
+					print "\t".$srv."\n" ;
+					my $srv_net = get_srv_iface ( $srv, $host_part->{$srv_type}->{$srv} ) ;
+					foreach my $iface ( sort keys %{$srv_net} ) {
+						print "\t\t".$iface."(".$srv_net->{$iface}->{'vlan'}.")\t: ".$srv_net->{$iface}->{'addr'}."\n" ;
+					}
+				}
+				print "\n" ;
+			}
+			print "\n" ;
+		}
+	}
+	else {
+		my $ip_list = get_all_ip ( $host_part ) ;
+		foreach my $ip ( sort { _ipcomp ( $a, $b ) } keys %{$ip_list} ) {
+			print "$ip\t" . join(' ', map { "$_->{'hostname'}($_->{'iface'})" } @{ $ip_list->{$ip} }) . "\n" ;
+		}
+	}
+}
+
+exit 0;




More information about the pf-tools-commits mailing list