| DNS-Oterica documentation | Contained in the DNS-Oterica distribution. |
DNS::Oterica::Node::Host - a host node
version 0.100001
DNS::Oterica::Node::Host represents an individual machine in DNS::Oterica.
A node has interfaces (which have IP addresses), a network location, and is
part of a named domain.
This is the name of the host. It does not include the domain name.
This is an arrayref of other fully-qualified names that refer to this host.
The accessor returns a list.
This is an arrayref of pairs, each one an IP address and a location.
This attribute is pretty likely to change later.
The name of the network location of this host
This is the default TTL for the host's A records -- it doesn't affect the TTL for records created by families to which the host belongs. If not provided, it will be unset, and the default TTL is used.
The world location IP address for this host.
This is the fully-qualified domain name of this host.
Ricardo SIGNES <rjbs@cpan.org>
This software is copyright (c) 2011 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
| DNS-Oterica documentation | Contained in the DNS-Oterica distribution. |
package DNS::Oterica::Node::Host; BEGIN { $DNS::Oterica::Node::Host::VERSION = '0.100001'; } # ABSTRACT: a host node use Moose; extends 'DNS::Oterica::Node'; has hostname => (is => 'ro', isa => 'Str', required => 1); has aliases => ( isa => 'ArrayRef', required => 1, default => sub { [] }, traits => [ 'Array' ], handles => { aliases => 'elements', }, ); has interfaces => ( isa => 'ArrayRef', required => 1, traits => [ 'Array' ], handles => { interfaces => 'elements', }, ); has location => (is => 'ro', isa => 'Str', required => 1); has ttl => (is => 'ro', isa => 'Int'); sub world_ip { my ($self) = @_; my ($if) = grep { $_->[1]->name eq 'world' } $self->interfaces; $if->[0]; } sub fqdn { my ($self) = @_; sprintf '%s.%s', $self->hostname, $self->domain; } sub _family_names { my ($self) = @_; my @all_families = $self->hub->node_families; my @has_self = grep { grep { $_ == $self } $_->nodes } @all_families; return map { $_->name } @has_self; } sub as_data_lines { my ($self) = @_; my @lines = $self->rec->comment("begin host ". $self->fqdn); push @lines, $self->rec->comment( " families: " . join(q{, }, $self->_family_names) ); push @lines, $self->rec->a_and_ptr({ name => $self->fqdn, node => $self, ttl => scalar $self->ttl, }); for ($self->aliases) { push @lines, $self->rec->a({ name => $_, node => $self, ttl => scalar $self->ttl, }); } push @lines, $self->rec->comment("end host ". $self->fqdn . "\n"); return @lines; } __PACKAGE__->meta->make_immutable; no Moose; 1; __END__