pf-tools commit: r782 [ccaillet-guest] - /branches/next-gen/lib/PFTools/Net.pm
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Fri Jul 23 14:14:24 UTC 2010
Author: ccaillet-guest
Date: Fri Jul 23 14:14:20 2010
New Revision: 782
URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=782
Log:
Source docs and renaming functions
Modified:
branches/next-gen/lib/PFTools/Net.pm
Modified: branches/next-gen/lib/PFTools/Net.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Net.pm?rev=782&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Net.pm (original)
+++ branches/next-gen/lib/PFTools/Net.pm Fri Jul 23 14:14:20 2010
@@ -1151,7 +1151,7 @@
#########################################################################
#
-# STR Get_hostname_model_from_hostname ( STR, STR, STR, STR, HASHREF )
+# STR Get_hostname_model_from_hostname ( STR, HASHREF )
#
# This function returns the hostname for a given model, number and node
# Inputs :
@@ -1187,18 +1187,44 @@
}
}
+#########################################################################
+#
+# STR __Get_host_interfaces ( HASHREF )
+#
+# This function returns the interfaces list for a given parsed hostfile
+# Inputs :
+# - $ref_src : string containing the model definition for building hostname
+#
+# Output :
+# Returns an arrayref containing the interfaces list
+#
sub __Get_host_interfaces ($) {
my ( $ref_src ) = @_;
my ( @if_list );
foreach my $section ( keys %{$ref_src} ) {
next if ( $section !~ /^interface/ );
- $section =~ /^interface::(((eth|bond)[\d]+)(\.(TAG[\d]+))?)$/;
+ $section =~ /^interface::(((eth|bond)[\d]+)(\.(TAG[\d]+|\d+))?)$/;
push ( @if_list, $1 );
}
return @if_list;
}
+#########################################################################
+#
+# STR Get_ip_from_hostindex ( NetAddr::IP, STR, STR, STR, INT )
+#
+# This function returns the host IP for a given number and node
+# Inputs :
+# - $net_block : NetAddr::IP object containing the subnet of the IP
+# - $ipstart : string containing the pf-tools IP definition
+# - $hostnum : string containing the number of the specified host
+# - $hostnode : string containing the node of the specified host
+# - $nodes : specify here the number of nodes for the specified hostclass
+#
+# Output :
+# Returns a NetAddr::IP object containing the IP
+#
sub __Get_ip_from_hostindex ($$;$$$) {
my ( $net_block, $ipstart, $hostnum, $hostnode, $nodes ) = @_;
@@ -1216,6 +1242,24 @@
return $ip;
}
+#########################################################################
+#
+# STR __Check_host_ip ( STR, NetAddr::IP, STR, STR, STR, INT, STR, HASHREF )
+#
+# This function returns the host IP for a given number and node
+# Inputs :
+# - $ip_type : specify here the IP type allowed values are ipv4 or ipv6
+# - $vlan_block : NetAddr::IP object containing the subnet of the IP
+# - $ipstart : string containing the pf-tools IP definition
+# - $hostnum : string containing the number of the specified host
+# - $hostnode : string containing the node of the specified host
+# - $nodes : specify here the number of nodes for the specified hostclass
+# - $site : specify here the site of the specified host
+# - $ref_site : specify here the hashref of site definition into global configuration
+#
+# Output :
+# Returns a NetAddr::IP object containing the checked IP
+#
sub __Check_host_ip ($$$$$$$$) {
my ( $ip_type, $vlan_block, $ipstart, $hostnum, $hostnode, $nodes, $site, $ref_site ) = @_;
@@ -1234,7 +1278,18 @@
return $realip;
}
-sub __Get_srv_vlan_list ($) {
+#####################################################################################
+#
+# STR __Get_vlan_list_from_server ( HASHREF )
+#
+# This function returns the vlan list for a given parsed server
+# Inputs :
+# - $ref_srv : hashref containing the server definition as parsed with Load_conf
+#
+# Output :
+# Returns an arrayref containing the vlan list
+#
+sub __Get_vlan_list_from_server ($) {
my ( $ref_srv ) = @_;
my $vlan_list = [];
@@ -1246,7 +1301,20 @@
return $vlan_list;
}
-sub __Get_alias_for_vlan ($$;$) {
+########################################################################################
+#
+# STR __Get_alias_list_from_server ( HASHREF, STR[, STR] )
+#
+# This function returns the DNS alias list from a given parsed server and a specified vlan
+# Inputs :
+# - $ref_parsed : hashref containing the server definition as parsed with Load_conf
+# - $vlan : specify here the vlan name as defined into pf-tools configuration
+# - $host_number : specify here the host index (host's number and host's node)
+#
+# Output :
+# Returns an arrayref containing the alias list
+#
+sub __Get_alias_list_from_server ($$;$) {
my ( $ref_parsed, $vlan, $host_number ) = @_;
my $alias_list = [];
@@ -1261,7 +1329,21 @@
return $alias_list;
}
-sub __Get_tag_from_vlan ($$$) {
+########################################################################################
+#
+# STR __Get_vlan_tag_from_site ( STR, STR, HASHREF )
+#
+# This function returns the 802.1q tag for a specified vlan and from a site defined into
+# global configuration structure
+# Inputs :
+# - $vlan : specify here the vlan's name as defined into pf-tools configuration
+# - $site : specify here the site's name as defined into pf-tools configuration
+# - $global_config : hashref containing the global configuration parsed
+#
+# Output :
+# Returns the tag if defined undef undef if not.
+#
+sub __Get_vlan_tag_from_site ($$$) {
my ( $vlan, $site, $global_config ) = @_;
foreach my $tag ( keys %{$global_config->{'SITE'}->{'BY_NAME'}->{$site}->{'NETWORK'}->{'BY_TAG'}} ) {
@@ -1270,6 +1352,18 @@
return;
}
+#########################################################################
+#
+# VOID Add_server ( STR, STR, HASHREF, HASHREF, HASHREF )
+#
+# This function adds server into global configuration
+# Inputs :
+# - $srvfile : filename where server is parsed
+# - $srvname_model : model for the server name
+# - $srv2add : hashref where are stored server definitions according to networkfile-syntax
+# - $global_config : hashref where are stored global configuration datas
+# - $pf_config : hashref where are stored pf-tools configuration datas
+#
sub Add_server ($$$$$) {
my ( $srvfile, $srvname_model, $srv2add, $global_config, $pf_config ) = @_;
@@ -1287,7 +1381,7 @@
my $srv_part = $site_part->{'HOST'}->{'BY_NAME'}->{$hostclass};
my $zone = __Get_site_zone ( $site, $global_config->{'SITE'}->{'BY_NAME'}->{$site} );
my $prefix = __Get_site_prefix ( $site, $global_config->{'SITE'}->{'BY_NAME'}->{$site} );
- my $vlan_list = __Get_srv_vlan_list ( $srv2add );
+ my $vlan_list = __Get_vlan_list_from_server ( $srv2add );
foreach my $hostnum ( 0 .. $host_last ) {
foreach my $hostnode ( 0 .. $node_last ) {
my $srvname = __Get_hostname_from_model ( $srvname_model, $hostnum, $hostnode, $prefix );
@@ -1341,7 +1435,7 @@
print Dumper $zone_part->{$hostclass};
push ( @{$zone_part->{$hostclass}->{$shortname.'.'.$vlan}}, "A\t".$realip->addr() );
}
- my $alias_list = __Get_alias_for_vlan ( $srv2add, $vlan, $srv_number );
+ my $alias_list = __Get_alias_list_from_server ( $srv2add, $vlan, $srv_number );
foreach my $alias ( @{$alias_list} ) {
if ( ! defined $zone_part->{$hostclass}->{$alias.'.'.$vlan} ) {
$zone_part->{$hostclass}->{$alias.'.'.$vlan} = "CNAME\t".$shortname.'.'.$vlan;
@@ -1357,6 +1451,22 @@
}
}
+#####################################################################################################
+#
+# HASHREF __Add_host_interface ( STR, STR, STR, STR, HASHREF, ARRAYREF, STR, HASHREF, HASHREF )
+#
+# This function creates the structure to add into global configuration for an interface defintion
+# Inputs :
+# - $iface : specify here the interface name e.g. ethX or bondY
+# - $hostname : specify here the hostname
+# - $hostnum : specify here the host number
+# - $hostnode : specify here the host node
+# - $ref_host : hashref containing the host definition as parsed according to networkfile-syntax
+# - $ref_if_list : arrayref where is stored the interface list of the given hostname
+# - $site : specify here the site of the specified hostname
+# - $ref_site : hashref where are stored the site definition into global configuration
+# - $pf_config : hashref where are stored pf-tools configuration datas
+#
sub __Add_host_interface ($$$$$$$$$) {
my ( $iface, $hostname, $hostnum, $hostnode, $ref_host, $ref_if_list, $site, $ref_site, $pf_config ) = @_;
my ( @if_list, $vlan, $ifraw, $iftag, $add_if, $iface_opt );
@@ -1377,9 +1487,6 @@
my $mac = $ref_host->{$iface_section}->{'mac.'.$host_number};
if ( $host_site->{'BY_MAC'}->{$mac} ) {
my ( $ifdef, $hostdef, $vlandef ) = split ( /\./, $host_site->{'BY_MAC'}->{$mac} );
- print $hostname." -- ".$iface."\n";
- print Dumper $ref_if_list;
- print Dumper $ref_host->{$iface_section};
Abort ( $CODE->{'DUPLICATE_VALUE'},
"MAC address ".$mac." is already defined for interface ".$ifdef." in host ".$hostdef
." which is on vlan ".$vlandef );
@@ -1565,7 +1672,7 @@
my $if2add = __Add_host_interface ( $iface, $hostname, $hostnum, $hostnode, $host2add, \@if_list, $site, $site_part, $pf_config );
my $iface_name = $iface;
if ( $iface =~ /^((eth|bond)[\d]+)(\.(TAG[\d]+))$/ ) {
- $iface_name = $1.'.'.__Get_tag_from_vlan ( $if2add->{'vlan'}, $site, $global_config );
+ $iface_name = $1.'.'.__Get_vlan_tag_from_site ( $if2add->{'vlan'}, $site, $global_config );
}
# Adding interface and IPs into site's zone
$host_part->{$hostname}->{'interfaces'} = {} if ( ! defined $host_part->{$hostname}->{'interfaces'} );
More information about the pf-tools-commits
mailing list