| 1 | # -*- perl -*- | ||
| 2 | |||
| 3 | # Copyright (c) 2010 AdCopy | ||
| 4 | # Author: Jeff Weisberg | ||
| 5 | # Created: 2010-Jan-18 18:10 (EST) | ||
| 6 | # Function: info about myself - default implementation | ||
| 7 | # | ||
| 8 | # $Id: MySelf.pm,v 1.1 2010/11/01 18:41:54 jaw Exp $ | ||
| 9 | |||
| 10 | package AC::MrGamoo::Default::MySelf; | ||
| 11 | use AC::MrGamoo::Config; | ||
| 12 | use AC::MrGamoo::Debug; | ||
| 13 | use Sys::Hostname; | ||
| 14 | use Socket; | ||
| 15 | use strict; | ||
| 16 | |||
| 17 | |||
| 18 | my $SERVERID; | ||
| 19 | my $MYIP = inet_ntoa(scalar gethostbyname(hostname())); | ||
| 20 | die "cannot determine my IP addr.\nsee 'class_myself' in the documentation\n" unless $MYIP; | ||
| 21 | |||
| 22 | sub init { | ||
| 23 | my $class = shift; | ||
| 24 | my $port = shift; # not used | ||
| 25 | my $id = shift; | ||
| 26 | |||
| 27 | $SERVERID = $id; | ||
| 28 | unless( $SERVERID ){ | ||
| 29 | $SERVERID = 'mrm/' . conf_value('environment') . '@' . hostname(); | ||
| 30 | } | ||
| 31 | verbose("system persistent-id: $SERVERID"); | ||
| 32 | } | ||
| 33 | |||
| 34 | sub my_server_id { | ||
| 35 | return $SERVERID; | ||
| 36 | } | ||
| 37 | |||
| 38 | sub my_network_info { | ||
| 39 | return [ { ipa => $MYIP } ]; | ||
| 40 | } | ||
| 41 | |||
| 42 | sub my_datacenter { | ||
| 43 | return 'default'; | ||
| 44 | } | ||
| 45 | |||
| 46 | 1; |