Imported Upstream version 1.237
Dominique Dumont
11 years ago
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
7 | 7 | # The GNU Lesser General Public License, Version 2.1, February 1999 |
8 | 8 | # |
9 | # Copyright (c) 2009-2012 Dominique Dumont. | |
9 | # Copyright (c) 2009-2013 Dominique Dumont. | |
10 | 10 | # |
11 | 11 | # This file is part of Config-Model-Itself. |
12 | 12 | # |
26 | 26 | # 02110-1301 USA |
27 | 27 | |
28 | 28 | use Module::Build; |
29 | use Data::Dumper ; | |
30 | 29 | |
31 | 30 | use warnings FATAL => qw(all) ; |
32 | 31 | use strict ; |
69 | 68 | 'namespace::autoclean' => '0' |
70 | 69 | }, |
71 | 70 | 'configure_requires' => { |
72 | 'Any::Moose' => '0', | |
73 | 71 | 'Config::Model' => '2.030', |
74 | 72 | 'File::Slurp' => '0', |
75 | 73 | 'Log::Log4perl' => '1.11', |
81 | 79 | 'Config::Model::TkUI' => '1.210', |
82 | 80 | 'Data::Compare' => '0', |
83 | 81 | 'Log::Log4perl' => '0', |
82 | 'Mouse' => '0', | |
84 | 83 | 'Path::Class' => '0', |
85 | 84 | 'Pod::POM' => '0', |
86 | 85 | 'Tk' => '0', |
0 | 2013-04-19 - 1.237 | |
1 | ||
2 | * Replaced Any::Moose with Mouse | |
3 | * backend detector: do not list twice the same backend | |
4 | * Removed augeas from model and tests. Augeas meta-model | |
5 | is now delivered with Config::Model::Backend::Augeas | |
6 | ||
0 | 7 | 2013-03-23 - 1.236 |
1 | 8 | |
2 | 9 | * Itself: use named parameters with load_data to avoid warnings |
0 | This software is Copyright (c) 2012 by Dominique Dumont. | |
0 | This software is Copyright (c) 2013 by Dominique Dumont. | |
1 | 1 | |
2 | 2 | This is free software, licensed under: |
3 | 3 |
4 | 4 | META.json |
5 | 5 | META.yml |
6 | 6 | README |
7 | augeas_box/etc/ssh/sshd_config | |
8 | 7 | config-model-edit |
9 | 8 | data/MasterModel.pl |
10 | 9 | data/MasterModel/CheckListExamples.pl |
11 | 10 | data/MasterModel/HashIdOfValues.pl |
12 | 11 | data/MasterModel/References.pl |
13 | data/MasterModel/SshdWithAugeas.pl | |
14 | 12 | data/MasterModel/WarpedId.pl |
15 | 13 | data/MasterModel/WarpedValues.pl |
16 | 14 | data/MasterModel/X_base_class.pl |
3 | 3 | "Dominique Dumont" |
4 | 4 | ], |
5 | 5 | "dynamic_config" : 0, |
6 | "generated_by" : "Dist::Zilla version 4.300030, CPAN::Meta::Converter version 2.120921", | |
6 | "generated_by" : "Dist::Zilla version 4.300033, CPAN::Meta::Converter version 2.120921", | |
7 | 7 | "license" : [ |
8 | 8 | "lgpl_2_1" |
9 | 9 | ], |
26 | 26 | }, |
27 | 27 | "configure" : { |
28 | 28 | "requires" : { |
29 | "Any::Moose" : "0", | |
30 | 29 | "Config::Model" : "2.030", |
31 | 30 | "File::Slurp" : "0", |
32 | 31 | "Log::Log4perl" : "1.11", |
45 | 44 | "Config::Model::TkUI" : "1.210", |
46 | 45 | "Data::Compare" : "0", |
47 | 46 | "Log::Log4perl" : "0", |
47 | "Mouse" : "0", | |
48 | 48 | "Path::Class" : "0", |
49 | 49 | "Pod::POM" : "0", |
50 | 50 | "Tk" : "0", |
65 | 65 | "web" : "http://github.com/dod38fr/config-model-itself" |
66 | 66 | } |
67 | 67 | }, |
68 | "version" : "1.236" | |
68 | "version" : "1.237" | |
69 | 69 | } |
70 | 70 |
10 | 10 | Test::More: 0 |
11 | 11 | namespace::autoclean: 0 |
12 | 12 | configure_requires: |
13 | Any::Moose: 0 | |
14 | 13 | Config::Model: 2.030 |
15 | 14 | File::Slurp: 0 |
16 | 15 | Log::Log4perl: 1.11 |
17 | 16 | Module::Build: 0.3601 |
18 | 17 | dynamic_config: 0 |
19 | generated_by: 'Dist::Zilla version 4.300030, CPAN::Meta::Converter version 2.120921' | |
18 | generated_by: 'Dist::Zilla version 4.300033, CPAN::Meta::Converter version 2.120921' | |
20 | 19 | license: lgpl |
21 | 20 | meta-spec: |
22 | 21 | url: http://module-build.sourceforge.net/META-spec-v1.4.html |
28 | 27 | Config::Model::TkUI: 1.210 |
29 | 28 | Data::Compare: 0 |
30 | 29 | Log::Log4perl: 0 |
30 | Mouse: 0 | |
31 | 31 | Path::Class: 0 |
32 | 32 | Pod::POM: 0 |
33 | 33 | Tk: 0 |
36 | 36 | bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Config-Model-Itself |
37 | 37 | homepage: https://github.com/dod38fr/config-model/wiki |
38 | 38 | repository: git://github.com/dod38fr/config-model-itself.git |
39 | version: 1.236 | |
39 | version: 1.237 |
0 | # only a few parameters for augeas tests in core module | |
1 | # leaf, list and hash elements | |
2 | HostbasedAuthentication no | |
3 | HostKey /etc/ssh/ssh_host_key | |
4 | HostKey /etc/ssh/ssh_host_rsa_key | |
5 | HostKey /etc/ssh/ssh_host_dsa_key | |
6 | Subsystem sftp /usr/lib/openssh/sftp-server | |
7 | Subsystem internal-sftp /usr/lib/openssh/sftp-server | |
8 | AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT | |
9 | AcceptEnv LC_IDENTIFICATION LC_ALL |
1 | 1 | # |
2 | 2 | # This file is part of Config-Model-Itself |
3 | 3 | # |
4 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
4 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
5 | 5 | # |
6 | 6 | # This is free software, licensed under: |
7 | 7 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | # | |
1 | # This file is part of Config-Model-Itself | |
2 | # | |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
4 | # | |
5 | # This is free software, licensed under: | |
6 | # | |
7 | # The GNU Lesser General Public License, Version 2.1, February 1999 | |
8 | # | |
9 | [ | |
10 | [ | |
11 | name => 'MasterModel::SshdWithAugeas', | |
12 | ||
13 | 'read_config' => [ | |
14 | { | |
15 | backend => 'augeas', | |
16 | config_dir => '/etc/ssh', | |
17 | file => 'sshd_config', | |
18 | sequential_lens => [qw/HostKey Subsystem Match/], | |
19 | }, | |
20 | { | |
21 | backend => 'perl_file', | |
22 | config_dir => '/etc/ssh', | |
23 | auto_create => 1, | |
24 | }, | |
25 | ], | |
26 | ||
27 | element => [ | |
28 | 'AcceptEnv', | |
29 | { | |
30 | 'cargo' => { | |
31 | 'value_type' => 'uniline', | |
32 | 'type' => 'leaf' | |
33 | }, | |
34 | 'type' => 'list', | |
35 | }, | |
36 | 'HostbasedAuthentication', | |
37 | { | |
38 | 'value_type' => 'boolean', | |
39 | 'type' => 'leaf', | |
40 | }, | |
41 | 'HostKey', | |
42 | { | |
43 | 'cargo' => { | |
44 | 'value_type' => 'uniline', | |
45 | 'type' => 'leaf' | |
46 | }, | |
47 | 'type' => 'list', | |
48 | }, | |
49 | 'Subsystem', | |
50 | { | |
51 | 'cargo' => { | |
52 | 'value_type' => 'uniline', | |
53 | 'mandatory' => '1', | |
54 | 'type' => 'leaf' | |
55 | }, | |
56 | 'type' => 'hash', | |
57 | 'index_type' => 'string' | |
58 | }, | |
59 | ], | |
60 | ] | |
61 | ]; |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
1 | 1 | # |
2 | 2 | # This file is part of Config-Model-Itself |
3 | 3 | # |
4 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
4 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
5 | 5 | # |
6 | 6 | # This is free software, licensed under: |
7 | 7 | # |
1 | 1 | # |
2 | 2 | # This file is part of Config-Model-Itself |
3 | 3 | # |
4 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
4 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
5 | 5 | # |
6 | 6 | # This is free software, licensed under: |
7 | 7 | # |
259 | 259 | 'new_from_deprecated' => { |
260 | 260 | type => 'leaf', |
261 | 261 | value_type => 'enum', |
262 | choice => [qw/cds_file perl_file ini_file augeas custom/], | |
262 | choice => [qw/cds_file perl_file ini_file custom/], | |
263 | 263 | migrate_from => { |
264 | 264 | formula => '$replace{$old}', |
265 | 265 | variables => { old => '- deprecated_p' }, |
384 | 384 | } qw/warn allow forbid suppress/ |
385 | 385 | ), |
386 | 386 | |
387 | ## too difficult to correctly test Augeas here | |
388 | 'sshd_augeas' => { | |
389 | type => 'node', | |
390 | config_class_name => 'MasterModel::SshdWithAugeas', | |
391 | }, | |
392 | 387 | ], |
393 | 388 | description => [ tree_macro => 'controls behavior of other elements' ], |
394 | 389 | author => "dod\@foo.com", |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
7 | 7 | # The GNU Lesser General Public License, Version 2.1, February 1999 |
8 | 8 | # |
9 | # Copyright (c) 2010 Dominique Dumont. | |
9 | # Copyright (c) 2010-2013 Dominique Dumont. | |
10 | 10 | # |
11 | 11 | # This file is part of Config-Model-Itself. |
12 | 12 | # |
26 | 26 | |
27 | 27 | package Config::Model::Itself::BackendDetector ; |
28 | 28 | { |
29 | $Config::Model::Itself::BackendDetector::VERSION = '1.236'; | |
29 | $Config::Model::Itself::BackendDetector::VERSION = '1.237'; | |
30 | 30 | } |
31 | 31 | |
32 | 32 | use Pod::POM ; |
39 | 39 | |
40 | 40 | sub setup_enum_choice { |
41 | 41 | my $self = shift ; |
42 | my @choices = ref $_[0] ? @{$_[0]} : @_ ; | |
42 | ||
43 | # using a hash to make sure that a backend is not listed twice. This may | |
44 | # happen in development environment where a backend in found in /usr/lib | |
45 | # and in ./lib (or ./blib) | |
46 | my %choices = map { ($_ => 1);} ref $_[0] ? @{$_[0]} : @_ ; | |
43 | 47 | |
44 | 48 | # find available backends in all @INC directories |
45 | 49 | my $wanted = sub { |
47 | 51 | if (-f $_ and $n =~ s/\.pm$// and $n !~ /Any$/) { |
48 | 52 | $n =~ s!.*Backend/!! ; |
49 | 53 | $n =~ s!/!::!g ; |
50 | push @choices , $n ; | |
54 | $choices{$n} = 1 ; | |
51 | 55 | } |
52 | 56 | } ; |
53 | 57 | |
56 | 60 | find ($wanted, $path ) if -d $path; |
57 | 61 | } |
58 | 62 | |
59 | $self->SUPER::setup_enum_choice(@choices) ; | |
63 | $self->SUPER::setup_enum_choice(sort keys %choices) ; | |
60 | 64 | } |
61 | 65 | |
62 | 66 | sub set_help { |
122 | 126 | class => 'Config::Model::Itself::BackendDetector' , |
123 | 127 | value_type => 'enum', |
124 | 128 | # specify backends built in Config::Model |
125 | choice => [qw/cds_file perl_file ini_file augeas custom/], | |
129 | choice => [qw/cds_file perl_file ini_file custom/], | |
126 | 130 | |
127 | 131 | help => { |
128 | 132 | cds_file => "file ...", |
129 | 133 | ini_file => "Ini file ...", |
130 | 134 | perl_file => "file perl", |
131 | 135 | custom => "Custom format", |
132 | augeas => "Experimental backend", | |
133 | 136 | } |
134 | 137 | } |
135 | 138 | ], |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
26 | 26 | |
27 | 27 | package Config::Model::Itself::TkEditUI ; |
28 | 28 | { |
29 | $Config::Model::Itself::TkEditUI::VERSION = '1.236'; | |
29 | $Config::Model::Itself::TkEditUI::VERSION = '1.237'; | |
30 | 30 | } |
31 | 31 | |
32 | 32 | use strict; |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
8 | 8 | # |
9 | 9 | package Config::Model::Itself ; |
10 | 10 | { |
11 | $Config::Model::Itself::VERSION = '1.236'; | |
12 | } | |
13 | ||
14 | use Any::Moose ; | |
11 | $Config::Model::Itself::VERSION = '1.237'; | |
12 | } | |
13 | ||
14 | use Mouse ; | |
15 | 15 | use namespace::autoclean; |
16 | 16 | |
17 | 17 | use IO::File ; |
111 | 111 | # - translate legacy warp parameters |
112 | 112 | # - expand elements name |
113 | 113 | my $tmp_model = Config::Model -> new( skip_include => 1, legacy => $legacy ) ; |
114 | # @models order is important to write configuration class back in the same | |
115 | # order as the declaration | |
114 | 116 | my @models = $tmp_model -> load ( 'Tmp' , $file ) ; |
115 | 117 | |
116 | 118 | my $rel_file = $file ; |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
145 | 145 | type => 'leaf', |
146 | 146 | class => 'Config::Model::Itself::BackendDetector', |
147 | 147 | value_type => 'enum', |
148 | choice => [qw/cds_file perl_file ini_file augeas custom/], | |
148 | choice => [qw/cds_file perl_file ini_file custom/], | |
149 | 149 | migrate_from => { |
150 | 150 | formula => '$old', |
151 | 151 | variables => { old => '- syntax' }, |
164 | 164 | "file with a perl data structure. Configuration filename is made with instance name", |
165 | 165 | custom => |
166 | 166 | "Custom format. You must specify your own class and method to perform the read or write function. See Config::Model::AutoRead doc for more details", |
167 | augeas => | |
168 | "Experimental backend with RedHat's Augeas library. See http://augeas.net for details", | |
169 | } | |
167 | } | |
170 | 168 | }, |
171 | 169 | |
172 | 170 | 'file' => { |
194 | 192 | mandatory => 1, |
195 | 193 | } |
196 | 194 | ], |
197 | } | |
198 | }, | |
199 | ||
200 | 'save' => { | |
201 | type => 'leaf', | |
202 | value_type => 'enum', | |
203 | choice => [qw/backup newfile/], | |
204 | level => 'hidden', | |
205 | description => | |
206 | 'Specify how to save the configuration file. Either create a newfile (with extension .augnew, and do not overwrite the original file) or move the original file into a backup file (.augsave extension). Configuration files are overwritten by default', | |
207 | warp => { | |
208 | follow => '- backend', | |
209 | rules => [ augeas => { level => 'normal', } ], | |
210 | 195 | } |
211 | 196 | }, |
212 | 197 | |
337 | 322 | follow => '- backend', |
338 | 323 | rules => [ ini_file => { level => 'normal', } ], |
339 | 324 | } |
340 | }, | |
341 | 'set_in' => { | |
342 | type => 'leaf', | |
343 | value_type => 'reference', | |
344 | refer_to => '- - element', | |
345 | level => 'hidden', | |
346 | description => | |
347 | 'Sometimes, the structure of a file loaded by Augeas starts directly with a list of items. For instance, /etc/hosts structure starts with a list of lines that specify hosts and IP addresses. This parameter specifies an element name in Config::Model root class that will hold the configuration data retrieved by Augeas', | |
348 | warp => { | |
349 | follow => '- backend', | |
350 | rules => [ augeas => { level => 'normal', } ], | |
351 | } | |
352 | }, | |
353 | 'sequential_lens' => { | |
354 | type => 'list', | |
355 | level => 'hidden', | |
356 | cargo => { | |
357 | type => 'leaf', | |
358 | value_type => 'uniline', | |
359 | }, | |
360 | warp => { | |
361 | follow => { b => '- backend' }, | |
362 | rules => [ '$b eq "augeas"' => { level => 'normal', } ], | |
363 | }, | |
364 | description => | |
365 | 'List of hash or list Augeas lenses where value are stored in sequential Augeas nodes. See Config::Model::Backend::Augeas for details.', | |
366 | 325 | }, |
367 | 326 | ], |
368 | 327 |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
13 | 13 | |
14 | 14 | =head2 backend |
15 | 15 | |
16 | specifies the backend to store permanently configuration data.I<< Optional. Type enum. choice: 'cds_file', 'perl_file', 'ini_file', 'augeas', 'custom'. >> | |
16 | specifies the backend to store permanently configuration data.I<< Optional. Type enum. choice: 'cds_file', 'perl_file', 'ini_file', 'custom'. >> | |
17 | 17 | |
18 | 18 | Here are some explanations on the possible values: |
19 | 19 | |
20 | 20 | =over |
21 | ||
22 | =item 'augeas' | |
23 | ||
24 | Experimental backend with RedHat's Augeas library. See http://augeas.net for details | |
25 | 21 | |
26 | 22 | =item 'cds_file' |
27 | 23 | |
54 | 50 | =head2 class |
55 | 51 | |
56 | 52 | I<< Optional. Type uniline. >> |
57 | ||
58 | =head2 save | |
59 | ||
60 | Specify how to save the configuration file. Either create a newfile (with extension .augnew, and do not overwrite the original file) or move the original file into a backup file (.augsave extension). Configuration files are overwritten by default. I<< Optional. Type enum. choice: 'backup', 'newfile'. >> | |
61 | 53 | |
62 | 54 | =head2 store_class_in_hash |
63 | 55 | |
103 | 95 | |
104 | 96 | comment starts with this character. I<< Optional. Type uniline. upstream_default: '#'. >> |
105 | 97 | |
106 | =head2 set_in | |
107 | ||
108 | Sometimes, the structure of a file loaded by Augeas starts directly with a list of items. For instance, /etc/hosts structure starts with a list of lines that specify hosts and IP addresses. This parameter specifies an element name in Config::Model root class that will hold the configuration data retrieved by Augeas. I<< Optional. Type reference. >> | |
109 | ||
110 | =head2 sequential_lens | |
111 | ||
112 | List of hash or list Augeas lenses where value are stored in sequential Augeas nodes. See Config::Model::Backend::Augeas for details.I<< Optional. Type list of uniline. >> | |
113 | ||
114 | 98 | =head2 function |
115 | 99 | |
116 | 100 | I<< Optional. Type uniline. >> |
13 | 13 | |
14 | 14 | =head2 backend |
15 | 15 | |
16 | specifies the backend to store permanently configuration data.I<< Optional. Type enum. choice: 'cds_file', 'perl_file', 'ini_file', 'augeas', 'custom'. >> | |
16 | specifies the backend to store permanently configuration data.I<< Optional. Type enum. choice: 'cds_file', 'perl_file', 'ini_file', 'custom'. >> | |
17 | 17 | |
18 | 18 | Here are some explanations on the possible values: |
19 | 19 | |
20 | 20 | =over |
21 | ||
22 | =item 'augeas' | |
23 | ||
24 | Experimental backend with RedHat's Augeas library. See http://augeas.net for details | |
25 | 21 | |
26 | 22 | =item 'cds_file' |
27 | 23 | |
54 | 50 | =head2 class |
55 | 51 | |
56 | 52 | I<< Optional. Type uniline. >> |
57 | ||
58 | =head2 save | |
59 | ||
60 | Specify how to save the configuration file. Either create a newfile (with extension .augnew, and do not overwrite the original file) or move the original file into a backup file (.augsave extension). Configuration files are overwritten by default. I<< Optional. Type enum. choice: 'backup', 'newfile'. >> | |
61 | 53 | |
62 | 54 | =head2 store_class_in_hash |
63 | 55 | |
103 | 95 | |
104 | 96 | comment starts with this character. I<< Optional. Type uniline. upstream_default: '#'. >> |
105 | 97 | |
106 | =head2 set_in | |
107 | ||
108 | Sometimes, the structure of a file loaded by Augeas starts directly with a list of items. For instance, /etc/hosts structure starts with a list of lines that specify hosts and IP addresses. This parameter specifies an element name in Config::Model root class that will hold the configuration data retrieved by Augeas. I<< Optional. Type reference. >> | |
109 | ||
110 | =head2 sequential_lens | |
111 | ||
112 | List of hash or list Augeas lenses where value are stored in sequential Augeas nodes. See Config::Model::Backend::Augeas for details.I<< Optional. Type list of uniline. >> | |
113 | ||
114 | 98 | =head2 function |
115 | 99 | |
116 | 100 | I<< Optional. Type uniline. >> |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
0 | 0 | # |
1 | 1 | # This file is part of Config-Model-Itself |
2 | 2 | # |
3 | # This software is Copyright (c) 2012 by Dominique Dumont. | |
3 | # This software is Copyright (c) 2013 by Dominique Dumont. | |
4 | 4 | # |
5 | 5 | # This is free software, licensed under: |
6 | 6 | # |
29 | 29 | 'backend' => { type => 'leaf', |
30 | 30 | class => 'Config::Model::Itself::BackendDetector' , |
31 | 31 | value_type => 'enum', |
32 | choice => [qw/cds_file perl_file ini_file augeas custom/], | |
32 | choice => [qw/cds_file perl_file ini_file custom/], | |
33 | 33 | |
34 | 34 | help => { |
35 | 35 | cds_file => "file ...", |
36 | 36 | ini_file => "Ini file ...", |
37 | 37 | perl_file => "file perl", |
38 | 38 | custom => "Custom format", |
39 | augeas => "Experimental backend", | |
40 | 39 | } |
41 | 40 | } |
42 | 41 | ], |
42 | 42 | close CDS ; |
43 | 43 | } |
44 | 44 | |
45 | # trap warning if Augeas backend is not installed | |
46 | if (not eval {require Config::Model::Backend::Augeas; } ) { | |
47 | # do not use Test::Warnings with this | |
48 | $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /unknown backend/}; | |
49 | } | |
50 | else { | |
51 | # workaround Augeas locale bug | |
52 | no warnings qw/uninitialized/; | |
53 | if ($ENV{LC_ALL} ne 'C' or $ENV{LANG} ne 'C') { | |
54 | $ENV{LC_ALL} = $ENV{LANG} = 'C'; | |
55 | my $inc = join(' ',map("-I$_",@INC)) ; | |
56 | exec("$^X $inc $0 @ARGV"); | |
57 | } | |
58 | } | |
59 | ||
60 | 45 | plan tests => 15 ; # avoid double print of plan when exec is run |
61 | 46 | |
62 | 47 | my $log4perl_user_conf_file = $ENV{HOME}.'/.log4config-model' ; |
85 | 70 | rmtree($wr_test) if -d $wr_test ; |
86 | 71 | |
87 | 72 | mkpath([$wr_conf1, $wr_model1, "$wr_conf1/etc/ssh/"], 0, 0755) ; |
88 | copy('augeas_box/etc/ssh/sshd_config', "$wr_conf1/etc/ssh/") ; | |
89 | 73 | dircopy('data',$wr_model1) || die "cannot copy model data:$!" ; |
90 | 74 | |
91 | 75 | my $model = Config::Model->new(legacy => 'ignore',model_dir => $wr_model1 ) ; |
36 | 36 | close CDS ; |
37 | 37 | } |
38 | 38 | |
39 | # trap warning if Augeas backend is not installed | |
40 | if (not eval {require Config::Model::Backend::Augeas; } ) { | |
41 | # do not use Test::Warnings with this | |
42 | $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /unknown backend/}; | |
43 | } | |
44 | else { | |
45 | # workaround Augeas locale bug | |
46 | no warnings qw/uninitialized/; | |
47 | if ($ENV{LC_ALL} ne 'C' or $ENV{LANG} ne 'C') { | |
48 | $ENV{LC_ALL} = $ENV{LANG} = 'C'; | |
49 | my $inc = join(' ',map("-I$_",@INC)) ; | |
50 | exec("$^X $inc $0 @ARGV"); | |
51 | } | |
52 | } | |
53 | ||
54 | 39 | plan tests => 19 ; # avoid double print of plan when exec is run |
55 | 40 | |
56 | 41 | my $meta_model = Config::Model -> new ( ) ;# model_dir => '.' ); |
63 | 48 | |
64 | 49 | # "modern" API of File::Path does not work with perl 5.8.8 |
65 | 50 | mkpath( [$wr_conf1, $wr_model1, "$wr_conf1/etc/ssh/"] , 0, 0755) ; |
66 | copy('augeas_box/etc/ssh/sshd_config', "$wr_conf1/etc/ssh/") ; | |
67 | 51 | dircopy('data',$wr_model1) || die "cannot copy model data:$!" ; |
68 | 52 | |
69 | 53 | # copy test model |
154 | 138 | 'MasterModel::Slave', |
155 | 139 | 'MasterModel::WarpedValues' |
156 | 140 | ], |
157 | 'MasterModel/SshdWithAugeas.pl' => [ | |
158 | 'MasterModel::SshdWithAugeas', | |
159 | ], | |
160 | 141 | 'MasterModel/References.pl' => [ |
161 | 142 | 'MasterModel::References::Host', |
162 | 143 | 'MasterModel::References::If', |