| 1 | package DNS::Oterica::Node::Host; | ||
| 2 | # ABSTRACT: a host node | ||
| 3 | 1 | $DNS::Oterica::Node::Host::VERSION = '0.313'; | |
| 4 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | extends 'DNS::Oterica::Node'; | |
| 6 | |||
| 7 | #pod =head1 OVERVIEW | ||
| 8 | #pod | ||
| 9 | #pod C<DNS::Oterica::Node::Host> represents an individual machine in DNS::Oterica. | ||
| 10 | #pod A node has interfaces (which have IP addresses) and is part of a named domain. | ||
| 11 | #pod | ||
| 12 | #pod =attr hostname | ||
| 13 | #pod | ||
| 14 | #pod This is the name of the host. B<It does not include the domain name.> | ||
| 15 | #pod | ||
| 16 | #pod =cut | ||
| 17 | |||
| 18 | 1 | has hostname => (is => 'ro', isa => 'Str', required => 1); | |
| 19 | |||
| 20 | #pod =attr aliases | ||
| 21 | #pod | ||
| 22 | #pod This is an arrayref of other fully-qualified names that refer to this host. | ||
| 23 | #pod | ||
| 24 | #pod The accessor returns a list. | ||
| 25 | #pod | ||
| 26 | #pod =cut | ||
| 27 | |||
| 28 | has aliases => ( | ||
| 29 | isa => 'ArrayRef', | ||
| 30 | required => 1, | ||
| 31 | 0 | ▶ | default => sub { [] }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 32 | 1 | traits => [ 'Array' ], | |
| 33 | handles => { | ||
| 34 | aliases => 'elements', | ||
| 35 | }, | ||
| 36 | ); | ||
| 37 | |||
| 38 | #pod =attr interfaces | ||
| 39 | #pod | ||
| 40 | #pod This is an arrayref of pairs, each one an IP address and a network. | ||
| 41 | #pod | ||
| 42 | #pod This attribute is pretty likely to change later. | ||
| 43 | #pod | ||
| 44 | #pod =cut | ||
| 45 | |||
| 46 | 1 | has interfaces => ( | |
| 47 | isa => 'ArrayRef', | ||
| 48 | required => 1, | ||
| 49 | traits => [ 'Array' ], | ||
| 50 | handles => { | ||
| 51 | interfaces => 'elements', | ||
| 52 | }, | ||
| 53 | ); | ||
| 54 | |||
| 55 | #pod =attr location | ||
| 56 | #pod | ||
| 57 | #pod The name of the network location of this host | ||
| 58 | #pod | ||
| 59 | #pod =cut | ||
| 60 | |||
| 61 | 1 | has location => (is => 'ro', isa => 'Str', required => 1); | |
| 62 | |||
| 63 | #pod =attr ttl | ||
| 64 | #pod | ||
| 65 | #pod This is the default TTL for the host's A records -- it doesn't affect the TTL | ||
| 66 | #pod for records created by families to which the host belongs. If not provided, | ||
| 67 | #pod it will be unset, and the default TTL is used. | ||
| 68 | #pod | ||
| 69 | #pod =cut | ||
| 70 | |||
| 71 | 1 | has ttl => (is => 'ro', isa => 'Int'); | |
| 72 | |||
| 73 | #pod =method fqdn | ||
| 74 | #pod | ||
| 75 | #pod This is the fully-qualified domain name of this host. | ||
| 76 | #pod | ||
| 77 | #pod =cut | ||
| 78 | |||
| 79 | sub fqdn { | ||
| 80 | 0 | ▶ | my ($self) = @_; |
|
Subroutine
fqdn: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 81 | 0 | sprintf '%s.%s', $self->hostname, $self->domain; | |
| 82 | } | ||
| 83 | |||
| 84 | sub _family_names { | ||
| 85 | 0 | ▶ | my ($self) = @_; |
|
Subroutine
_family_names: not called CC=1 SCAR=6.9
| |||
| 86 | 0 | my @all_families = $self->hub->node_families; | |
| 87 | 0 | my @has_self = grep { grep { $_ == $self } $_->nodes } @all_families; | |
| 88 | |||
| 89 | 0 | return map { $_->name } @has_self; | |
| 90 | } | ||
| 91 | |||
| 92 | sub as_data_lines { | ||
| 93 | 0 | ▶ | my ($self) = @_; |
|
Subroutine
as_data_lines: not called CC=2 SCAR=17.9
Pod
documented
| |||
| 94 | |||
| 95 | 0 | my @lines = $self->rec->comment("begin host ". $self->fqdn); | |
| 96 | |||
| 97 | 0 | push @lines, $self->rec->comment( | |
| 98 | " families: " . join(q{, }, $self->_family_names) | ||
| 99 | ); | ||
| 100 | |||
| 101 | 0 | push @lines, $self->rec->a_and_ptr({ | |
| 102 | name => $self->fqdn, | ||
| 103 | node => $self, | ||
| 104 | ttl => scalar $self->ttl, | ||
| 105 | }); | ||
| 106 | |||
| 107 | 0 | for ($self->aliases) { | |
| 108 | 0 | push @lines, $self->rec->a({ | |
| 109 | name => $_, | ||
| 110 | node => $self, | ||
| 111 | ttl => scalar $self->ttl, | ||
| 112 | }); | ||
| 113 | } | ||
| 114 | |||
| 115 | 0 | push @lines, $self->rec->comment("end host ". $self->fqdn . "\n"); | |
| 116 | |||
| 117 | 0 | return @lines; | |
| 118 | } | ||
| 119 | |||
| 120 | 1 | __PACKAGE__->meta->make_immutable; | |
| 121 | 1 | ▶ | no Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 122 | 1 | 1; | |
| 123 | |||
| 124 | __END__ | ||
| 125 | |||
| 126 | =pod | ||
| 127 | |||
| 128 | =encoding UTF-8 | ||
| 129 | |||
| 130 | =head1 NAME | ||
| 131 | |||
| 132 | DNS::Oterica::Node::Host - a host node | ||
| 133 | |||
| 134 | =head1 VERSION | ||
| 135 | |||
| 136 | version 0.313 | ||
| 137 | |||
| 138 | =head1 OVERVIEW | ||
| 139 | |||
| 140 | C<DNS::Oterica::Node::Host> represents an individual machine in DNS::Oterica. | ||
| 141 | A node has interfaces (which have IP addresses) and is part of a named domain. | ||
| 142 | |||
| 143 | =head1 PERL VERSION | ||
| 144 | |||
| 145 | This library should run on perls released even a long time ago. It should work | ||
| 146 | on any version of perl released in the last five years. | ||
| 147 | |||
| 148 | Although it may work on older versions of perl, no guarantee is made that the | ||
| 149 | minimum required version will not be increased. The version may be increased | ||
| 150 | for any reason, and there is no promise that patches will be accepted to lower | ||
| 151 | the minimum required perl. | ||
| 152 | |||
| 153 | =head1 ATTRIBUTES | ||
| 154 | |||
| 155 | =head2 hostname | ||
| 156 | |||
| 157 | This is the name of the host. B<It does not include the domain name.> | ||
| 158 | |||
| 159 | =head2 aliases | ||
| 160 | |||
| 161 | This is an arrayref of other fully-qualified names that refer to this host. | ||
| 162 | |||
| 163 | The accessor returns a list. | ||
| 164 | |||
| 165 | =head2 interfaces | ||
| 166 | |||
| 167 | This is an arrayref of pairs, each one an IP address and a network. | ||
| 168 | |||
| 169 | This attribute is pretty likely to change later. | ||
| 170 | |||
| 171 | =head2 location | ||
| 172 | |||
| 173 | The name of the network location of this host | ||
| 174 | |||
| 175 | =head2 ttl | ||
| 176 | |||
| 177 | This is the default TTL for the host's A records -- it doesn't affect the TTL | ||
| 178 | for records created by families to which the host belongs. If not provided, | ||
| 179 | it will be unset, and the default TTL is used. | ||
| 180 | |||
| 181 | =head1 METHODS | ||
| 182 | |||
| 183 | =head2 fqdn | ||
| 184 | |||
| 185 | This is the fully-qualified domain name of this host. | ||
| 186 | |||
| 187 | =head1 AUTHOR | ||
| 188 | |||
| 189 | Ricardo SIGNES <rjbs@semiotic.systems> | ||
| 190 | |||
| 191 | =head1 COPYRIGHT AND LICENSE | ||
| 192 | |||
| 193 | This software is copyright (c) 2021 by Ricardo SIGNES. | ||
| 194 | |||
| 195 | This is free software; you can redistribute it and/or modify it under | ||
| 196 | the same terms as the Perl 5 programming language system itself. | ||
| 197 | |||
| 198 | =cut | ||