Yenta/MySelf.pm untested

filter: Statementstmt 0.0% 0 / 12 Branchbran n/a Conditioncond n/a Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 15 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 # -*- perl -*-
2  
3 # Copyright (c) 2010 AdCopy
4 # Author: Jeff Weisberg
5 # Created: 2010-Jan-18 18:10 (EST)
6 # Function: stub for customization
7 #
8 # $Id: MySelf.pm,v 1.4 2010/11/01 16:41:06 jaw Exp $
9  
10 package AC::Yenta::MySelf;
11 use AC::Yenta::Customize;
12 use AC::Import;
13 use strict;
14  
15 our @ISA = 'AC::Yenta::Customize';
16 our @EXPORT = qw(my_server_id my_network_info my_datacenter);
17 our @CUSTOM = (@EXPORT, 'init');
18  
19  
20 1;
21  
22 =head1 NAME
23  
24 AC::Yenta::MySelf - customize yenta to your own environment
25  
26 =head1 SYNOPSIS
27  
28 emacs /myperldir/Local/Yenta/MySelf.pm
29 copy. paste. edit.
30  
31 use lib '/myperldir';
32 my $y = AC::Yenta::D->new(
33 class_myself => 'Local::Yenta::MySelf',
34 );
35  
36 =head1 DESCRIPTION
37  
38 provide functions to override default behavior. you may define
39 any or all of the following functions.
40  
41 =head2 my_server_id
42  
43 return a unique identity for this yenta instance. typically,
44 something similar to the server hostname.
45  
46 sub my_server_id {
47 return 'yenta@' . hostname();
48 }
49  
50 =head2 my_datacenter
51  
52 return the name of the local datacenter. yenta will use this
53 to determine which systems are local (same datacenter) and
54 which are remote (different datacenter), and will tune various
55 behaviors accordingly.
56  
57 sub my_datacenter {
58 my($domain) = hostname() =~ /^[\.]+\.(.*)/;
59 return $domain;
60 }
61  
62 =head2 my_network_info
63  
64 return information about the various networks this server has.
65  
66 sub my_network_info {
67 my $public_ip = inet_ntoa(scalar gethostbyname(hostname()));
68 my $privat_ip = inet_ntoa(scalar gethostbyname('internal-' . hostname()));
69  
70  
71 return [
72 # use this IP for communication with servers this datacenter (same natdom)
73 { ip => $privat_ip, natdom => my_datacenter() },
74 # otherwise use this IP
75 { ip => $public_ip },
76 ]
77 }
78  
79 =head2 init
80  
81 inialization function called at startup. typically used to lookup hostanmes, IP addresses,
82 and such and store them in variables to make the above functions faster.
83  
84 my $HOSTNAME;
85 my $DOMAIN;
86 sub init {
87 $HOSTNAME = hostname();
88 ($DOMAIN) = $HOSTNAME =~ /^[\.]+\.(.*)/;
89 }
90  
91 =head1 BUGS
92  
93 none. you write this yourself.
94  
95 =head1 SEE ALSO
96  
97 AC::Yenta
98  
99 =head1 AUTHOR
100  
101 You!
102  
103 =cut