| 1 | package Net::ISC::DHCPd::Config::SharedNetwork; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | Net::ISC::DHCPd::Config::SharedNetwork - Shared-network 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 one of the | ||||||||||
| 13 | blocks below, dependent on L</name> is set or not. | ||||||||||
| 14 | |||||||||||
| 15 | shared-network $name_attribute_value { | ||||||||||
| 16 | $keyvalues_attribute_value | ||||||||||
| 17 | $subnets_attribute_value | ||||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | shared-network { | ||||||||||
| 21 | $keyvalues_attribute_value | ||||||||||
| 22 | $subnets_attribute_value | ||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | =head1 SYNOPSIS | ||||||||||
| 26 | |||||||||||
| 27 | See L<Net::ISC::DHCPd::Config/SYNOPSIS>. | ||||||||||
| 28 | |||||||||||
| 29 | =cut | ||||||||||
| 30 | |||||||||||
| 31 | 27 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | |||||||||||
| 33 | 27 | with 'Net::ISC::DHCPd::Config::Role'; | |||||||||
| 34 | |||||||||||
| 35 | =head2 children | ||||||||||
| 36 | |||||||||||
| 37 | See L<Net::ISC::DHCPd::Config::Role/children>. | ||||||||||
| 38 | |||||||||||
| 39 | =cut | ||||||||||
| 40 | 39 | ▶ | sub children { | ||||||||
|
Subroutine
children: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 41 | 39 | return qw/ | |||||||||
| 42 | Net::ISC::DHCPd::Config::Host | ||||||||||
| 43 | Net::ISC::DHCPd::Config::Subnet | ||||||||||
| 44 | Net::ISC::DHCPd::Config::Subnet6 | ||||||||||
| 45 | Net::ISC::DHCPd::Config::KeyValue | ||||||||||
| 46 | /; | ||||||||||
| 47 | } | ||||||||||
| 48 | 27 | __PACKAGE__->create_children(__PACKAGE__->children()); | |||||||||
| 49 | |||||||||||
| 50 | =head1 ATTRIBUTES | ||||||||||
| 51 | |||||||||||
| 52 | =head2 subnets | ||||||||||
| 53 | |||||||||||
| 54 | A list of parsed L<Net::ISC::DHCPd::Config::Subnet> objects. | ||||||||||
| 55 | |||||||||||
| 56 | =head2 keyvalues | ||||||||||
| 57 | |||||||||||
| 58 | A list of parsed L<Net::ISC::DHCPd::Config::KeyValue> objects. | ||||||||||
| 59 | |||||||||||
| 60 | =head2 name | ||||||||||
| 61 | |||||||||||
| 62 | Holds a string representing the name of this shared network. | ||||||||||
| 63 | Will be omitted if it contains an empty string. | ||||||||||
| 64 | |||||||||||
| 65 | =cut | ||||||||||
| 66 | |||||||||||
| 67 | 27 | has name => ( | |||||||||
| 68 | is => 'ro', | ||||||||||
| 69 | isa => 'Str', | ||||||||||
| 70 | ); | ||||||||||
| 71 | |||||||||||
| 72 | =head2 quoted | ||||||||||
| 73 | |||||||||||
| 74 | This flag tells if the shared-network name should be quoted or not. | ||||||||||
| 75 | |||||||||||
| 76 | =cut | ||||||||||
| 77 | |||||||||||
| 78 | 27 | has quoted => ( | |||||||||
| 79 | is => 'ro', | ||||||||||
| 80 | isa => 'Bool', | ||||||||||
| 81 | ); | ||||||||||
| 82 | |||||||||||
| 83 | =head2 regex | ||||||||||
| 84 | |||||||||||
| 85 | See L<Net::ISC::DHCPd::Config::Role/regex>. | ||||||||||
| 86 | |||||||||||
| 87 | =cut | ||||||||||
| 88 | |||||||||||
| 89 | 27 | our $regex = qr{^\s* shared-network \s+ ([\w\.-]+|".*?")? }x; | |||||||||
| 90 | |||||||||||
| 91 | =head1 METHODS | ||||||||||
| 92 | |||||||||||
| 93 | =head2 captured_to_args | ||||||||||
| 94 | |||||||||||
| 95 | See L<Net::ISC::DHCPd::Config::Role/captured_to_args>. | ||||||||||
| 96 | |||||||||||
| 97 | =cut | ||||||||||
| 98 | |||||||||||
| 99 | 8 | ▶ | sub captured_to_args { | ||||||||
|
Subroutine
captured_to_args: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 100 | 8 | my $name = shift; | |||||||||
| 101 | 8 | my $quoted = 0; | |||||||||
| 102 | 8 | ▶ | return if !defined($name); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 103 | |||||||||||
| 104 | 6 | ▶ | $quoted = 1 if ($name =~ s/^"(.*)"$/$1/g); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 105 | |||||||||||
| 106 | return { | ||||||||||
| 107 | 6 | name => $name, | |||||||||
| 108 | quoted => $quoted, | ||||||||||
| 109 | }; | ||||||||||
| 110 | } | ||||||||||
| 111 | |||||||||||
| 112 | |||||||||||
| 113 | =head2 generate | ||||||||||
| 114 | |||||||||||
| 115 | See L<Net::ISC::DHCPd::Config::Role/generate>. | ||||||||||
| 116 | |||||||||||
| 117 | =cut | ||||||||||
| 118 | |||||||||||
| 119 | 5 | ▶ | sub generate { | ||||||||
|
Subroutine
generate: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 120 | 5 | my $self = shift; | |||||||||
| 121 | |||||||||||
| 122 | 5 | ▶ | if (defined($self->name)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 123 | 4 | my $name = $self->name; | |||||||||
| 124 | 4 | ▶ | return 'shared-network ' . ($self->quoted ? qq("$name") : $self->name) . ' {', $self->_generate_config_from_children, '}'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 125 | } | ||||||||||
| 126 | |||||||||||
| 127 | 1 | return 'shared-network {', $self->_generate_config_from_children, '}'; | |||||||||
| 128 | } | ||||||||||
| 129 | |||||||||||
| 130 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 131 | |||||||||||
| 132 | =head1 AUTHOR | ||||||||||
| 133 | |||||||||||
| 134 | See L<Net::ISC::DHCPd>. | ||||||||||
| 135 | |||||||||||
| 136 | =cut | ||||||||||
| 137 | 27 | __PACKAGE__->meta->make_immutable; | |||||||||
| 138 | 27 | 1; | |||||||||