| 1 | package BigIP::LTM::ParseConfig; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # CURRENTLY UNDER DEVELOMENT BY CARELINE | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION = '0.8.2'; | |||||||||||||||||||||||||||
| 6 | 1 | my $AUTOLOAD; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # Initialize the module | ||||||||||||||||||||||||||||
| 12 | sub new { | ||||||||||||||||||||||||||||
| 13 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | my $self = {}; | |||||||||||||||||||||||||||
| 16 | 0 | bless $self, $class; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | $self->{'ConfigFile'} = shift; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | return $self; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # Return a list of objects | ||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub monitors { return shift->_objectlist('monitor'); } | ||||||||||||||||||||||||||
|
Subroutine
monitors: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub nodes { return shift->_objectlist('ltm node'); } | ||||||||||||||||||||||||||
|
Subroutine
nodes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub partitions { return shift->_objectlist('partition'); } | ||||||||||||||||||||||||||
|
Subroutine
partitions: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub pools { return shift->_objectlist('ltm pool'); } | ||||||||||||||||||||||||||
|
Subroutine
pools: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub profiles { return shift->_objectlist('ltm profile'); } | ||||||||||||||||||||||||||
|
Subroutine
profiles: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub routes { return shift->_objectlist('net route'); } | ||||||||||||||||||||||||||
|
Subroutine
routes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub interfaces { return shift->_objectlist('net interface'); } | ||||||||||||||||||||||||||
|
Subroutine
interfaces: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub rules { return shift->_objectlist('ltm rule'); } | ||||||||||||||||||||||||||
|
Subroutine
rules: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub users { return shift->_objectlist('auth'); } | ||||||||||||||||||||||||||
|
Subroutine
users: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub virtuals { return shift->_objectlist('ltm virtual'); } | ||||||||||||||||||||||||||
|
Subroutine
virtuals: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # Return an object hash | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub monitor { return shift->_object( 'monitor', shift ); } | ||||||||||||||||||||||||||
|
Subroutine
monitor: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub node { return shift->_object( 'ltm node', shift ); } | ||||||||||||||||||||||||||
|
Subroutine
node: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub partition { return shift->_object( 'partition', shift ); } | ||||||||||||||||||||||||||
|
Subroutine
partition: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub pool { return shift->_object( 'ltm pool', shift ); } | ||||||||||||||||||||||||||
|
Subroutine
pool: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub profile { return shift->_object( 'ltm profile', shift ); } | ||||||||||||||||||||||||||
|
Subroutine
profile: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub route { return shift->_object( 'net route', shift ); } | ||||||||||||||||||||||||||
|
Subroutine
route: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub interface { return shift->_object( 'net interface', shift ); } | ||||||||||||||||||||||||||
|
Subroutine
interface: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub rule { return shift->_object( 'ltm rule', shift ); } | ||||||||||||||||||||||||||
|
Subroutine
rule: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub user { return shift->_object( 'auth', shift ); } | ||||||||||||||||||||||||||
|
Subroutine
user: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub virtual { return shift->_object( 'ltm virtual', shift ); } | ||||||||||||||||||||||||||
|
Subroutine
virtual: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # Return a list of pool members | ||||||||||||||||||||||||||||
| 48 | sub members { | ||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
members: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 50 | 0 | my $pool = shift; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | $self->{'Parsed'} ||= $self->_parse(); | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Parsed"} ||= $self->_parse
MC/DC0%0/2
$self->{"Parsed"} ||= $self->_parse
$self->{"Parsed"}
$self->_parse
Truth table0%0/3
A ||= B
A= $self->{"Parsed"}B= $self->_parse
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | return 0 unless $self->{'Parsed'}->{'pool'}->{$pool}->{'members'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if ( ref $self->{'Parsed'}->{'pool'}->{$pool}->{'members'} eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 0 | return @{ $self->{'Parsed'}->{'pool'}->{$pool}->{'members'} }; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | else { | ||||||||||||||||||||||||||||
| 60 | 0 | return $self->{'Parsed'}->{'pool'}->{$pool}->{'members'}; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | # Modify an object | ||||||||||||||||||||||||||||
| 65 | sub modify { | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
modify: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | my ($arg); | |||||||||||||||||||||||||||
| 69 | 0 | %{$arg} = @_; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | return 0 unless $arg->{'type'} && $arg->{'key'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$arg->{"type"} and $arg->{"key"}
MC/DC0%0/2
$arg->{"type"} and $arg->{"key"}
$arg->{"type"}
$arg->{"key"}
Truth table0%0/3
A and B
A= $arg->{"type"}B= $arg->{"key"}
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | my $obj = $arg->{'type'}; | |||||||||||||||||||||||||||
| 74 | 0 | my $key = $arg->{'key'}; | |||||||||||||||||||||||||||
| 75 | 0 | delete $arg->{'type'}; | |||||||||||||||||||||||||||
| 76 | 0 | delete $arg->{'key'}; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | $self->{'Parsed'} ||= $self->_parse(); | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Parsed"} ||= $self->_parse
MC/DC0%0/2
$self->{"Parsed"} ||= $self->_parse
$self->{"Parsed"}
$self->_parse
Truth table0%0/3
A ||= B
A= $self->{"Parsed"}B= $self->_parse
| |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | return 0 unless $self->{'Parsed'}->{$obj}->{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | foreach my $attr ( keys %{$arg} ) { | |||||||||||||||||||||||||||
| 83 | 0 | ▶ | next unless $self->{'Parsed'}->{$obj}->{$key}->{$attr}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 0 | $self->{'Modify'}->{$obj}->{$key}->{$attr} = $arg->{$attr}; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | return 1; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | # Write out a new configuration file | ||||||||||||||||||||||||||||
| 91 | sub write { | ||||||||||||||||||||||||||||
| 92 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
write: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my $file = shift || $self->{'ConfigFile'}; | ||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $self->{'ConfigFile'}
MC/DC0%0/2
shift() || $self->{'ConfigFile'}
shift()
$self->{'ConfigFile'}
Truth table0%0/3
A || B
A= shift()B= $self->{'ConfigFile'}
| |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | die "No changes found; no write necessary" unless $self->{'Modify'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | foreach my $obj ( | |||||||||||||||||||||||||||
| 98 | qw( self partition route user monitor auth profile node pool rule virtual ) | ||||||||||||||||||||||||||||
| 99 | ) | ||||||||||||||||||||||||||||
| 100 | { | ||||||||||||||||||||||||||||
| 101 | 0 | foreach my $key ( sort keys %{ $self->{'Parsed'}->{$obj} } ) { | |||||||||||||||||||||||||||
| 102 | 0 | ▶ | if ( $self->{'Modify'}->{$obj}->{$key} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 0 | $self->{'Output'} .= "$obj $key {\n"; | |||||||||||||||||||||||||||
| 104 | 0 | foreach my $attr ( $self->_order($obj) ) { | |||||||||||||||||||||||||||
| 105 | 0 | ▶ | next unless $self->{'Parsed'}->{$obj}->{$key}->{$attr}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | $self->{'Modify'}->{$obj}->{$key}->{$attr} | ||||||||||||||||||||||||||||
| 107 | 0 | ▶ | ||= $self->{'Parsed'}->{$obj}->{$key}->{$attr}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Modify"}{$obj}{$key}{$attr} ||= $self->{"Parsed"}{$obj}{$key}{$attr}
MC/DC0%0/2
$self->{"Modify"}{$obj}{$key}{$attr} ||= $self->{"Parsed"}{$obj}{$key}{$attr}
$self->{"Modify"}{$obj}{$key}{$attr}
$self->{"Parsed"}{$obj}{$key}{$attr}
Truth table0%0/3
A ||= B
A= $self->{"Modify"}{$obj}{$key}{$attr}B= $self->{"Parsed"}{$obj}{$key}{$attr}
| |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if (ref $self->{'Modify'}->{$obj}->{$key}->{$attr} eq | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 'ARRAY' ) | ||||||||||||||||||||||||||||
| 110 | { | ||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if ( @{ $self->{'Modify'}->{$obj}->{$key}->{$attr} } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | > 1 ) | ||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||
| 114 | 0 | $self->{'Output'} .= " $attr\n"; | |||||||||||||||||||||||||||
| 115 | 0 | foreach my $val ( | |||||||||||||||||||||||||||
| 116 | 0 | @{ $self->{'Modify'}->{$obj}->{$key}->{$attr} | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | ) | ||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||
| 120 | 0 | $self->{'Output'} .= " $val\n"; | |||||||||||||||||||||||||||
| 121 | 0 | ▶ | if ( $self->{'Parsed'}->{$obj}->{$key} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | ->{'_xtra'}->{$val} ) | ||||||||||||||||||||||||||||
| 123 | { | ||||||||||||||||||||||||||||
| 124 | $self->{'Output'} | ||||||||||||||||||||||||||||
| 125 | .= ' ' | ||||||||||||||||||||||||||||
| 126 | . $self->{'Parsed'}->{$obj}->{$key} | ||||||||||||||||||||||||||||
| 127 | 0 | ->{'_xtra'}->{$val} . "\n"; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | else { | ||||||||||||||||||||||||||||
| 132 | $self->{'Output'} | ||||||||||||||||||||||||||||
| 133 | .= " $attr " | ||||||||||||||||||||||||||||
| 134 | . $self->{'Modify'}->{$obj}->{$key} | ||||||||||||||||||||||||||||
| 135 | 0 | ->{$attr}[0] . "\n"; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | else { | ||||||||||||||||||||||||||||
| 139 | $self->{'Output'} | ||||||||||||||||||||||||||||
| 140 | .= " $attr " | ||||||||||||||||||||||||||||
| 141 | 0 | . $self->{'Modify'}->{$obj}->{$key}->{$attr} | |||||||||||||||||||||||||||
| 142 | . "\n"; | ||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | 0 | $self->{'Output'} .= "}\n"; | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | else { | ||||||||||||||||||||||||||||
| 148 | 0 | $self->{'Output'} .= $self->{'Raw'}->{$obj}->{$key}; | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 0 | ▶ | open FILE, ">$file" || return 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
">$file" || (return 0)
MC/DC0%0/1
">$file" || (return 0)
">$file"
Truth table0%0/2
A
A= ">$file"
| |||||||||||||||||||||||||||||
| 154 | 0 | print FILE $self->{'Output'}; | |||||||||||||||||||||||||||
| 155 | 0 | close FILE; | |||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 0 | return 1; | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | # Return an object hash | ||||||||||||||||||||||||||||
| 161 | sub _object { | ||||||||||||||||||||||||||||
| 162 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_object: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 163 | 0 | my $obj = shift; | |||||||||||||||||||||||||||
| 164 | 0 | my $var = shift; | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 0 | ▶ | $self->{'Parsed'} ||= $self->_parse(); | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Parsed"} ||= $self->_parse
MC/DC0%0/2
$self->{"Parsed"} ||= $self->_parse
$self->{"Parsed"}
$self->_parse
Truth table0%0/3
A ||= B
A= $self->{"Parsed"}B= $self->_parse
| |||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | ▶ | return $self->{'Parsed'}->{$obj}->{$var} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'Parsed'}{$obj}{$var} || 0
MC/DC0%0/1
$self->{'Parsed'}{$obj}{$var} || 0
$self->{'Parsed'}{$obj}{$var}
Truth table0%0/2
A
A= $self->{'Parsed'}{$obj}{$var}
| |||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | # Return a list of objects | ||||||||||||||||||||||||||||
| 172 | sub _objectlist { | ||||||||||||||||||||||||||||
| 173 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_objectlist: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 174 | 0 | my $obj = shift; | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | ▶ | $self->{'Parsed'} ||= $self->_parse(); | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Parsed"} ||= $self->_parse
MC/DC0%0/2
$self->{"Parsed"} ||= $self->_parse
$self->{"Parsed"}
$self->_parse
Truth table0%0/3
A ||= B
A= $self->{"Parsed"}B= $self->_parse
| |||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ( $self->{'Parsed'}->{$obj} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 0 | return keys %{ $self->{'Parsed'}->{$obj} }; | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | else { | ||||||||||||||||||||||||||||
| 182 | 0 | return 0; | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | # Define object attribute ordering | ||||||||||||||||||||||||||||
| 187 | sub _order { | ||||||||||||||||||||||||||||
| 188 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_order: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 0 | for (shift) { | |||||||||||||||||||||||||||
| 191 | 0 | ▶ | /auth/ && return qw( bind login search servers service ssl user ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | 0 | ▶ | /monitor/ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | && return | ||||||||||||||||||||||||||||
| 194 | qw( default base debug filter mandatoryattrs password security username interval timeout manual dest recv send ); | ||||||||||||||||||||||||||||
| 195 | 0 | ▶ | /node/ && return qw( monitor screen ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 196 | 0 | ▶ | /partition/ && return qw( description ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 0 | ▶ | /pool/ && return qw( lb nat monitor members ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 0 | ▶ | /self/ && return qw( netmask unit floating vlan allow ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | 0 | ▶ | /user/ && return qw( password description id group home shell role ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 0 | ▶ | /virtual/ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | && return | ||||||||||||||||||||||||||||
| 202 | qw( translate snat pool destination ip rules profiles persist ); | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 0 | return 0; | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | # Parse the configuration file | ||||||||||||||||||||||||||||
| 209 | sub _parse { | ||||||||||||||||||||||||||||
| 210 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_parse: not called CC=24 SCAR=55.4
| |||||||||||||||||||||||||||||
| 211 | 0 | ▶ | my $file = shift || $self->{'ConfigFile'}; | ||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $self->{'ConfigFile'}
MC/DC0%0/2
shift() || $self->{'ConfigFile'}
shift()
$self->{'ConfigFile'}
Truth table0%0/3
A || B
A= shift()B= $self->{'ConfigFile'}
| |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | die "File not found: $self->{'ConfigFile'}\n" | ||||||||||||||||||||||||||||
| 214 | 0 | ▶ | unless -e $self->{'ConfigFile'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 0 | ▶ | open FILE, $file || return 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$file || (return 0)
MC/DC0%0/1
$file || (return 0)
$file
Truth table0%0/2
A
A= $file
| |||||||||||||||||||||||||||||
| 217 | 0 | my @file = <FILE>; | |||||||||||||||||||||||||||
| 218 | 0 | close FILE; | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | my ( $data, $parsed ); | |||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | ▶ | until ( !$file[0] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 0 | my $ln = shift @file; | |||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if ( $ln | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | =~ /^(auth|patition|cli|ltm node|ltm pool|ltm profile|ltm rule|ltm virtual|net self|net route|net interface)\s(.*)\s\{(\s?\}?)$/ | ||||||||||||||||||||||||||||
| 227 | ) | ||||||||||||||||||||||||||||
| 228 | { | ||||||||||||||||||||||||||||
| 229 | 0 | $data->{'obj'} = $1; | |||||||||||||||||||||||||||
| 230 | 0 | $data->{'key'} = $2; | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 0 | ▶ | if ( $data->{'obj'} && $data->{'key'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$data->{"obj"} and $data->{"key"}
MC/DC0%0/2
$data->{"obj"} and $data->{"key"}
$data->{"obj"}
$data->{"key"}
Truth table0%0/3
A and B
A= $data->{"obj"}B= $data->{"key"}
| |||||||||||||||||||||||||||||
| 234 | 0 | $self->{'Raw'}->{ $data->{'obj'} }->{ $data->{'key'} } .= $ln; | |||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | #缩è¿ä¸º4ä¸{}é空åå¸ | ||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if ( $ln =~ /^\s{4}(\S+)\s\{$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | 0 | $data->{'list1'} = $1; | |||||||||||||||||||||||||||
| 239 | 0 | next; | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | #缩è¿ä¸º8ä¸{}é空åå¸ | ||||||||||||||||||||||||||||
| 243 | 0 | ▶ | if ( $ln =~ /^\s{8}(\S+)\s\{$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | 0 | $data->{'list2'} = $1; | |||||||||||||||||||||||||||
| 245 | 0 | next; | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | #ææä»£ç åç»æç¬¦å¹¶æ¸ ç©º | ||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if ( $ln =~ /^\s{4}\}$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | 0 | delete $data->{'list1'}; | |||||||||||||||||||||||||||
| 251 | 0 | next; | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | #ææä»£ç åç»æç¬¦å¹¶æ¸ ç©º | ||||||||||||||||||||||||||||
| 255 | 0 | ▶ | if ( $ln =~ /^\s{8}\}$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | 0 | delete $data->{'list2'}; | |||||||||||||||||||||||||||
| 257 | 0 | next; | |||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | #缩è¿ä¸º4䏿ºå¸¦{}空åå¸ | ||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if ( $ln =~ /^\s{4}(\S+)\s\{\s\}$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 262 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 263 | 0 | $parsed->{ $data->{'obj'} }->{ $data->{'key'} }->{$1} = undef; | |||||||||||||||||||||||||||
| 264 | 1 | ▶ | use strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 265 | 0 | next; | |||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if ( $data->{'list1'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | #缩è¿ä¸º8䏿ºå¸¦{}空åå¸ | ||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if ( $ln =~ /^\s{8}(\S+)\s\{\s\}$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 272 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 273 | $parsed->{ $data->{'obj'} }->{ $data->{'key'} } | ||||||||||||||||||||||||||||
| 274 | 0 | ->{ $data->{'list1'} }->{$1} = undef; | |||||||||||||||||||||||||||
| 275 | 1 | ▶ | use strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 276 | 0 | next; | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | #缩è¿ä¸º8ä¸ä¸ºé®å¼å¯¹ | ||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if ( $ln =~ /^\s{8}(\S+)\s(\S+)$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 281 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 282 | $parsed->{ $data->{'obj'} }->{ $data->{'key'} } | ||||||||||||||||||||||||||||
| 283 | 0 | ->{ $data->{'list1'} }->{$1} = $2; | |||||||||||||||||||||||||||
| 284 | 1 | ▶ | use strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 285 | 0 | next; | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | #缩è¿ä¸º8ä¸ä¸ºæ éæ°æ® | ||||||||||||||||||||||||||||
| 289 | 0 | ▶ | if ( $ln =~ /^\s{8}(\S+)$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 291 | $parsed->{ $data->{'obj'} }->{ $data->{'key'} } | ||||||||||||||||||||||||||||
| 292 | 0 | ->{ $data->{'list1'} } = $1; | |||||||||||||||||||||||||||
| 293 | 1 | ▶ | use strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 294 | 0 | next; | |||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 0 | ▶ | if ( $data->{'list2'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | #缩è¿ä¸º12ä¸ä¸ºç©ºåå¸(ææ¶å¿½ç¥ç¼©è¿ä¸º12ä¸åµå¥é®å¼å¯¹çæ¸ ç©º) -- å¾ å®å | ||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ( $ln =~ /^\s{12}(\S+)\s\{\s\}$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 302 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 303 | $parsed->{ $data->{'obj'} }->{ $data->{'key'} } | ||||||||||||||||||||||||||||
| 304 | 0 | ->{ $data->{'list1'} }->{ $data->{'list2'} }->{$1} | |||||||||||||||||||||||||||
| 305 | = undef; | ||||||||||||||||||||||||||||
| 306 | 1 | ▶ | use strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 307 | 0 | next; | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | #缩è¿ä¸º12ä¸ä¸ºé®å¼å¯¹ | ||||||||||||||||||||||||||||
| 311 | 0 | ▶ | if ( $ln =~ /^\s{12}(\S+)\s(\S+)$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 312 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 313 | $parsed->{ $data->{'obj'} }->{ $data->{'key'} } | ||||||||||||||||||||||||||||
| 314 | 0 | ->{ $data->{'list1'} }->{ $data->{'list2'} }->{$1} | |||||||||||||||||||||||||||
| 315 | = $2; | ||||||||||||||||||||||||||||
| 316 | 1 | ▶ | use strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 317 | 0 | next; | |||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | #å åºçç¥è§£æ | ||||||||||||||||||||||||||||
| 322 | 0 | ▶ | if ( $ln =~ /^\s{4}(\S+)\s(\S+)\s+?$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 323 | 0 | say $ln; | |||||||||||||||||||||||||||
| 324 | 0 | $parsed->{ $data->{'obj'} }->{ $data->{'key'} }->{$1} = $2; | |||||||||||||||||||||||||||
| 325 | 0 | next; | |||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | # Fill in ill-formatted objects | ||||||||||||||||||||||||||||
| 331 | 0 | foreach my $obj ( keys %{ $self->{'Raw'} } ) { | |||||||||||||||||||||||||||
| 332 | 0 | foreach my $key ( keys %{ $self->{'Raw'}->{$obj} } ) { | |||||||||||||||||||||||||||
| 333 | 0 | ▶ | $parsed->{$obj}->{$key} ||= $self->{'Raw'}->{$obj}->{$key}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$parsed->{$obj}{$key} ||= $self->{"Raw"}{$obj}{$key}
MC/DC0%0/2
$parsed->{$obj}{$key} ||= $self->{"Raw"}{$obj}{$key}
$parsed->{$obj}{$key}
$self->{"Raw"}{$obj}{$key}
Truth table0%0/3
A ||= B
A= $parsed->{$obj}{$key}B= $self->{"Raw"}{$obj}{$key}
| |||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 0 | return $parsed; | |||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | 1 | 1; | |||||||||||||||||||||||||||