| 1 | package Net::ISC::DHCPd::Config::Subnet6; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Net::ISC::DHCPd::Config::Subnet6 - Subnet6 config parameter | ||
| 6 | |||
| 7 | =head1 DESCRIPTION | ||
| 8 | |||
| 9 | See L<Net::ISC::DHCPd::Config::Role> for methods and attributes without | ||
| 10 | documentation. | ||
| 11 | |||
| 12 | An instance from this class, comes from / will produce: | ||
| 13 | |||
| 14 | subnet6 $address_attribute_value { | ||
| 15 | $options_attribute_value | ||
| 16 | $filename_attribute_value | ||
| 17 | $range_attribute_value | ||
| 18 | $pool_attribute_value | ||
| 19 | $hosts_attribute_value | ||
| 20 | } | ||
| 21 | |||
| 22 | =head1 SYNOPSIS | ||
| 23 | |||
| 24 | See L<Net::ISC::DHCPd::Config/SYNOPSIS>. | ||
| 25 | |||
| 26 | =cut | ||
| 27 | |||
| 28 | use Moose; | ||
| 29 | use NetAddr::IP qw(:lower); | ||
| 30 | |||
| 31 | with 'Net::ISC::DHCPd::Config::Role'; | ||
| 32 | |||
| 33 | =head2 children | ||
| 34 | |||
| 35 | See L<Net::ISC::DHCPd::Config::Role/children>. | ||
| 36 | |||
| 37 | =cut | ||
| 38 | sub children { | ||
| 39 | return qw/ | ||
| 40 | Net::ISC::DHCPd::Config::Host | ||
| 41 | Net::ISC::DHCPd::Config::Pool | ||
| 42 | Net::ISC::DHCPd::Config::Range6 | ||
| 43 | Net::ISC::DHCPd::Config::Filename | ||
| 44 | Net::ISC::DHCPd::Config::Option | ||
| 45 | Net::ISC::DHCPd::Config::Class | ||
| 46 | Net::ISC::DHCPd::Config::KeyValue | ||
| 47 | Net::ISC::DHCPd::Config::Block | ||
| 48 | /; | ||
| 49 | } | ||
| 50 | |||
| 51 | __PACKAGE__->create_children(__PACKAGE__->children()); | ||
| 52 | |||
| 53 | =head1 ATTRIBUTES | ||
| 54 | |||
| 55 | =head2 options | ||
| 56 | |||
| 57 | A list of parsed L<Net::ISC::DHCPd::Config::Option> objects. | ||
| 58 | |||
| 59 | =head2 ranges | ||
| 60 | |||
| 61 | A list of parsed L<Net::ISC::DHCPd::Config::Range> objects. | ||
| 62 | |||
| 63 | =head2 hosts | ||
| 64 | |||
| 65 | A list of parsed L<Net::ISC::DHCPd::Config::Host> objects. | ||
| 66 | |||
| 67 | =head2 filenames | ||
| 68 | |||
| 69 | A list of parsed L<Net::ISC::DHCPd::Config::Filename> objects. There can | ||
| 70 | be only be one node in this list. | ||
| 71 | |||
| 72 | =cut | ||
| 73 | |||
| 74 | before add_filename => sub { | ||
| 75 | if(0 < int @{ $_[0]->filenames }) { | ||
| 76 | confess 'Subnet6 cannot have more than one filename'; | ||
| 77 | } | ||
| 78 | }; | ||
| 79 | |||
| 80 | =head2 pools | ||
| 81 | |||
| 82 | A list of parsed L<Net::ISC::DHCPd::Config::Pool> objects. | ||
| 83 | |||
| 84 | =head2 address | ||
| 85 | |||
| 86 | This attribute holds an instance of L<NetAddr::IP>, and represents | ||
| 87 | the ip address of this subnet. | ||
| 88 | |||
| 89 | =cut | ||
| 90 | |||
| 91 | has address => ( | ||
| 92 | is => 'ro', | ||
| 93 | isa => 'Object', | ||
| 94 | ); | ||
| 95 | |||
| 96 | =head2 regex | ||
| 97 | |||
| 98 | See L<Net::ISC::DHCPd::Config/regex>. | ||
| 99 | |||
| 100 | =cut | ||
| 101 | |||
| 102 | our $regex = qr{^ \s* subnet6 \s+ (\S+) }x; | ||
| 103 | |||
| 104 | =head1 METHODS | ||
| 105 | |||
| 106 | =head2 captured_to_args | ||
| 107 | |||
| 108 | See L<Net::ISC::DHCPd::Config::Role/captured_to_args>. | ||
| 109 | |||
| 110 | =cut | ||
| 111 | |||
| 112 | sub captured_to_args { | ||
| 113 | return { address => NetAddr::IP->new($_[0]) }; | ||
| 114 | } | ||
| 115 | |||
| 116 | =head2 generate | ||
| 117 | |||
| 118 | See L<Net::ISC::DHCPd::Config::Role/generate>. | ||
| 119 | |||
| 120 | =cut | ||
| 121 | |||
| 122 | sub generate { | ||
| 123 | my $self = shift; | ||
| 124 | my $net = $self->address; | ||
| 125 | |||
| 126 | return( | ||
| 127 | 'subnet6 ' .$net->short() .'/' . $net->masklen() . ' {', | ||
| 128 | $self->_generate_config_from_children, | ||
| 129 | '}', | ||
| 130 | ); | ||
| 131 | } | ||
| 132 | |||
| 133 | =head1 COPYRIGHT & LICENSE | ||
| 134 | |||
| 135 | =head1 AUTHOR | ||
| 136 | |||
| 137 | See L<Net::ISC::DHCPd>. | ||
| 138 | |||
| 139 | =cut | ||
| 140 | __PACKAGE__->meta->make_immutable; | ||
| 141 | 1; |