| 1 | package BigIP::GTM::ParseConfig; | ||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||
| 3 | # CURRENTLY UNDER DEVELOMENT BY WENWU YAN < careline@126.com > | ||||||||||||||||||||||||||||||
| 4 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 5 | # The contents of this file are subject to the iControl Public License | ||||||||||||||||||||||||||||||
| 6 | # Version 4.5 (the "License"); you may not use this file except in | ||||||||||||||||||||||||||||||
| 7 | # compliance with the License. You may obtain a copy of the License at | ||||||||||||||||||||||||||||||
| 8 | # http://www.f5.com/. | ||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||
| 10 | # Software distributed under the License is distributed on an "AS IS" | ||||||||||||||||||||||||||||||
| 11 | # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See | ||||||||||||||||||||||||||||||
| 12 | # the License for the specific language governing rights and limitations | ||||||||||||||||||||||||||||||
| 13 | # under the License. | ||||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||||
| 15 | # The Original Code is iControl Code and related documentation | ||||||||||||||||||||||||||||||
| 16 | # distributed by F5. | ||||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||||
| 18 | # The Initial Developer of the Original Code is F5 Networks, | ||||||||||||||||||||||||||||||
| 19 | # Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2019 F5 Networks, | ||||||||||||||||||||||||||||||
| 20 | # Inc. All Rights Reserved. iControl (TM) is a registered trademark of F5 Networks, Inc. | ||||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||||
| 22 | # Alternatively, the contents of this file may be used under the terms | ||||||||||||||||||||||||||||||
| 23 | # of the GNU General Public License (the "GPL"), in which case the | ||||||||||||||||||||||||||||||
| 24 | # provisions of GPL are applicable instead of those above. If you wish | ||||||||||||||||||||||||||||||
| 25 | # to allow use of your version of this file only under the terms of the | ||||||||||||||||||||||||||||||
| 26 | # GPL and not to allow others to use your version of this file under the | ||||||||||||||||||||||||||||||
| 27 | # License, indicate your decision by deleting the provisions above and | ||||||||||||||||||||||||||||||
| 28 | # replace them with the notice and other provisions required by the GPL. | ||||||||||||||||||||||||||||||
| 29 | # If you do not delete the provisions above, a recipient may use your | ||||||||||||||||||||||||||||||
| 30 | # version of this file under either the License or the GPL. | ||||||||||||||||||||||||||||||
| 31 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||
| 33 | 1 | our $VERSION = '0.8.2'; | |||||||||||||||||||||||||||||
| 34 | 1 | my $AUTOLOAD; | |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | use 5.012; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 39 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||
| 41 | # Initialize the module | ||||||||||||||||||||||||||||||
| 42 | sub new { | ||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||
| 45 | 0 | my $self = {}; | |||||||||||||||||||||||||||||
| 46 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||
| 48 | 0 | $self->{'ConfigFile'} = shift; | |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||
| 50 | 0 | return $self; | |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||
| 53 | # Return a list of objects | ||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub regions { return shift->_objectlist('gtm region'); } | ||||||||||||||||||||||||||||
|
Subroutine
regions: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub wideips { return shift->_objectlist('gtm wideip'); } | ||||||||||||||||||||||||||||
|
Subroutine
wideips: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub pools { return shift->_objectlist('gtm pool'); } | ||||||||||||||||||||||||||||
|
Subroutine
pools: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub servers { return shift->_objectlist('gtm server'); } | ||||||||||||||||||||||||||||
|
Subroutine
servers: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub monitors { return shift->_objectlist('gtm monitor'); } | ||||||||||||||||||||||||||||
|
Subroutine
monitors: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub partitions { return shift->_objectlist('partition'); } | ||||||||||||||||||||||||||||
|
Subroutine
partitions: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub routes { return shift->_objectlist('net route'); } | ||||||||||||||||||||||||||||
|
Subroutine
routes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub selfs { return shift->_objectlist('net self'); } | ||||||||||||||||||||||||||||
|
Subroutine
selfs: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub vlans { return shift->_objectlist('net vlan'); } | ||||||||||||||||||||||||||||
|
Subroutine
vlans: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub trunks { return shift->_objectlist('net trunk'); } | ||||||||||||||||||||||||||||
|
Subroutine
trunks: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub interfaces { return shift->_objectlist('net interface'); } | ||||||||||||||||||||||||||||
|
Subroutine
interfaces: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub mgmt_routes { return shift->_objectlist('sys management-route'); } | ||||||||||||||||||||||||||||
|
Subroutine
mgmt_routes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub users { return shift->_objectlist('auth user'); } | ||||||||||||||||||||||||||||
|
Subroutine
users: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||
| 68 | # Return an object hash | ||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub region { return shift->_object( 'gtm region', shift ); } | ||||||||||||||||||||||||||||
|
Subroutine
region: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub wideip { return shift->_object( 'gtm wideip', shift ); } | ||||||||||||||||||||||||||||
|
Subroutine
wideip: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub pool { return shift->_object( 'gtm pool', shift ); } | ||||||||||||||||||||||||||||
|
Subroutine
pool: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub server { return shift->_object( 'gtm server', shift ); } | ||||||||||||||||||||||||||||
|
Subroutine
server: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub monitor { return shift->_object( 'gtm monitor', shift ); } | ||||||||||||||||||||||||||||
|
Subroutine
monitor: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub partition { return shift->_object( 'partition', shift ); } | ||||||||||||||||||||||||||||
|
Subroutine
partition: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub self { return shift->_object( 'net self', shift ); } | ||||||||||||||||||||||||||||
|
Subroutine
self: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub route { return shift->_object( 'net route', shift ); } | ||||||||||||||||||||||||||||
|
Subroutine
route: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub vlan { return shift->_object( 'net vlan', shift ); } | ||||||||||||||||||||||||||||
|
Subroutine
vlan: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub trunk { return shift->_object( 'net trunk', shift ); } | ||||||||||||||||||||||||||||
|
Subroutine
trunk: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub interface { return shift->_object( 'net interface', shift ); } | ||||||||||||||||||||||||||||
|
Subroutine
interface: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | sub mgmt_route { return shift->_object( 'sys management-route', shift ); } | ||||||||||||||||||||||||||||
|
Subroutine
mgmt_route: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub snmp { return shift->_object( 'sys', 'snmp' ); } | ||||||||||||||||||||||||||||
|
Subroutine
snmp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub sshd { return shift->_object( 'sys', 'sshd' ); } | ||||||||||||||||||||||||||||
|
Subroutine
sshd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub ntp { return shift->_object( 'sys', 'ntp' ); } | ||||||||||||||||||||||||||||
|
Subroutine
ntp: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub syslog { return shift->_object( 'sys', 'syslog' ); } | ||||||||||||||||||||||||||||
|
Subroutine
syslog: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub user { return shift->_object( 'auth user', shift ); } | ||||||||||||||||||||||||||||
|
Subroutine
user: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||
| 87 | #return a list of funcs | ||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||
| 89 | sub funcs { | ||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||
|
Subroutine
funcs: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||
| 92 | 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
| |||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | return keys %{ $self->{'Parsed'} } || 0; | ||||||||||||||||||||||||||||
|
Condition0%0/2
keys %{$$self{'Parsed'};} || 0
MC/DC0%0/1
keys %{$$self{'Parsed'};} || 0
keys %{$$self{'Parsed'};}
Truth table0%0/2
A
A= keys %{$$self{'Parsed'};}
| |||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||
| 97 | # Return a list of pool members | ||||||||||||||||||||||||||||||
| 98 | sub members { | ||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||
|
Subroutine
members: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 100 | 0 | my $pool = shift; | |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||
| 102 | 0 | my $members; | |||||||||||||||||||||||||||||
| 103 | 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
| |||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | return 0 unless $self->{'Parsed'}->{'gtm pool'}->{$pool}->{'members'}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ( ref $self->{'Parsed'}->{'gtm pool'}->{$pool}->{'members'} eq 'HASH' ) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 108 | { | ||||||||||||||||||||||||||||||
| 109 | return | ||||||||||||||||||||||||||||||
| 110 | 0 | map {s/\:/\//r} | |||||||||||||||||||||||||||||
| 111 | ( | ||||||||||||||||||||||||||||||
| 112 | 0 | keys %{ $self->{'Parsed'}->{'gtm pool'}->{$pool}->{'members'} } ); | |||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||
| 114 | else { | ||||||||||||||||||||||||||||||
| 115 | 0 | return $self->{'Parsed'}->{'gtm pool'}->{$pool}->{'members'}; | |||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||
| 119 | #Return a list of VS | ||||||||||||||||||||||||||||||
| 120 | sub wideips_all { | ||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||
|
Subroutine
wideips_all: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 122 | 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
| |||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | return 0 unless $self->{'Parsed'}->{'gtm wideip'}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||
| 126 | # Loop for wideips() | ||||||||||||||||||||||||||||||
| 127 | 0 | foreach ( $self->wideips() ) { | |||||||||||||||||||||||||||||
| 128 | 0 | my $pools = $self->wideip($_)->{pools}; | |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||
| 130 | 0 | foreach my $pool ( keys %{$pools} ) { | |||||||||||||||||||||||||||||
| 131 | my $members = $self->pool($pool)->{members} | ||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if defined $self->pool($pool); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||
| 134 | 0 | $self->wideip($_)->{"pools_members"} = $members; | |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||
| 136 | 0 | foreach my $serverAndVs ( keys %{$members} ) { | |||||||||||||||||||||||||||||
| 137 | 0 | my ( $server, $vs ) = split( /\:/, $serverAndVs ); | |||||||||||||||||||||||||||||
| 138 | 0 | my $details = $self->server($server); | |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | $self->wideip($_)->{"servers_details"}{$serverAndVs} = $server | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 141 | if $details; | ||||||||||||||||||||||||||||||
| 142 | $self->wideip($_)->{"vs_details"}{$serverAndVs} | ||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | = $details->{"virtual-servers"}{$vs} | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 144 | if $vs; | ||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||
| 149 | 0 | return $self->{Parsed}{"gtm wideip"}; | |||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||
| 152 | # Modify an object | ||||||||||||||||||||||||||||||
| 153 | sub modify { | ||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||
|
Subroutine
modify: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||
| 156 | 0 | my ($arg); | |||||||||||||||||||||||||||||
| 157 | 0 | %{$arg} = @_; | |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||
| 159 | 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"}
| |||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||
| 161 | 0 | my $obj = $arg->{'type'}; | |||||||||||||||||||||||||||||
| 162 | 0 | my $key = $arg->{'key'}; | |||||||||||||||||||||||||||||
| 163 | 0 | delete $arg->{'type'}; | |||||||||||||||||||||||||||||
| 164 | 0 | delete $arg->{'key'}; | |||||||||||||||||||||||||||||
| 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 0 unless $self->{'Parsed'}->{$obj}->{$key}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||
| 170 | 0 | foreach my $attr ( keys %{$arg} ) { | |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | next unless $self->{'Parsed'}->{$obj}->{$key}->{$attr}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 172 | 0 | $self->{'Modify'}->{$obj}->{$key}->{$attr} = $arg->{$attr}; | |||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||
| 175 | 0 | return 1; | |||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||
| 178 | # Write out a new configuration file | ||||||||||||||||||||||||||||||
| 179 | sub write { | ||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||
|
Subroutine
write: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||
| 181 | 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'}
| |||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | die "No changes found; no write necessary" unless $self->{'Modify'}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||
| 185 | 0 | foreach my $obj ( | |||||||||||||||||||||||||||||
| 186 | qw( self partition route user monitor auth profile node pool rule virtual ) | ||||||||||||||||||||||||||||||
| 187 | ) | ||||||||||||||||||||||||||||||
| 188 | { | ||||||||||||||||||||||||||||||
| 189 | 0 | foreach my $key ( sort keys %{ $self->{'Parsed'}->{$obj} } ) { | |||||||||||||||||||||||||||||
| 190 | 0 | ▶ | if ( $self->{'Modify'}->{$obj}->{$key} ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 191 | 0 | $self->{'Output'} .= "$obj $key {\n"; | |||||||||||||||||||||||||||||
| 192 | 0 | foreach my $attr ( $self->_order($obj) ) { | |||||||||||||||||||||||||||||
| 193 | 0 | ▶ | next unless $self->{'Parsed'}->{$obj}->{$key}->{$attr}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 194 | $self->{'Modify'}->{$obj}->{$key}->{$attr} | ||||||||||||||||||||||||||||||
| 195 | 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}
| |||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if (ref $self->{'Modify'}->{$obj}->{$key}->{$attr} eq | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 197 | 'ARRAY' ) | ||||||||||||||||||||||||||||||
| 198 | { | ||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | if ( @{ $self->{'Modify'}->{$obj}->{$key}->{$attr} } | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 200 | > 1 ) | ||||||||||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||||||||||
| 202 | 0 | $self->{'Output'} .= " $attr\n"; | |||||||||||||||||||||||||||||
| 203 | 0 | foreach my $val ( | |||||||||||||||||||||||||||||
| 204 | 0 | @{ $self->{'Modify'}->{$obj}->{$key}->{$attr} | |||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||
| 206 | ) | ||||||||||||||||||||||||||||||
| 207 | { | ||||||||||||||||||||||||||||||
| 208 | 0 | $self->{'Output'} .= " $val\n"; | |||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if ( $self->{'Parsed'}->{$obj}->{$key} | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 210 | ->{'_xtra'}->{$val} ) | ||||||||||||||||||||||||||||||
| 211 | { | ||||||||||||||||||||||||||||||
| 212 | $self->{'Output'} | ||||||||||||||||||||||||||||||
| 213 | .= ' ' | ||||||||||||||||||||||||||||||
| 214 | . $self->{'Parsed'}->{$obj}->{$key} | ||||||||||||||||||||||||||||||
| 215 | 0 | ->{'_xtra'}->{$val} . "\n"; | |||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||
| 219 | else { | ||||||||||||||||||||||||||||||
| 220 | $self->{'Output'} | ||||||||||||||||||||||||||||||
| 221 | .= " $attr " | ||||||||||||||||||||||||||||||
| 222 | . $self->{'Modify'}->{$obj}->{$key} | ||||||||||||||||||||||||||||||
| 223 | 0 | ->{$attr}[0] . "\n"; | |||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||
| 226 | else { | ||||||||||||||||||||||||||||||
| 227 | $self->{'Output'} | ||||||||||||||||||||||||||||||
| 228 | .= " $attr " | ||||||||||||||||||||||||||||||
| 229 | 0 | . $self->{'Modify'}->{$obj}->{$key}->{$attr} | |||||||||||||||||||||||||||||
| 230 | . "\n"; | ||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||
| 233 | 0 | $self->{'Output'} .= "}\n"; | |||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||
| 235 | else { | ||||||||||||||||||||||||||||||
| 236 | 0 | $self->{'Output'} .= $self->{'Raw'}->{$obj}->{$key}; | |||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||
| 241 | 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"
| |||||||||||||||||||||||||||||||
| 242 | 0 | print FILE $self->{'Output'}; | |||||||||||||||||||||||||||||
| 243 | 0 | close FILE; | |||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||
| 245 | 0 | return 1; | |||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||
| 248 | # Return an object hash | ||||||||||||||||||||||||||||||
| 249 | sub _object { | ||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||
|
Subroutine
_object: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||
| 251 | 0 | my $obj = shift; | |||||||||||||||||||||||||||||
| 252 | 0 | my $var = shift; | |||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||
| 254 | 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
| |||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | return undef unless defined $var; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | return $self->{'Parsed'}->{$obj}->{$var} || undef; | ||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'Parsed'}{$obj}{$var} || undef
MC/DC0%0/1
$self->{'Parsed'}{$obj}{$var} || undef
$self->{'Parsed'}{$obj}{$var}
Truth table0%0/2
A
A= $self->{'Parsed'}{$obj}{$var}
| |||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||
| 259 | # Return a list of objects | ||||||||||||||||||||||||||||||
| 260 | sub _objectlist { | ||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||
|
Subroutine
_objectlist: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||
| 262 | 0 | my $obj = shift; | |||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||
| 264 | 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
| |||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if ( $self->{'Parsed'}->{$obj} ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 267 | 0 | return keys %{ $self->{'Parsed'}->{$obj} }; | |||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||
| 269 | else { | ||||||||||||||||||||||||||||||
| 270 | 0 | return 0; | |||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||
| 274 | # Define object attribute ordering | ||||||||||||||||||||||||||||||
| 275 | sub _order { | ||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||
|
Subroutine
_order: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||
| 278 | 0 | for (shift) { | |||||||||||||||||||||||||||||
| 279 | 0 | ▶ | /auth/ && return qw( bind login search servers service ssl user ); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | /gtm monitor/ | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 281 | && return | ||||||||||||||||||||||||||||||
| 282 | qw( default base debug filter mandatoryattrs password security username interval timeout manual dest recv send ); | ||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | /gtm node/ && return qw( monitor screen ); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | /gtm pool/ && return qw( lb nat monitor members ); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | /partition/ && return qw( description ); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | /net self/ && return qw( netmask unit floating vlan allow ); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | /auth user/ | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 288 | && return qw( password description id group home shell role ); | ||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | /gtm server/ | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 290 | && return | ||||||||||||||||||||||||||||||
| 291 | qw( translate snat pool destination ip rules profiles persist ); | ||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||
| 293 | 0 | return 0; | |||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||
| 297 | # Parse the configuration file | ||||||||||||||||||||||||||||||
| 298 | sub _parse { | ||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||
|
Subroutine
_parse: not called CC=45 SCAR=76.4
| |||||||||||||||||||||||||||||||
| 300 | 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'}
| |||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||
| 302 | die "File not found: $self->{'ConfigFile'}\n" | ||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | unless -e $self->{'ConfigFile'}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||
| 305 | 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
| |||||||||||||||||||||||||||||||
| 306 | 0 | my @file = <FILE>; | |||||||||||||||||||||||||||||
| 307 | 0 | close FILE; | |||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||
| 309 | 0 | my ( $parsed, $obj, $key, $attr, $attr1, $attr2 ); | |||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | until ( !$file[0] ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 312 | 0 | my $ln = shift @file; | |||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||
| 314 | #policy hit situation with gtm attribute | ||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | if ( $ln =~ /^(auth user|patition|cli)\s(.*)\s\{(\s\})?$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||
| 316 | 0 | $obj = $1; | |||||||||||||||||||||||||||||
| 317 | 0 | $key = $2; | |||||||||||||||||||||||||||||
| 318 | 0 | ▶ | $attr = undef if $3; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||
| 321 | #gtm attribute | ||||||||||||||||||||||||||||||
| 322 | elsif ( $ln | ||||||||||||||||||||||||||||||
| 323 | =~ /^(gtm wideip|gtm pool|gtm server|gtm monitor|gtm region)\s(.*)\s\{(\s\})?$/ | ||||||||||||||||||||||||||||||
| 324 | ) | ||||||||||||||||||||||||||||||
| 325 | { | ||||||||||||||||||||||||||||||
| 326 | 0 | $obj = $1; | |||||||||||||||||||||||||||||
| 327 | 0 | $key = $2; | |||||||||||||||||||||||||||||
| 328 | 0 | ▶ | $attr = undef if $3; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||
| 331 | #net attribute | ||||||||||||||||||||||||||||||
| 332 | elsif ( $ln | ||||||||||||||||||||||||||||||
| 333 | =~ /^(net self|net route|net interface|net vlan|net trunk)\s(.*)\s\{(\s\})?$/ | ||||||||||||||||||||||||||||||
| 334 | ) | ||||||||||||||||||||||||||||||
| 335 | { | ||||||||||||||||||||||||||||||
| 336 | 0 | $obj = $1; | |||||||||||||||||||||||||||||
| 337 | 0 | $key = $2; | |||||||||||||||||||||||||||||
| 338 | 0 | ▶ | $attr = undef if $3; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||
| 341 | #sys attribute | ||||||||||||||||||||||||||||||
| 342 | elsif ( $ln =~ /^(sys management-route)\s(.*)\s\{(\s\})?$/ ) { | ||||||||||||||||||||||||||||||
| 343 | 0 | $obj = $1; | |||||||||||||||||||||||||||||
| 344 | 0 | $key = $2; | |||||||||||||||||||||||||||||
| 345 | 0 | ▶ | $attr = undef if $3; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||
| 348 | #sys management attribute | ||||||||||||||||||||||||||||||
| 349 | elsif ( $ln | ||||||||||||||||||||||||||||||
| 350 | =~ /^(sys)\s(snmp|sshd|ntp|syslog|state-mirroring)\s\{(\s\})?$/ ) | ||||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||||
| 352 | 0 | $obj = $1; | |||||||||||||||||||||||||||||
| 353 | 0 | $key = $2; | |||||||||||||||||||||||||||||
| 354 | 0 | ▶ | $attr = undef if $3; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||
| 356 | elsif ( $ln =~ /^\}$/ ) { | ||||||||||||||||||||||||||||||
| 357 | 0 | $obj = undef; | |||||||||||||||||||||||||||||
| 358 | 0 | $key = undef; | |||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||
| 361 | # mungle data structure | ||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | if ( $obj && $key ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$obj and $key
MC/DC0%0/2
$obj and $key
$obj
$key
Truth table0%0/3
A and B
A= $objB= $key
| |||||||||||||||||||||||||||||||
| 363 | 0 | $self->{'Raw'}->{$obj}{$key} .= $ln; | |||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||
| 365 | #Indent=4 { not empty } | ||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | if ( $ln =~ /^\s{4}(\S+)\s\{$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 367 | 0 | $attr1 = $1; | |||||||||||||||||||||||||||||
| 368 | 0 | next; | |||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||
| 371 | #$intdent=8 { not empty } | ||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if ( $ln =~ /^\s{8}(\S+)\s\{$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 373 | 0 | $attr2 = $1; | |||||||||||||||||||||||||||||
| 374 | 0 | next; | |||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||
| 377 | #Indent=4 with }$ | ||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | if ( $ln =~ /^\s{4}\}$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 379 | 0 | $attr1 = undef; | |||||||||||||||||||||||||||||
| 380 | 0 | next; | |||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||
| 383 | #Indent=8 with }$ | ||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | if ( $ln =~ /^\s{8}\}$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 385 | 0 | $attr2 = undef; | |||||||||||||||||||||||||||||
| 386 | 0 | next; | |||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||
| 389 | #Indent=4 {} | ||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | if ( $ln =~ /^\s{4}(\S+)\s\{\s\}$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 391 | 0 | $parsed->{$obj}{$key}{$1} = undef; | |||||||||||||||||||||||||||||
| 392 | 0 | next; | |||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||
| 395 | #Indent=4 { scalar } | ||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | if ( $ln =~ /^\s{4}(\S+)\s\{(.*)\}$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | $parsed->{$obj}{$key}{$1} ||= []; | ||||||||||||||||||||||||||||
|
Condition0%0/2
$parsed->{$obj}{$key}{$1} ||= []
MC/DC0%0/1
$parsed->{$obj}{$key}{$1} ||= []
$parsed->{$obj}{$key}{$1}
Truth table0%0/2
A
A= $parsed->{$obj}{$key}{$1}
| |||||||||||||||||||||||||||||||
| 398 | 0 | push @{ $parsed->{$obj}{$key}{$1} }, | |||||||||||||||||||||||||||||
| 399 | 0 | grep { not /^\s*$/ } split( /\s+/, $2 ); | |||||||||||||||||||||||||||||
| 400 | 0 | next; | |||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | if ($attr1) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||
| 405 | #Indent=8 {} | ||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | if ( $ln =~ /^\s{8}(\S+)\s\{\s\}$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 407 | 0 | $parsed->{$obj}{$key}{$attr1}{$1} = undef; | |||||||||||||||||||||||||||||
| 408 | 0 | next; | |||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||
| 411 | #Indent=8 { scalar } | ||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | if ( $ln =~ /^\s{8}(\S+)\s\{(.*)\}$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | $parsed->{$obj}{$key}{$1} ||= []; | ||||||||||||||||||||||||||||
|
Condition0%0/2
$parsed->{$obj}{$key}{$1} ||= []
MC/DC0%0/1
$parsed->{$obj}{$key}{$1} ||= []
$parsed->{$obj}{$key}{$1}
Truth table0%0/2
A
A= $parsed->{$obj}{$key}{$1}
| |||||||||||||||||||||||||||||||
| 414 | 0 | push @{ $parsed->{$obj}{$key}{$1} }, | |||||||||||||||||||||||||||||
| 415 | 0 | grep { not /^\s*$/ } split( /\s+/, $2 ); | |||||||||||||||||||||||||||||
| 416 | 0 | next; | |||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||
| 419 | #Indent=8 match { key => value } | ||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | if ( $ln =~ /^\s{8}(\S+)\s(.*)$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 421 | 0 | $parsed->{$obj}{$key}{$attr1}{$1} = $2; | |||||||||||||||||||||||||||||
| 422 | 0 | next; | |||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||
| 425 | #Indent=8 match scalar | ||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | if ( $ln =~ /^\s{8}(\S.+)$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | if ( ref( $parsed->{$obj}{$key}{$attr1} ) eq 'HASH' ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 428 | 0 | $parsed->{$obj}{$key}{$attr1}{$1} = undef; | |||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||
| 430 | else { | ||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | $parsed->{$obj}{$key}{$attr1} ||= []; | ||||||||||||||||||||||||||||
|
Condition0%0/2
$parsed->{$obj}{$key}{$attr1} ||= []
MC/DC0%0/1
$parsed->{$obj}{$key}{$attr1} ||= []
$parsed->{$obj}{$key}{$attr1}
Truth table0%0/2
A
A= $parsed->{$obj}{$key}{$attr1}
| |||||||||||||||||||||||||||||||
| 432 | 0 | push @{ $parsed->{$obj}{$key}{$attr1} }, $1; | |||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||
| 434 | 0 | next; | |||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | if ($attr2) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||
| 440 | #Indent=12 match { not empty } | ||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | if ( $ln =~ /^\s{12}(\S+)\s\{\s\}$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 442 | 0 | $parsed->{$obj}{$key}{$attr1}{$attr2}{$1} = undef; | |||||||||||||||||||||||||||||
| 443 | 0 | next; | |||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||
| 446 | #Indent=12 { scalar } | ||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | if ( $ln =~ /^\s{12}(\S+)\s\{(.*)\}$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | $parsed->{$obj}{$key}{$attr1} ||= []; | ||||||||||||||||||||||||||||
|
Condition0%0/2
$parsed->{$obj}{$key}{$attr1} ||= []
MC/DC0%0/1
$parsed->{$obj}{$key}{$attr1} ||= []
$parsed->{$obj}{$key}{$attr1}
Truth table0%0/2
A
A= $parsed->{$obj}{$key}{$attr1}
| |||||||||||||||||||||||||||||||
| 449 | 0 | push @{ $parsed->{$obj}{$key}{$attr1}{$attr2}{$1} }, | |||||||||||||||||||||||||||||
| 450 | 0 | grep { not /^\s*$/ } split( /\s+/, $2 ); | |||||||||||||||||||||||||||||
| 451 | 0 | next; | |||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||
| 454 | #Indent=12 match { key => value } | ||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | if ( $ln =~ /^\s{12}(\S+)\s(.*)\s?$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 456 | 0 | say( $ln, $attr1, $attr2 ); | |||||||||||||||||||||||||||||
| 457 | 0 | $parsed->{$obj}->{$key}{$attr1}{$attr2}{$1} = $2; | |||||||||||||||||||||||||||||
| 458 | 0 | next; | |||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||
| 461 | #Indent=12 match scalar | ||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | if ( $ln =~ /^\s{12}(.*)\s?$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | if ( ref( $parsed->{$obj}{$key}{$attr1} ) eq 'HASH' ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 464 | 0 | $parsed->{$obj}{$key}{$attr1}{$1} = undef; | |||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||
| 466 | else { | ||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | $parsed->{$obj}{$key}{$attr1} ||= []; | ||||||||||||||||||||||||||||
|
Condition0%0/2
$parsed->{$obj}{$key}{$attr1} ||= []
MC/DC0%0/1
$parsed->{$obj}{$key}{$attr1} ||= []
$parsed->{$obj}{$key}{$attr1}
Truth table0%0/2
A
A= $parsed->{$obj}{$key}{$attr1}
| |||||||||||||||||||||||||||||||
| 468 | 0 | push @{ $parsed->{$obj}{$key}{$attr1} }, $1; | |||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||
| 470 | 0 | next; | |||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||
| 474 | #Indent=4 match { key => value } | ||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | if ( $ln =~ /^\s{4}(\S+)\s(.*)$/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 476 | 0 | $parsed->{$obj}{$key}{$1} = $2; | |||||||||||||||||||||||||||||
| 477 | 0 | next; | |||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||
| 479 | else { | ||||||||||||||||||||||||||||||
| 480 | 0 | say $ln; | |||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||
| 485 | # Fill in ill-formatted objects | ||||||||||||||||||||||||||||||
| 486 | 0 | foreach my $obj ( keys %{ $self->{'Raw'} } ) { | |||||||||||||||||||||||||||||
| 487 | 0 | foreach my $key ( keys %{ $self->{'Raw'}->{$obj} } ) { | |||||||||||||||||||||||||||||
| 488 | 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}
| |||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||
| 492 | 0 | return $parsed; | |||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||
| 495 | 1 | 1; | |||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||
| 497 | __END__ | ||||||||||||||||||||||||||||||