pf-tools commit: r765 [ccaillet-guest] - in /branches/next-gen: debian/changelog doc/hostfile-syntax lib/PFTools/Conf.pm

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Wed Jun 30 13:51:28 UTC 2010


Author: ccaillet-guest
Date: Wed Jun 30 13:51:27 2010
New Revision: 765

URL: http://svn.debian.org/wsvn/pf-tools/?sc=1&rev=765
Log:
* doc/hostfile-syntax : adding file describing the new grammar for host
definition
* lib/PF-Tools/Conf.pm
  - renaming Load_conf to __Load_conf_old
  - adding __Load_conf_new for parsing new configuration file with "standard"
  ini parser
  - adding __Merge_conf_new for merging include part or model part from
  configuration files
  - adding __Chk_section_struct for checking the content of sections (basic checks)
  - adding Load_conf as a wrapper for old or new parsing method

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=765&op=diff
==============================================================================
--- branches/next-gen/debian/changelog (original)
+++ branches/next-gen/debian/changelog Wed Jun 30 13:51:27 2010
@@ -1,3 +1,19 @@
+pf-tools (0.99.0-0) lucid; urgency=low
+
+  [Christophe Caillet]
+  * doc/hostfile-syntax : adding file describing the new grammar for host
+  definition
+  * lib/PF-Tools/Conf.pm
+    - renaming Load_conf to __Load_conf_old
+    - adding __Load_conf_new for parsing new configuration file with "standard"
+    ini parser
+    - adding __Merge_conf_new for merging include part or model part from
+    configuration files
+    - adding __Chk_section_struct for checking the content of sections (basic checks)
+    - adding Load_conf as a wrapper for old or new parsing method
+
+ -- Christophe Caillet <quadchris at free.fr>  Wed, 30 Jun 2010 15:42:51 +0200
+
 pf-tools (0.34.0-0WIP) unstable; urgency=low
 
   [ Christophe Caillet ]

Modified: branches/next-gen/doc/hostfile-syntax
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/doc/hostfile-syntax?rev=765&op=diff
==============================================================================
--- branches/next-gen/doc/hostfile-syntax (original)
+++ branches/next-gen/doc/hostfile-syntax Wed Jun 30 13:51:27 2010
@@ -1,62 +1,69 @@
-?[includes]
-	? @files	::= <FILENAME>
-
 [interface::ethX]
-	? mac[.default|%HOSTNUM%]		::= <MAC_ADDR>
-	! vlan[.default|%HOSTNUM%]		::= <VLAN_NAME> as defined in network configurations part in PF-TOOLS
-	! ipv4[.default|%HOSTNUM%]		::= <IPV4_ADDR>
-	? ipv6[.default|%HOSTNUM%]		::= <IPV6_ADDR>
-	? options[.default|%HOSTNUM%]	::= <IFACE_OPT>
-	? @route[.default|%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>]
-	? @route6[.default|%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>]
+	? mac[.%HOSTNUM%]				::= <MAC_ADDR> WARNING this directive MUST BE defined for interface which is used for deployment
+	! 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
+	? iface_opt[.%HOSTNUM%]			::= <IFACE_OPT> define here iface options (ip link syntax)
+	? @route[.default|%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>] (ip route syntax)
+	? @route6[.default|%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>] (ip route syntax)
 
 [interface::ethX.TAGY]
-	! vlan[.default|%HOSTNUM%]		::= <VLAN_NAME> as defined in network configurations part in PF-TOOLS
-	! ipv4[.default|%HOSTNUM%]		::= <IPV4_ADDR>
-	? ipv6[.default|%HOSTNUM%]		::= <IPV6_ADDR>
-	? @route[.default|%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>]
-	? @route6[.default|%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>]
+	! 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
+	? iface_opt[%HOSTNUM%]	::= <IFACE_OPT> define here iface options (ip link syntax)
+	? @route[.%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>] (ip route syntax)
+	? @route6[.%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>] (ip route syntax)
 
 [interface::bondX]
-	! slaves[.default|%HOSTNUM%]	::= <IFACE>,<IFACE>,...
-	! mode[.default|%HOSTNUM%]		::= active-backup|802.3ad ... see kernel Docs for different modes
-	! options[.default|%HOSTNUM%]	::= see kernel docs for misc options like xmit_hash_policy 
-	! vlan[.default|%HOSTNUM%]		::= <VLAN_NAME> as defined in network configurations part in PF-TOOLS
-	! ipv4[.default|%HOSTNUM%]		::= <IPV4_ADDR>
-	? ipv6[.default|%HOSTNUM%]		::= <IPV6_ADDR>
-	? @route[.default|%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>]
-	? @route6[.default|%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>]
+	! 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
+	! 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
+	? iface_opt[.%HOSTNUM%]	::= <IFACE_OPT> define here iface options (ip link syntax)
+	? @route[.%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>] (ip route syntax)
+	? @route6[.%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>] (ip route syntax)
 
 [interface::bondX.TAGY]
-	! vlan[.default|%HOSTNUM%]		::= <VLAN_NAME> as defined in network configurations part in PF-TOOLS
-	! ipv4[.default|%HOSTNUM%]		::= <IPV4_ADDR>
-	? ipv6[.default|%HOSTNUM%]		::= <IPV6_ADDR>
-	? @route[.default|%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>]
-	? @route6[.default|%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>]
+	! 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
+	? iface_opt[.%HOSTNUM%]	::= <IFACE_OPT> define here iface options (ip link syntax)
+	? @route[.%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>] (ip route syntax)
+	? @route6[.%HOSTNUM%]	::= <SUBNET>/<NETMASK> [via <GATEWAY>] (ip route syntax)
 
 [deployment]
-	! mode[.default|%HOSTNUM%]		::= debian|ubuntu|redhat
-	! arch[.default|%HOSTNUM%]		::= i386|amd64
-	! distrib[.default|%HOSTNUM%]	::= <DISTRIB_NAME>
+	? os_type				::= redhat|debian|centos ...
+	! mode[.%HOSTNUM%]		::= debian|ubuntu|kickstart
+	! arch[.%HOSTNUM%]		::= i386|amd64
+	! distrib[.%HOSTNUM%]	::= <DISTRIB_NAME>
+	! dhcp[.%HOSTNUM%]		::= <VLAN_NAME>
 
 [hostgroup]
-	model	::= <MODEL_NAME>
-	number	::= <INT>
-	order	::= <INT>
+	? 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>
+	! hostname	::= <STR>[%%]? if the string <STR> is ended by one or more % then each percent is a digit for indexing hosts
+	? hosttype	::= <STR> if defined this key is used for %HOSTTYPE% instead of the derived one from hostfile name
 
 [boot]
-	? pxefilename[.default|%HOSTNUM%]	::= <FILENAME> pxelinux.0 is used by default (generic legacy PXE boot) need to change if UEFI is used
-	! kernel[.default|%HOSTNUM%]		::= <KERNEL_FILENAME>
-	? cmdline[.default|%HOSTNUM%]		::= misc options on cmdline see kernel docs
-	? console[.default|%HOSTNUM%]		::= [default|ttyS0,115200n8]
+	? 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
+	? cmdline[.%HOSTNUM%]		::= misc options on cmdline see kernel docs
+	? console[.%HOSTNUM%]		::= [default|ttyS0,115200n8]
 
 [dns]
-	! resolver[.default|%HOSTNUM%]		::= <IPV4_ADDR|IPV6_ADDR|HOSTNAME>[,<IPV4_ADDR|IPV6_ADDR|HOSTNAME>] : HOSTNAME as defined in PF-TOOLS configurations
-	? shortname[.default|%HOSTNUM%]		::= <VLAN_NAME> as defined in network configurations part in PF-TOOLS, if not defined use the eth0 vlan value
-	? alias.<name>[.default|%HOSTNUM%]	::= <VLAN_NAME> as defined in network configurations part in PF-TOOLS
+	! resolver[.%HOSTNUM%]		::= <IPV4_ADDR|IPV6_ADDR|HOSTNAME>[,<IPV4_ADDR|IPV6_ADDR|HOSTNAME>] : HOSTNAME as defined in PF-TOOLS configurations
+	? shortname[.%HOSTNUM%]		::= <VLAN_NAME> as defined in network configurations part in PF-TOOLS, if not defined use the vlan value defined in dhcpvlan from private-network
+	? alias.<name>[.%HOSTNUM%]	::= <VLAN_NAME> as defined in network configurations part in PF-TOOLS now if %HOSTNUM% is used then we have an alias for each host in hostgroup
 
+##### NEED TO BE IMPLEMENTED
 [monitoring]
 	! type[.default|%HOSTNUM%]		::= nagios
 	! interface[.default|%HOSTNUM%]	::= <VLAN_NAME> as defined in network configurations part in PF-TOOLS
 	! @system[.default|%HOSTNUM%]	::= <CHECK_COMMAND> as defined in NAGIOS configurations
-	! @service[.default|%HOSTNUM%]	::= <CHECK_COMMAND> as defined in NAGIOS configurations
+	! @service[.default|%HOSTNUM%]	::= <CHECK_COMMAND> as defined in NAGIOS configurations
+#####

Modified: branches/next-gen/lib/PFTools/Conf.pm
URL: http://svn.debian.org/wsvn/pf-tools/branches/next-gen/lib/PFTools/Conf.pm?rev=765&op=diff
==============================================================================
--- branches/next-gen/lib/PFTools/Conf.pm (original)
+++ branches/next-gen/lib/PFTools/Conf.pm Wed Jun 30 13:51:27 2010
@@ -26,6 +26,8 @@
 use warnings;
 
 use Exporter;
+use Config::Easy;
+use Hash::Merge;
 
 our @ISA = ('Exporter');
 
@@ -48,6 +50,119 @@
     Debug
     Log
 );
+
+# Prototypes
+sub __Merge_conf_new ($$$);
+sub __Load_conf_new ($$$);
+
+# Error code and error messages
+my $CODE					= {};
+$CODE->{'SECTION_OK'}		= 1;
+$CODE->{'INVALID_CONTEXT'}	= 10;
+$CODE->{'INVALID_SECTNAME'}	= 11;
+$CODE->{'UNDEF_KEY'}		= 20;
+
+# Syntax definitions
+my $ALLOWED_PARSING_CONTEXT = 'host|model|config|network';
+my $HOST_CONFIG_REGEX = qr{
+	\A
+	(				# HOSTTYPE
+	(
+	    (			# POPNAME (optional)
+		[a-z]{3}\d{1}
+	    )
+	    -
+	)?
+	(
+	    [a-z0-9-]+[a-z-]	# host type (without the POP name)
+	)
+    )
+    %*				# % sign designate the number of digit at the end of real hostname
+    \z
+}xms;
+my $HOSTTYPE_CONFIG_REGEX = qr{
+	\A
+	(				# HOSTTYPE
+	(
+	    (			# POPNAME (optional)
+		[a-z]{3}\d{1}
+	    )
+	    -
+	)?
+	(
+	    [a-z0-9-]+[a-z-]	# host type (without the POP name)
+	)
+    )
+    \z
+}xms;
+
+my $DEF_SECTIONS = {};
+$DEF_SECTIONS->{'interface'} = {
+	'MANDATORY_KEYS'	=> [ 'vlan','ipv4','slaves' ],
+	'mac'				=> '([0-9a-f]{2}:){5}[0-9a-f]{2}',
+	'vlan'				=> '[a-z][a-z0-9\-]+[a-z0-9]',
+	'ipv4'				=> '([\d]{1,3}\.){3}[\d]{1,3}',
+	'ipv6'				=> 'undefined',
+	'iface_opt'			=> 'undefined',
+	'@route'			=> 'undefined',
+	'@route6'			=> 'undefined'
+};
+$DEF_SECTIONS->{'deployment'} = {
+	'MANDATORY_KEYS'	=> [ 'arch','mode','distrib' ],
+	'arch'				=> 'i386|amd64',
+	'mode'				=> '(debian|ubuntu)-installer',
+	'distrib'			=> '[a-z]+'
+	'dhcp'				=> 'eth\d'
+};
+$DEF_SECTIONS->{'hostgroup'} = {
+	'MANDATORY_KEYS'	=> [ 'number','hostname' ],
+	'model'				=> 'undefined',
+	'number'			=> '[\d]+',
+	'order'				=> '[\d]+',
+	'hostname'			=> $HOST_CONFIG_REGEX,
+	'hosttype'			=> $HOSTTYPE_CONFIG_REGEX
+};
+$DEF_SECTIONS->{'boot'} = {
+	'MANDATORY_KEYS'	=> [ 'kernel' ],
+	'pxefilename'		=> 'undefined',
+	'kernel'			=> 'undefined',
+	'initrd'			=> 'undefined',
+	'cmdline'			=> 'undefined',
+	'console'			=> 'default|ttyS0,115200n8'
+};
+$DEF_SECTIONS->{'dns'} = {
+	'MANDATORY_KEYS'	=> [ 'resolver' ],
+	'resolver'			=> 'undefined',
+	'shortname'			=> 'undefined',
+	'alias'				=> 'undefined'
+};
+$DEF_SECTIONS->{'config'}->{'addfile'} = {
+	'MANDATORY_KEYS'	=> [ 'source' ],
+	'depends'			=> 'undefined',
+	'source'			=> 'undefined',
+	'filter'			=> 'undefined',
+	'owner'				=> '([\d]+|[a-z\d\-]+)',
+	'group'				=> '([\d]+|[a-z\d\-]+)',
+	'mode'				=> '0?[0-7]{3}',
+	'before_change'		=> 'undefined',
+	'on_noaction'		=> 'undefined',
+	'after_change'		=> 'undefined'
+};
+$DEF_SECTIONS->{'config'}->{'addlink'} = {
+	'MANDATORY_KEYS'	=> [ 'source' ],
+	'source'			=> 'undefined',
+	'before_change'		=> 'undefined',
+	'on_noaction'		=> 'undefined',
+	'after_change'		=> 'undefined'
+};
+$DEF_SECTIONS->{'config'}->{'addmount'} = {
+	'MANDATORY_KEYS'	=> [ 'source','fstype','options' ],
+	'depends'			=> 'undefined',
+	'source'			=> 'undefined',
+	'fstype'			=> 'nfs|ext[2-4]|btrfs|cifs',
+	'options'			=> 'undefined',
+	'mode'				=> '0?[0-7]{3}'
+};
 
 our @EXPORT_OK = qw();
 
@@ -340,7 +455,7 @@
 }
 
 # Load_conf
-sub Load_conf {
+sub __Load_conf_old {
     my ( $fic_conf, $substdestvars ) = @_;
 
     my $CONF     = {};
@@ -602,6 +717,166 @@
     return ($CONF);
 }
 
+sub __Chk_section_struct ($$$$) {
+	my ( $sect_name, $sect_type, $sect_hash, $context ) = @_;
+	my $iface_type;
+	my $sect_tmp = {};
+	my $definition;
+
+	if ( $context ne 'config' ) {
+		if ( ! defined $DEF_SECTIONS->{$sect_type} ) {
+			return ( $CODE->{'INVALID_SECTNAME'}, "Invalid section type ".$sect_type );
+		}
+		if ( $sect_name =~ /^\Q$sect_type\E(::((eth|bond)[\d]+(\.TAG[\d]+)?))?$/ ) {
+			$iface_type = $3;
+		}
+		else {
+			return ( $CODE->{'INVALID_SECTNAME'}, "Invalid section name ".$sect_name )
+		}
+		# Cleaning key name by removing .default or .%HOSTNUM% suffix
+		foreach my $key ( keys %{$sect_hash} ) {
+			my $new = $key;
+			$new =~ s/\..*$//;
+			$sect_tmp->{$new}->{'ORIG_NAME'} = $key;
+			$sect_tmp->{$new}->{'VALUE'} = $sect_hash->{$key};
+		}
+		$definition = $DEF_SECTIONS->{$sect_type};
+	}
+	else {
+		$sect_tmp = $sect_hash;
+		if ( ! defined $DEF_SECTIONS->{'config'}->{$sect_type} ) {
+			return ( $CODE->{'INVALID_SECTNAME'}, "Invalid section type ".$sect_type )
+		}
+		$definition = $DEF_SECTIONS->{'config'}->{$sect_type};
+	}
+
+	# Checking mandatory keys
+	foreach my $key ( @{$definition->{'MANDATORY_KEYS'}} ) {
+		if ( $sect_type eq 'interface' ) {
+			next if ( $iface_type eq 'eth' && $key eq 'slaves' );
+			next if ( $key =~ /^ipv/ && $context eq 'model' );
+		}
+		return ( $CODE->{'UNDEF_KEY'}, 
+			"Mandatory key ".$key." MUST BE defined on section "
+			.$sect_name." in context ".$context ) if ( ! defined ( $sect_tmp->{$key} ) );
+	}
+	# Checking all keys defined
+	foreach my $key ( keys %{$definition} ) {
+		next if ( $key eq 'MANDATORY_KEYS'
+			|| $key =~ /^__/
+			|| $definition->{$key} eq 'undefined'
+			|| ! defined $sect_tmp->{$key} );
+		if ( $context ne 'config' && $sect_tmp->{$key}->{'VALUE'} !~ /^$definition->{$key}$/ ) {
+			return ( $CODE->{'INVALID_VALUE'}, 
+			"Invalid value ".$sect_tmp->{$key}->{'VALUE'}." for key ".$sect_tmp->{$key}->{'ORIG_NAME'}
+			." on section ".$sect_name." in context ".$context );
+		}
+		elsif ( $context eq 'config' && $sect_tmp->{$key} !~ /^$definition->{$key}$/ ) {
+			return ( $CODE->{'INVALID_VALUE'}, 
+			"Invalid value ".$sect_tmp->{$key}." for key ".$key
+			." on section ".$sect_name." in context ".$context );
+		}
+	}
+	return ( $CODE->{'SECTION_OK'}, "" ) ;
+}
+
+sub __Merge_conf_new ($$$) {
+	my ( $hash_to_merge, $hash_subst, $context ) = @_;
+	my $global_order = [];
+	my $global_parsed = {};
+
+	if ( $context ne 'config' ) {
+		
+	}
+	else {
+		foreach my $section ( @{$hash_to_merge->{'__sections_order'}} ) {
+			if ( $hash_to_merge->{$section}->{'action'} ne 'include' ) {
+				push ( @{$global_parsed->{'__sections_order'}}, $section );
+				$global_parsed->{$section} = $hash_to_merge->{$section};
+			}
+			else {
+				my $tmp_merged = __Merge_conf_new ( $hash_to_merge->{$section}->{'__content'}, $hash_subst, $context );
+				foreach my $tomerge_section ( @{$tmp_merged->{'__sections_order'}} ) {
+					if ( defined $global_parsed->{$tomerge_section} ) {
+						if ( ! defined $tmp_merged->{$tomerge_section}->{'override'} || $tmp_merged->{$tomerge_section}->{'override'} ne 'replace' ) {
+							warn "Section ".$tomerge_section." from file ".$section." already defined ... skipping it\n";
+							next;
+						}
+						else {
+							warn "Section ".$tomerge_section." already defined but override is set to replace ... overriding it\n";
+							# Need to evalute if order must be changed
+							# push ( @{$global_parsed->{'__sections_order'}}, $tomerge_section );
+						}
+					}
+					else {
+						push ( @{$global_parsed->{'__sections_order'}}, $tomerge_section );
+					}
+					$global_parsed->{$tomerge_section} = $tmp_merged->{$tomerge_section};
+				} 
+			}
+		}
+	}
+	return $global_parsed;
+}
+
+sub __Load_conf_new ($$$) {
+	my ( $file, $hash_subst, $context ) = @_;
+	my $sect_type;
+
+	my $parsed = load_config ( $file, 'ini', [ 'ordered' ] );
+	if ( ! defined $parsed ) {
+		Abort ( $ERR_SYNTAX, "Parsing error for file ".$file );
+	}
+
+	# Basic checks
+	foreach my $section ( keys %{$parsed} ) {
+		next if ( $section eq '__sections_order' );
+		if ( $context ne 'config' ) {
+			$section =~ /^([^:]+)(::.+)?$/;
+			$sect_type = $1;
+		}
+		else {
+			if ( ! defined $parsed->{$section}->{'action'} ) {
+				Abort ( $CODE->{'UNDEF_KEY'},
+					"Key action on section ".$section." from file ".$file." MUST BE defined" );
+			}
+			$sect_type = $parsed->{$section}->{'action'};
+			if ( $sect_type eq 'include' ) {
+				# We need to dive into deep ...
+				my $inc_parsed = __Load_conf_new ( $section, $hash_subst, $context );
+				$parsed->{$section}->{'__content'} = $inc_parsed;
+			}
+		}
+		if ( $sect_type ne 'include' ) {
+			my ( $code, $msg ) = __Chk_section_struct ( $section, $sect_type, $parsed->{$section}, $context ) if ( $sect_type ne 'include' );
+			if ( $code > 1 ) {
+				Warn ( $code, "Errors occur during parsing model from file ". $file );
+				Abort ( $code, $msg );
+			}
+		}
+	}
+	# Merging if needed
+	return __Merge_conf_new ( $parsed, $hash_subst, $context ) ;
+}
+
+sub Load_conf ($$;$) {
+	my ( $fic_conf, $substdestvars, $type_conf ) = @_;
+
+	if ( defined $type_conf ) {
+		if ( $type_conf =~ /^$ALLOWED_PARSING_CONTEXT$/ ) {
+			# Using new parser with basic checks included
+			__Load_conf_new ( $fic_conf, $substdestvars, $type_conf );
+		}
+		else {
+			Abort ( $CODE->{'INVALID_CONTEXT'}, "Invalid parsing context ".$type_conf );
+		}
+	}
+	else {
+		# Assuming old parser is in use
+		__Load_conf_old ( $fic_conf, $substdestvars );
+	}
+}
+
 # Add_var
 sub Add_var {
     my ( $V, $var, $val ) = @_;




More information about the pf-tools-commits mailing list