pf-tools commit: r769 [ccaillet-guest] - in /branches/next-gen: debian/changelog doc/hostfile-syntax lib/PFTools/Conf.pm tools/old2new_syntax
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Mon Jul 5 10:48:35 UTC 2010
Author: ccaillet-guest
Date: Mon Jul 5 10:48:35 2010
New Revision: 769
URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=769
Log:
adding __Translate_old2new_host for translating Parser_pftools result hash to
hash Parser_ini hash result with new syntax file
Removed:
branches/next-gen/tools/old2new_syntax
Modified:
branches/next-gen/debian/changelog
branches/next-gen/doc/hostfile-syntax
branches/next-gen/lib/PFTools/Conf.pm
Modified: branches/next-gen/debian/changelog
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/debian/changelog?rev=769&op=diff
==============================================================================
--- branches/next-gen/debian/changelog (original)
+++ branches/next-gen/debian/changelog Mon Jul 5 10:48:35 2010
@@ -14,6 +14,8 @@
this function is also used for old syntax files
- modifying Load_conf as a wrapper for old or new parsing method
- using PFTools::Parser and PFTools::Logger
+ - adding __Translate_old2new_host for translating Parser_pftools result hash to
+ hash Parser_ini hash result with new syntax file
* lib/PFTools/Parser.pm
- introducing this package from splitting Conf.pm function with old parser
- adding parsing with ini standard parser based on Config::IniFiles
@@ -29,7 +31,7 @@
* lib/PFTools/Update.pm
- using new packages Parser.pm et Logger.pm
- -- Christophe Caillet <tof at sitadelle.com> Fri, 02 Jul 2010 17:05:53 +0200
+ -- Christophe Caillet <quadchris at free.fr> Mon, 05 Jul 2010 12:45:16 +0200
pf-tools (0.34.0-0WIP) unstable; urgency=low
Modified: branches/next-gen/doc/hostfile-syntax
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/doc/hostfile-syntax?rev=769&op=diff
==============================================================================
--- branches/next-gen/doc/hostfile-syntax (original)
+++ branches/next-gen/doc/hostfile-syntax Mon Jul 5 10:48:35 2010
@@ -18,7 +18,7 @@
[interface::bondX]
! slaves[.%HOSTNUM%] ::= <IFACE>,<IFACE>,... abort parsing if one <IFACE> is defined into [interface::<IFACE>] section
? mode[.%HOSTNUM%] ::= active-backup|802.3ad ... see kernel Docs for different modes default value is active-backup
- ? options[.%HOSTNUM%] ::= see kernel docs for misc options like xmit_hash_policy
+ ? options[.%HOSTNUM%] ::= see kernel docs for misc options like xmit_hash_policy (space separated list)
! vlan[.%HOSTNUM%] ::= <VLAN_NAME> as defined in network configurations part in PF-TOOLS
! ipv4[.%HOSTNUM%] ::= <IPV4_ADDR> if default is used then act as old ipstart directive
? ipv6[.%HOSTNUM%] ::= <IPV6_ADDR> if default is used then act as old ipstart directive
@@ -43,6 +43,7 @@
[hostgroup]
! site ::= <SITE_NAME>
+ ? comment ::= <STR>
? model ::= <MODEL_NAME> if model is defined then <MODEL_NAME> file is parsed from model directory and hashes are merged with right precedency
! number ::= <INT> define here the number of hosts inside this hostgroup
? order ::= <INT>
@@ -53,6 +54,8 @@
? pxefilename[.%HOSTNUM%] ::= <FILENAME> pxelinux.0 is used by default (generic legacy PXE boot) need to change if UEFI is used
! kernel[.%HOSTNUM%] ::= <KERNEL_FILENAME> this filename is searched into the kernel tftp directory define in pf-tools.conf
? initrd[.%HOSTNUM%] ::= <INITRD_FILENAME> this filename is searched into the kernel tftp directory define in pf-tools.conf
+ ? kerneluml[.%HOSTNUM%] ::= <KERNEL_FILENAME> this filename is searched into the kernel tftp directory define in pf-tools.conf for UML hosts
+ ? initrduml[.%HOSTNUM%] ::= <INITRD_FILENAME> this filename is searched into the kernel tftp directory define in pf-tools.conf
? cmdline[.%HOSTNUM%] ::= misc options on cmdline see kernel docs
? console[.%HOSTNUM%] ::= [default|ttyS0,115200n8]
Modified: branches/next-gen/lib/PFTools/Conf.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Conf.pm?rev=769&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Conf.pm (original)
+++ branches/next-gen/lib/PFTools/Conf.pm Mon Jul 5 10:48:35 2010
@@ -543,6 +543,165 @@
return __Merge_conf_new ( $parsed, $hash_subst, $context );
}
+sub __Translate_old2new_host ($$) {
+ my ( $host_parsed, $hostname ) = @_;
+ my $new_host = {};
+
+ if ( $host_parsed->{'type'} !~ /-server$/ ) {
+ Warn ( $CODE->{'INVALID_KEY'}, "Unable to translate into new format a section which is not a host declaration" );
+ return;
+ }
+
+ $new_host->{'hostgroup'}->{'hostname'} = $hostname;
+ $new_host->{'hostgroup'}->{'comment'} = $host_parsed->{'comment'} || "";
+ foreach my $key ( keys %{$host_parsed} ) {
+ if ( $key eq 'shortname' ) {
+ $new_host->{'dns'}->{'shortname'} = $host_parsed->{'shortname'};
+ }
+ elsif ( $key eq 'ether' ) {
+ foreach my $num ( sort keys %{$host_parsed->{'ether'}} ) {
+ $new_host->{'interface::eth0'}->{'mac.'.$num} = $host_parsed->{$key}->{$num};
+ }
+ }
+ elsif ( $key =~ /^arch|distrib|deploymode$/ ) {
+ my $new_key = ( $key eq 'deploymode' ) ? 'mode' : $key;
+ if ( ref $host_parsed->{$key} eq 'HASH' ) {
+ foreach my $subkey ( keys %{$host_parsed->{$key}} ) {
+ if ( $subkey eq 'default' ) {
+ $new_host->{'deployment'}->{$new_key} = $host_parsed->{$key}->{$subkey};
+ }
+ else {
+ $new_host->{'deployment'}->{$new_key.'.'.$subkey} = $host_parsed->{$key}->{$subkey};
+ }
+ }
+ }
+ else {
+ $new_host->{'deployment'}->{$new_key} = $host_parsed->{$key};
+ }
+ }
+ elsif ( $key =~ /^order|number$/ ) {
+ $new_host->{'hostgroup'}->{$key} = $host_parsed->{$key};
+ }
+ elsif ( $key eq 'interface' ) {
+ foreach my $iface ( keys %{$host_parsed->{$key}} ){
+ my $vlan = $host_parsed->{$key}->{$iface};
+ $new_host->{'interface::'.$iface}->{'vlan'} = $vlan;
+ if ( defined $host_parsed->{'ipstart'}->{$vlan} ) {
+ $new_host->{'interface::'.$iface}->{'ipv4'} = $host_parsed->{'ipstart'}->{$vlan};
+ }
+ elsif ( defined $host_parsed->{'ip'}->{$vlan} ) {
+ foreach my $subkey ( keys %{$host_parsed->{'ip'}->{$vlan}} ) {
+ if ( $subkey eq 'default' && ! defined $new_host->{'interface::'.$iface}->{'ipv4'} ) {
+ $new_host->{'interface::'.$iface}->{'ipv4'} = $host_parsed->{'ip'}->{$vlan}->{$subkey};
+ }
+ else {
+ $new_host->{'interface::'.$iface}->{'ipv4.'.$subkey} = $host_parsed->{'ip'}->{$vlan}->{$subkey};
+ }
+ }
+ }
+ else {
+ $new_host->{'interface::'.$iface}->{'ipv4'} = $host_parsed->{'ipstart'}->{'default'};
+ }
+ if ( defined $host_parsed->{$iface} ) {
+ foreach my $route ( keys %{$host_parsed->{$iface}} ) {
+ if ( ref $host_parsed->{$iface}->{$route} eq 'HASH' ) {
+ foreach my $subkey ( keys %{$host_parsed->{$iface}->{$route}} ) {
+ if ( $subkey eq 'default' ) {
+ push ( @{$new_host->{'interface::'.$iface}->{'@route'}}, $host_parsed->{$iface}->{$route}->{$subkey} );
+ }
+ else {
+ push ( @{$new_host->{'interface::'.$iface}->{'@route.'.$subkey}}, $host_parsed->{$iface}->{$route}->{$subkey} );
+ }
+ }
+ }
+ }
+ if ( $iface =~ /^bond/ ) {
+ if ( ref $host_parsed->{'bonding'}->{$iface} eq 'HASH' ) {
+ foreach my $subkey ( keys %{$host_parsed->{'bonding'}->{$iface}} ) {
+ if ( $subkey eq 'default' ) {
+ $new_host->{'interface::'.$iface}->{'slaves'} = $host_parsed->{'bonding'}->{$iface}->{$subkey};
+ }
+ else {
+ $new_host->{'interface::'.$iface}->{'slaves.'.$subkey} = $host_parsed->{'bonding'}->{$iface}->{$subkey};
+ }
+ }
+ }
+ else {
+ $new_host->{'interface::'.$iface}->{'slaves'} = $host_parsed->{'bonding'}->{$iface};
+ }
+ my $ref_cmdline = {};
+ if ( ref $host_parsed->{'cmdline'} eq 'HASH' ) {
+ $ref_cmdline = $host_parsed->{'cmdline'};
+ } else {
+ $ref_cmdline->{'default'} = $host_parsed->{'cmdline'};
+ }
+ foreach my $cmdline ( keys %{$ref_cmdline} ) {
+ my $newcmd_key = ( $cmdline eq 'default' ) ? 'cmdline' : 'cmdline.'.$cmdline;
+ my $newopt_key = ( $cmdline eq 'default' ) ? 'options' : 'options.'.$cmdline;
+ my $newmode_key = ( $cmdline eq 'default' ) ? 'mode' : 'mode.'.$cmdline;
+ foreach my $cmd ( split ( / /, $ref_cmdline->{$cmdline} ) ) {
+ if ( $cmd =~ /^bonding\.(.+)$/ ) {
+ my ( $opt, $val ) = split ( /=/, $1 );
+ my $new_opt;
+ if ( $opt eq 'mode' ) {
+ $new_host->{'interface::'.$iface}->{$newmode_key} = $val;
+ }
+ else {
+ $new_host->{'interface::'.$iface}->{$newopt_key} = $opt.'='.$val.' ';
+ }
+ }
+ else {
+ $new_host->{'boot'}->{$newcmd_key} .= $cmd." ";
+ }
+ }
+ $new_host->{'interface::'.$iface}->{$newopt_key} =~ s/\s*$//;
+ $new_host->{'boot'}->{$newcmd_key} =~ s/\s*$// if ( $new_host->{'boot'}->{$newcmd_key} );
+ }
+ }
+ }
+ }
+ }
+ elsif ( $key eq 'alias' ) {
+ foreach my $alias ( keys %{$host_parsed->{$key}} ) {
+ $new_host->{'dns'}->{'alias.'.$alias} = $host_parsed->{$key}->{$alias};
+ }
+ }
+ elsif ( $key eq 'dns' ) {
+ if ( ref $host_parsed->{$key} eq 'HASH' ) {
+ foreach my $subkey ( keys %{$host_parsed->{$key}} ) {
+ my $new_key = ( $subkey eq 'default' ) ? 'resolver' : 'resolver.'.$subkey;
+ $new_host->{'dns'}->{$new_key} = $host_parsed->{$key}->{$subkey};
+ }
+ }
+ else {
+ $new_host->{'dns'}->{'resolver'} = $host_parsed->{$key};
+ }
+ }
+ elsif ( $key =~ /^console|(pxe|uml)?filename$/ ) {
+ my $new_key;
+ if ( defined $1 ) {
+ $new_key = ( $1 eq 'uml' ) ? 'kerneluml' : 'kernel';
+ }
+ elsif ( $key eq 'filename' ) {
+ $new_key = 'pxefilename';
+ }
+ else {
+ $new_key = $key;
+ }
+ if ( ref $host_parsed->{$key} eq 'HASH' ) {
+ foreach my $subkey ( keys %{$host_parsed->{$key}} ) {
+ my $newsub_key = ( $subkey eq 'default' ) ? $new_key : $new_key.'.'.$subkey;
+ $new_host->{'boot'}->{$newsub_key} = $host_parsed->{$key}->{$subkey};
+ }
+ }
+ else {
+ $new_host->{'boot'}->{$new_key} = $host_parsed->{$key};
+ }
+ }
+ }
+ return $new_host;
+}
+
sub Load_conf ($$;$$) {
my ( $file, $hash_subst, $context, $syntax ) = @_;
my $sect_type;
More information about the pf-tools-commits
mailing list