pf-tools/pf-tools: add some new shortcut: SHORTHOST, SHORTHOSTSI...
parmelan-guest at users.alioth.debian.org
parmelan-guest at users.alioth.debian.org
Fri Dec 5 13:44:22 UTC 2014
details: http://hg.debian.org/hg/pf-tools/pf-tools/rev/1d27fe0ea54c
changeset: 1351:1d27fe0ea54c
user: melkor <melkor at sitadelle.com>
date: Fri Dec 05 14:44:19 2014 +0100
description:
add some new shortcut: SHORTHOST, SHORTHOSTSITE, SHORHOSTSITE_, HOSTSITE, CONFIGSITE and MODELSITE
diffstat:
doc/network-file.sample | 88 ------------------------------------------
doc/networkfile-syntax | 14 +-----
doc/networkfile.sample | 88 ++++++++++++++++++++++++++++++++++++++++++
doc/updatefile-syntax | 26 +++++++----
lib/PFTools/Conf.pm | 43 ++++++++++++--------
lib/PFTools/Conf/Syntax.pm | 6 +-
t/13.conf.t | 95 ++++++++++++++++++++++++++++++---------------
7 files changed, 197 insertions(+), 163 deletions(-)
diffs (475 lines):
diff -r 5883cb175ea1 -r 1d27fe0ea54c doc/network-file.sample
--- a/doc/network-file.sample Fri Dec 05 11:18:02 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-[cbv4-pfds]
- type = site
- coment = Root site PFDS
- location = Courbevoie
- room = 010D (ex Tele 2)
- state = ROOT
- dhcpvlan = vlan-systeme
- console = default
- zone = private
-
-[cbv4]
- type = site
- coment = POP Courbevoie (CBV4)
- location = Courbevoie
- room = 010D (ex Tele 2)
- state = EDGE
- console = default
- zone = private
- dhcpvlan = vlan-systeme
-
-[private]
- type = zone
- comment = Zone de gestion interne plateforme
- serial = AUTO
- soa = Deploy00.private.
- mail = dnsmaster at private
- refresh = 6H ; Refresh (6 hours)
- retry = 1H ; Retry (1 hour)
- expire = 7D ; Expire (7 days)
- negttl = 1H ; Negative TTL (1 hours)
- ttl = 1D ; TTL (1 day)
- @ns = deploy00.vlan-systeme.private.
- @ns = deploy01.vlan-systeme.private.
- @mx = 1 mf.private.
- @mx = 2 mf00.private.
- @mx = 2 mf01.private.
- console = ttyS0,115200n8
-
-[vip-spawn]
- type = server
- site = cbv4-pfds
- comment = VIP for accessing to spawn functionnality
- order = 2
- number = 1
- ipv4.vlan-systeme = 167.254
- ipv4.vlan-pfds-ext = 99
- shortname = vlan-systeme
- alias.mirrors = vlan-systeme
- alias.cvs = vlan-systeme
- alias.nsprivate = vlan-systeme
- alias.nscache = vlan-systeme
- alias.mf = vlan-systeme
- alias.vip-deploy = vlan-systeme
-
-[network-common]
- type = include
-
-[vlan-pfds-ext]
- type = network
- site = cbv4-pfds
- network = 93.20.126.0/24
- tag = 40
- netmask = 255.255.255.0
- scope = public
- gateway = 254
-
-[vlan-admindsi]
- type = network
- site = cbv4-pfds
- network = 10.111.204.0/24
- tag = 302
- scope = private
- gateway = 254
-
-[vlan-middledsi]
- type = network
- site = cbv4-pfds
- network = 10.111.220.0/24
- tag = 372
-# netmask = /24
- scope = private
- gateway = 254
-
-[admins]
- type = service
- comment = Administration hosts
- site = cbv4-pfds
- @host = hostfile-cbv4-spawn
diff -r 5883cb175ea1 -r 1d27fe0ea54c doc/networkfile-syntax
--- a/doc/networkfile-syntax Fri Dec 05 11:18:02 2014 +0100
+++ b/doc/networkfile-syntax Fri Dec 05 14:44:19 2014 +0100
@@ -50,20 +50,10 @@
[<FILENAME>]
! type ::= include
there are some shortcut defined that resolve to path relatively to VCS root
- and 'module' defined in pf-tool.conf file
- - ROOT: resolve to /module/
- - COMMON: resolve to /module/COMMON/
- - HOST: resolve to /module/bar/ (if the hosttype of machine is bar)
- - HOSTSITE_foo: resolve to /module/SITE/foo/bar/ (if the hosttype of machine is bar)
- - SITE: resolve to /module/SITE/
- - SITE_foo: resolve to /module/SITE/foo/
- - CONFIG: resolve to /module/CONFIG/
- - CONFIGSITE_foo: resolve to /module/SITE/foo/CONFIG/
- - MODEL: resolve to /module/MODEL/
- - MODELSITE_foo: resolve to /module/SITE/foo/MODEL/
+ and 'module' defined in pf-tool.conf file, see update-syntax docuement file
[<SERVICE_NAME>]
! type ::= service
? comment ::= <STR>
! site ::= <STR>
- ! @hosts ::= <STR> add here the hostfile name one per hostgroup
\ No newline at end of file
+ ! @hosts ::= <STR> add here the hostfile name one per hostgroup
diff -r 5883cb175ea1 -r 1d27fe0ea54c doc/networkfile.sample
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/networkfile.sample Fri Dec 05 14:44:19 2014 +0100
@@ -0,0 +1,88 @@
+[cbv4-pfds]
+ type = site
+ coment = Root site PFDS
+ location = Courbevoie
+ room = 010D (ex Tele 2)
+ state = ROOT
+ dhcpvlan = vlan-systeme
+ console = default
+ zone = private
+
+[cbv4]
+ type = site
+ coment = POP Courbevoie (CBV4)
+ location = Courbevoie
+ room = 010D (ex Tele 2)
+ state = EDGE
+ console = default
+ zone = private
+ dhcpvlan = vlan-systeme
+
+[private]
+ type = zone
+ comment = Zone de gestion interne plateforme
+ serial = AUTO
+ soa = Deploy00.private.
+ mail = dnsmaster at private
+ refresh = 6H ; Refresh (6 hours)
+ retry = 1H ; Retry (1 hour)
+ expire = 7D ; Expire (7 days)
+ negttl = 1H ; Negative TTL (1 hours)
+ ttl = 1D ; TTL (1 day)
+ @ns = deploy00.vlan-systeme.private.
+ @ns = deploy01.vlan-systeme.private.
+ @mx = 1 mf.private.
+ @mx = 2 mf00.private.
+ @mx = 2 mf01.private.
+ console = ttyS0,115200n8
+
+[vip-spawn]
+ type = server
+ site = cbv4-pfds
+ comment = VIP for accessing to spawn functionnality
+ order = 2
+ number = 1
+ ipv4.vlan-systeme = 167.254
+ ipv4.vlan-pfds-ext = 99
+ shortname = vlan-systeme
+ alias.mirrors = vlan-systeme
+ alias.cvs = vlan-systeme
+ alias.nsprivate = vlan-systeme
+ alias.nscache = vlan-systeme
+ alias.mf = vlan-systeme
+ alias.vip-deploy = vlan-systeme
+
+[network-common]
+ type = include
+
+[vlan-pfds-ext]
+ type = network
+ site = cbv4-pfds
+ network = 93.20.126.0/24
+ tag = 40
+ netmask = 255.255.255.0
+ scope = public
+ gateway = 254
+
+[vlan-admindsi]
+ type = network
+ site = cbv4-pfds
+ network = 10.111.204.0/24
+ tag = 302
+ scope = private
+ gateway = 254
+
+[vlan-middledsi]
+ type = network
+ site = cbv4-pfds
+ network = 10.111.220.0/24
+ tag = 372
+# netmask = /24
+ scope = private
+ gateway = 254
+
+[admins]
+ type = service
+ comment = Administration hosts
+ site = cbv4-pfds
+ @host = hostfile-cbv4-spawn
diff -r 5883cb175ea1 -r 1d27fe0ea54c doc/updatefile-syntax
--- a/doc/updatefile-syntax Fri Dec 05 11:18:02 2014 +0100
+++ b/doc/updatefile-syntax Fri Dec 05 14:44:19 2014 +0100
@@ -175,13 +175,19 @@
! action ::= include
there are some shortcut defined that resolve to path relatively to VCS root
and 'module' defined in pf-tool.conf file
- - ROOT: resolve to /module/
- - COMMON: resolve to /module/COMMON/
- - HOST: resolve to /module/bar/ (if the hosttype of machine is bar)
- - HOSTSITE_foo: resolve to /module/SITE/foo/bar/ (if the hosttype of machine is bar)
- - SITE: resolve to /module/SITE/
- - SITE_foo: resolve to /module/SITE/foo/
- - CONFIG: resolve to /module/CONFIG/
- - CONFIGSITE_foo: resolve to /module/SITE/foo/CONFIG/
- - MODEL: resolve to /module/MODEL/
- - MODELSITE_foo: resolve to /module/SITE/foo/MODEL/
+ - CONFIG: resolve to /module/CONFIG/
+ - CONFIGSITE: resolve to /module/SITE/pop/CONFIG/ (if the hosttype of machine is pop-bar)
+ - CONFIGSITE_foo: resolve to /module/SITE/foo/CONFIG/
+ - COMMON: resolve to /module/COMMON/
+ - HOST: resolve to /module/bar/ (if the hosttype of machine is pop-bar)
+ - HOSTSITE: resolve to /module/SITE/pop/pop-bar/ (if the hosttype of machine is pop-bar)
+ - HOSTSITE_foo: resolve to /module/SITE/foo/pop-bar/ (if the hosttype of machine is pop-bar)
+ - MODEL: resolve to /module/MODEL/
+ - MODELSITE: resolve to /module/SITE/pop/MODEL/ (if the hosttype of machine is pop-bar)
+ - MODELSITE_foo: resolve to /module/SITE/foo/MODEL/
+ - SITE: resolve to /module/SITE/
+ - SITE_foo: resolve to /module/SITE/foo/
+ - SHORTHOST: resolve to /module/CONFIG/bar/ (if the hosttype of machine is pop-bar)
+ - SHORTHOSTHOSTSITE: resolve to /module/SITE/pop/CONFIG/bar (if the hosttype of machine is pop-bar)
+ - SHORTHOSTHOSTSITE_foo: resolve to /module/SITE/SITE/foo/CONFIG/bar (if the hosttype of machine is pop-bar)
+ - ROOT: resolve to /module/
diff -r 5883cb175ea1 -r 1d27fe0ea54c lib/PFTools/Conf.pm
--- a/lib/PFTools/Conf.pm Fri Dec 05 11:18:02 2014 +0100
+++ b/lib/PFTools/Conf.pm Fri Dec 05 14:44:19 2014 +0100
@@ -302,10 +302,11 @@
HOSTNODEINDEX => $LAST_PAREN_MATCH{HOSTNODEINDEX} || q{},
HOSTCLUSTER => $LAST_PAREN_MATCH{HOSTDIGITS}
. $LAST_PAREN_MATCH{HOSTNODEINDEX},
- POPNAME => $LAST_PAREN_MATCH{POPNAME} || q{},
- OS_RELEASE => $os_release,
- HOSTMINUTE => $hostnum % 60,
- HOSTHOUR => $hostnum % 24,
+ POPNAME => $LAST_PAREN_MATCH{POPNAME} || q{},
+ OS_RELEASE => $os_release,
+ HOSTMINUTE => $hostnum % 60,
+ HOSTHOUR => $hostnum % 24,
+ SHORTHOSTTYPE => $LAST_PAREN_MATCH{SHORTHOSTTYPE} || q{},
};
return $ref_subst;
@@ -353,21 +354,27 @@
my $module = $pf_config->{'vcs'}->{'module'}
or croak q{ERROR: Undefined configuration parameter: vcs.module};
- my $result = $source;
+ my $result = $source;
+ my $root_dir = qq{$vcs_work_dir/$module};
+ my $site_dir = qq{$root_dir/SITE};
+ my $config_dir = qq{$root_dir/CONFIG};
- $result
- =~ s{ \A MODELSITE_([^:]+) [:] }{$vcs_work_dir/$module/SITE/$1/MODEL/}xms;
- $result =~ s{ \A MODEL [:] }{$vcs_work_dir/$module/MODEL/}xms;
- $result
- =~ s{ \A CONFIGSITE_([^:]+) [:] }{$vcs_work_dir/$module/SITE/$1/CONFIG/}xms;
- $result =~ s{ \A CONFIG [:] }{$vcs_work_dir/$module/CONFIG/}xms;
- $result =~ s{ \A SITE_([^:]+) [:] }{$vcs_work_dir/$module/SITE/$1/}xms;
- $result =~ s{ \A SITE [:] }{$vcs_work_dir/$module/SITE/}xms;
- $result
- =~ s{ \A HOSTSITE_([^:]+) [:] }{$vcs_work_dir/$module/SITE/$1/%HOSTTYPE%/}xms;
- $result =~ s{ \A HOST [:] }{$vcs_work_dir/$module/%HOSTTYPE%/}xms;
- $result =~ s{ \A COMMON [:] }{$vcs_work_dir/$module/COMMON/}xms;
- $result =~ s{ \A ROOT [:] }{$vcs_work_dir/$module/}xms;
+ $result =~ s{ \A CONFIG [:] }{$config_dir/}xms;
+ $result =~ s{ \A CONFIGSITE [:] }{$site_dir/%POPNAME%/CONFIG/}xms;
+ $result =~ s{ \A CONFIGSITE_([^:]+) [:] }{$site_dir/$1/CONFIG/}xms;
+ $result =~ s{ \A COMMON [:] }{$root_dir/COMMON/}xms;
+ $result =~ s{ \A HOST [:] }{$config_dir/%HOSTTYPE%/}xms;
+ $result =~ s{ \A HOSTSITE [:] }{$site_dir/%POPNAME%/%HOSTTYPE%/}xms;
+ $result =~ s{ \A HOSTSITE_([^:]+) [:] }{$site_dir/$1/%HOSTTYPE%/}xms;
+ $result =~ s{ \A SHORTHOST [:] }{$config_dir/%SHORTHOSTTYPE%/}xms;
+ $result =~ s{ \A SHORTHOSTSITE [:] }{$site_dir/%POPNAME%/CONFIG/%SHORTHOSTTYPE%/}xms;
+ $result =~ s{ \A SHORTHOSTSITE_([^:]+) [:] }{$site_dir/$1/CONFIG/%SHORTHOSTTYPE%/}xms;
+ $result =~ s{ \A MODEL [:] }{$root_dir/MODEL/}xms;
+ $result =~ s{ \A MODELSITE [:] }{$site_dir/%POPNAME%/MODEL/}xms;
+ $result =~ s{ \A MODELSITE_([^:]+) [:] }{$site_dir/$1/MODEL/}xms;
+ $result =~ s{ \A ROOT [:] }{$root_dir/}xms;
+ $result =~ s{ \A SITE [:] }{$site_dir/}xms;
+ $result =~ s{ \A SITE_([^:]+) [:] }{$site_dir/$1/}xms;
#$result =~ s{ \A CVS [:] }{$vcs_work_dir/}xms;
#$result =~ s{ \A GLOBAL [:] }{$vcs_work_dir/$module/GLOBAL/}xms;
diff -r 5883cb175ea1 -r 1d27fe0ea54c lib/PFTools/Conf/Syntax.pm
--- a/lib/PFTools/Conf/Syntax.pm Fri Dec 05 11:18:02 2014 +0100
+++ b/lib/PFTools/Conf/Syntax.pm Fri Dec 05 14:44:19 2014 +0100
@@ -67,7 +67,7 @@
)
-
)?
- (
+ (?<SHORTHOSTTYPE>
[a-z0-9-]+[a-z-] # host type (without the POP name)
)
)
@@ -82,7 +82,7 @@
)
-
)?
- (
+ (?<SHORTHOSTTYPE>
[a-z0-9-]+[a-z-] # host type (without the POP name)
)
)
@@ -99,7 +99,7 @@
)
-
)?
- (
+ (?<SHORTHOSTTYPE>
[a-z0-9-]+[a-z-] # host type (without the POP name)
)
)
diff -r 5883cb175ea1 -r 1d27fe0ea54c t/13.conf.t
--- a/t/13.conf.t Fri Dec 05 11:18:02 2014 +0100
+++ b/t/13.conf.t Fri Dec 05 14:44:19 2014 +0100
@@ -200,7 +200,8 @@
'HOSTHOUR' => 0,
'HOSTTYPE' => 'abv1-ncdn-lvs',
'HOSTCLUSTER' => '00',
- 'POPNAME' => 'abv1'
+ 'POPNAME' => 'abv1',
+ 'SHORTHOSTTYPE' => 'ncdn-lvs',
},
'cor1-spawn00' => {
'HOSTMINUTE' => 0,
@@ -213,7 +214,8 @@
'HOSTHOUR' => 0,
'HOSTTYPE' => 'cor1-spawn',
'HOSTCLUSTER' => '00',
- 'POPNAME' => 'cor1'
+ 'POPNAME' => 'cor1',
+ 'SHORTHOSTTYPE' => 'spawn',
},
'cor1-spawn01' => {
'HOSTMINUTE' => 1,
@@ -226,7 +228,8 @@
'HOSTHOUR' => 1,
'HOSTTYPE' => 'cor1-spawn',
'HOSTCLUSTER' => '01',
- 'POPNAME' => 'cor1'
+ 'POPNAME' => 'cor1',
+ 'SHORTHOSTTYPE' => 'spawn',
},
};
@@ -272,49 +275,77 @@
qr{ \A ERROR: [ ] Undefined [ ] configuration [ ] parameter: [ ] vcs.module}xms
=> q{Dies on invalid $pf_config (no vcs.module)};
-is get_source(q{MODELSITE_FOOBAR:/my/path/to/file}),
- q{/var/lib/cvsguest/config/SITE/FOOBAR/MODEL/my/path/to/file}
- => q{Good result for MODELSITE_*:};
+is get_source(q{COMMON:/my/path/to/file}),
+ q{/var/lib/cvsguest/config/COMMON/my/path/to/file}
+ => q{Good result for COMMON:};
+
+is get_source(q{CONFIG:/my/path/to/file}),
+ q{/var/lib/cvsguest/config/CONFIG/my/path/to/file}
+ => q{Good result for CONFIG:};
+
+is get_source(q{CONFIGSITE_FOOBAR:/my/path/to/file}),
+ q{/var/lib/cvsguest/config/SITE/FOOBAR/CONFIG/my/path/to/file}
+ => q{Good result for CONFIGSITE_*:};
+
+is get_source(q{CONFIGSITE:/my/path/to/file}, q{abv3-totolala}),
+ q{/var/lib/cvsguest/config/SITE/abv3/CONFIG/my/path/to/file}
+ => q{Good result for CONFIGSITE_*:};
+
+is get_source( q{HOST:/my/path/to/file}, q{myhost00} ),
+ q{/var/lib/cvsguest/config/CONFIG/myhost/my/path/to/file}
+ => q{Good result for HOST:};
+
+is get_source( q{HOST:/my/path/to/file.%HOSTDIGITS%}, q{myhost00} ),
+ q{/var/lib/cvsguest/config/CONFIG/myhost/my/path/to/file.00}
+ => q{Good result for HOST: and %HOSTDIGITS%};
+
+is get_source( q{HOSTSITE:/my/path/to/file}, q{poo1-myhost00} ),
+ q{/var/lib/cvsguest/config/SITE/poo1/poo1-myhost/my/path/to/file}
+ => q{Good result for HOSTSITE:};
+
+is get_source( q{HOSTSITE_FOOBAR:/my/path/to/file}, q{myhost00} ),
+ q{/var/lib/cvsguest/config/SITE/FOOBAR/myhost/my/path/to/file}
+ => q{Good result for HOSTSITE_*:};
is get_source(q{MODEL:/my/path/to/file}),
q{/var/lib/cvsguest/config/MODEL/my/path/to/file}
=> q{Good result for MODEL:};
-is get_source(q{CONFIGSITE_FOOBAR:/my/path/to/file}),
- q{/var/lib/cvsguest/config/SITE/FOOBAR/CONFIG/my/path/to/file}
- => q{Good result for CONFIGSITE_*:};
+is get_source(q{MODELSITE_FOOBAR:/my/path/to/file}),
+ q{/var/lib/cvsguest/config/SITE/FOOBAR/MODEL/my/path/to/file}
+ => q{Good result for MODELSITE_*:};
-is get_source(q{CONFIG:/my/path/to/file}),
- q{/var/lib/cvsguest/config/CONFIG/my/path/to/file}
- => q{Good result for CONFIG:};
+is get_source(q{MODELSITE:/my/path/to/file}, q{abv1-coucoulala}),
+ q{/var/lib/cvsguest/config/SITE/abv1/MODEL/my/path/to/file}
+ => q{Good result for MODELSITE_*:};
+
+is get_source(q{ROOT:/my/path/to/file}),
+ q{/var/lib/cvsguest/config/my/path/to/file}
+ => q{Good result for ROOT:/};
+
+is get_source(q{SITE:/my/path/to/file}),
+ q{/var/lib/cvsguest/config/SITE/my/path/to/file}
+ => q{Good result for SITE:};
is get_source(q{SITE_FOOBAR:/my/path/to/file}),
q{/var/lib/cvsguest/config/SITE/FOOBAR/my/path/to/file}
=> q{Good result for SITE_*:};
-is get_source(q{SITE:/my/path/to/file}),
- q{/var/lib/cvsguest/config/SITE/my/path/to/file}
- => q{Good result for SITE:};
+is get_source(q{SHORTHOST:/my/path/to/file}, q{abv1-toto00}),
+ q{/var/lib/cvsguest/config/CONFIG/toto/my/path/to/file}
+ => q{Good result for SHORTHOST:/};
-is get_source( q{HOSTSITE_FOOBAR:/my/path/to/file}, q{myhost00} ),
- q{/var/lib/cvsguest/config/SITE/FOOBAR/myhost/my/path/to/file}
- => q{Good result for HOSTSITE_*:};
+is get_source(q{SHORTHOSTSITE_abv1:/my/path/to/file}, q{abv1-toto00}),
+ q{/var/lib/cvsguest/config/SITE/abv1/CONFIG/toto/my/path/to/file}
+ => q{Good result for SHORTHOSTSITE_*:/};
-is get_source( q{HOST:/my/path/to/file}, q{myhost00} ),
- q{/var/lib/cvsguest/config/myhost/my/path/to/file}
- => q{Good result for HOST:};
+is get_source(q{SHORTHOSTSITE:/my/path/to/file}, q{abv1-toto00}),
+ q{/var/lib/cvsguest/config/SITE/abv1/CONFIG/toto/my/path/to/file}
+ => q{Good result for SHORTHOSTSITE:/};
-is get_source( q{HOST:/my/path/to/file.%HOSTDIGITS%}, q{myhost00} ),
- q{/var/lib/cvsguest/config/myhost/my/path/to/file.00}
- => q{Good result for HOST: and %HOSTDIGITS%};
-
-is get_source(q{COMMON:/my/path/to/file}),
- q{/var/lib/cvsguest/config/COMMON/my/path/to/file}
- => q{Good result for COMMON:};
-
-is get_source(q{ROOT:/my/path/to/file}),
- q{/var/lib/cvsguest/config/my/path/to/file}
- => q{Good result for ROOT:/};
+is get_source(q{SHORTHOSTSITE:/my/path/to/file.%HOSTDIGITS%}, q{abv1-toto00}),
+ q{/var/lib/cvsguest/config/SITE/abv1/CONFIG/toto/my/path/to/file.00}
+ => q{Good result for SHORTHOSTSITE:/};
########################################################################
note('Testing PFTools::Conf::__get_config_path');
More information about the pf-tools-commits
mailing list