pf-tools/pf-tools: Conf.pm: add new shortcut SHORTHOSTNAME, SHOR...

parmelan-guest at users.alioth.debian.org parmelan-guest at users.alioth.debian.org
Wed Dec 10 12:28:04 UTC 2014


details:   http://hg.debian.org/hg/pf-tools/pf-tools/rev/1278a6b4c2ed
changeset: 1371:1278a6b4c2ed
user:      melkor <melkor at sitadelle.com>
date:      Wed Dec 10 13:28:01 2014 +0100
description:
Conf.pm: add new shortcut SHORTHOSTNAME, SHORTHOSTNAMESITE, SHORTHOSTNAMESITE_

diffstat:

 lib/PFTools/Conf.pm |   9 +++++++++
 t/13.conf.t         |  15 +++++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)

diffs (74 lines):

diff -r 8be01e585a19 -r 1278a6b4c2ed lib/PFTools/Conf.pm
--- a/lib/PFTools/Conf.pm	Wed Dec 10 13:11:04 2014 +0100
+++ b/lib/PFTools/Conf.pm	Wed Dec 10 13:28:01 2014 +0100
@@ -307,8 +307,14 @@
         HOSTMINUTE    => $hostnum % 60,
         HOSTHOUR      => $hostnum % 24,
         SHORTHOSTTYPE => $LAST_PAREN_MATCH{SHORTHOSTTYPE} || q{},
+        SHORTHOSTNAME => {}, 
     };
 
+    if ($ref_subst->{SHORTHOSTTYPE}) {
+        $ref_subst->{SHORTHOSTNAME} = $ref_subst->{SHORTHOSTTYPE}
+            . $ref_subst->{HOSTDIGITS};
+    }
+
     return $ref_subst;
 }
 
@@ -376,6 +382,9 @@
     $result =~ s{ \A SHORTHOST [:] }{$files_dir/%SHORTHOSTTYPE%/}xms;
     $result =~ s{ \A SHORTHOSTSITE [:] }{$site_dir/%POPNAME%/FILE/%SHORTHOSTTYPE%/}xms;
     $result =~ s{ \A SHORTHOSTSITE_([^:]+) [:] }{$site_dir/$1/FILE/%SHORTHOSTTYPE%/}xms;
+    $result =~ s{ \A SHORTHOSTNAME [:] }{$files_dir/%SHORTHOSTNAME%/}xms;
+    $result =~ s{ \A SHORTHOSTNAMESITE [:] }{$site_dir/%POPNAME%/FILE/%SHORTHOSTNAME%/}xms;
+    $result =~ s{ \A SHORTHOSTNAMESITE_([^:]+) [:] }{$site_dir/$1/FILE/%SHORTHOSTNAME%/}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;
diff -r 8be01e585a19 -r 1278a6b4c2ed t/13.conf.t
--- a/t/13.conf.t	Wed Dec 10 13:11:04 2014 +0100
+++ b/t/13.conf.t	Wed Dec 10 13:28:01 2014 +0100
@@ -202,6 +202,7 @@
         'HOSTCLUSTER'   => '00',
         'POPNAME'       => 'abv1',
         'SHORTHOSTTYPE' => 'ncdn-lvs',
+        'SHORTHOSTNAME' => 'ncdn-lvs00',
     },
     'cor1-spawn00' => {
         'HOSTMINUTE'    => 0,
@@ -216,6 +217,7 @@
         'HOSTCLUSTER'   => '00',
         'POPNAME'       => 'cor1',
         'SHORTHOSTTYPE' => 'spawn',
+        'SHORTHOSTNAME' => 'spawn00',
     },
     'cor1-spawn01' => {
         'HOSTMINUTE'    => 1,
@@ -230,6 +232,7 @@
         'HOSTCLUSTER'   => '01',
         'POPNAME'       => 'cor1',
         'SHORTHOSTTYPE' => 'spawn',
+        'SHORTHOSTNAME' => 'spawn01',
     },
 };
 
@@ -359,6 +362,18 @@
     q{/var/lib/cvsguest/config/SITE/abv1/FILE/toto/my/path/to/file.00}
     => q{Good result for SHORTHOSTSITE:/};
 
+is get_source(q{SHORTHOSTNAME:/my/path/to/file}, q{abv1-toto00}),
+    q{/var/lib/cvsguest/config/FILE/toto00/my/path/to/file}
+    => q{Good result for SHORTHOSTNAME:/};
+
+is get_source(q{SHORTHOSTNAMESITE_abv1:/my/path/to/file}, q{abv1-toto00}),
+    q{/var/lib/cvsguest/config/SITE/abv1/FILE/toto00/my/path/to/file}
+    => q{Good result for SHORTHOSTNAMESITE_*:/};
+
+is get_source(q{SHORTHOSTNAMESITE:/my/path/to/file}, q{abv1-toto00}),
+    q{/var/lib/cvsguest/config/SITE/abv1/FILE/toto00/my/path/to/file}
+    => q{Good result for SHORTHOSTNAMESITE:/};
+
 ########################################################################
 note('Testing PFTools::Conf::__get_config_path');
 can_ok( 'PFTools::Conf', qw( __get_config_path ) );



More information about the pf-tools-commits mailing list