Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opentrafficshaper
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Francisco Manuel Cardoso
opentrafficshaper
Commits
0e8e50eb
Commit
0e8e50eb
authored
Mar 06, 2018
by
Nigel Kukard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'nkfixes' into 'master'
Fixes for pool override functionality See merge request
!8
parents
ffda0646
28665a2b
Pipeline
#2893
failed with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
18 deletions
+63
-18
opentrafficshaper/plugins/configmanager.pm
opentrafficshaper/plugins/configmanager.pm
+33
-8
opentrafficshaper/plugins/tc/tc.pm
opentrafficshaper/plugins/tc/tc.pm
+1
-1
opentrafficshaper/plugins/webserver/pages/limits.pm
opentrafficshaper/plugins/webserver/pages/limits.pm
+29
-9
No files found.
opentrafficshaper/plugins/configmanager.pm
View file @
0e8e50eb
...
...
@@ -93,6 +93,7 @@ our (@ISA,@EXPORT,@EXPORT_OK);
setPoolShaperState
unsetPoolShaperState
isPoolIDValid
isPoolOverridden
isPoolReady
getEffectivePool
...
...
@@ -2805,6 +2806,26 @@ sub isPoolReady
# Function to check if pool is being overridden or not
sub
isPoolOverridden
{
my
$pid
=
shift
;
if
(
!
isPoolIDValid
(
$pid
))
{
return
;
}
# Set a property based on if this pool is overridden or not
if
(
defined
(
$globals
->
{'
Pools
'}
->
{
$pid
}
->
{'
.applied_overrides
'})
&&
(
keys
%
{
$globals
->
{'
Pools
'}
->
{
$pid
}
->
{'
.applied_overrides
'}})
>
0
)
{
return
1
;
}
return
0
;
}
# Function to return a pool with any items changed as per pool overrides
sub
getEffectivePool
{
...
...
@@ -3353,7 +3374,7 @@ sub createLimit
my
$poolName
=
$limitData
->
{'
Username
'};
my
$poolData
=
{
'
FriendlyName
'
=>
$limitData
->
{'
IPAddress
'},
'
FriendlyName
'
=>
$limitData
->
{'
FriendlyName
'}
||
$limitData
->
{'
IPAddress
'},
'
Name
'
=>
$poolName
,
'
InterfaceGroupID
'
=>
$limitData
->
{'
InterfaceGroupID
'},
'
TrafficClassID
'
=>
$limitData
->
{'
TrafficClassID
'},
...
...
@@ -3404,7 +3425,10 @@ sub createPoolOverride
# Check that we have at least one match attribute
my
$isValid
=
0
;
foreach
my
$item
(
POOL_OVERRIDE_MATCH_ATTRIBUTES
)
{
$isValid
++
;
# Bump up $isValid if we have a match attribute
if
(
defined
(
$poolOverrideData
->
{
$item
}))
{
$isValid
++
;
}
}
if
(
!
$isValid
)
{
$logger
->
log
(
LOG_WARN
,"
[CONFIGMANAGER] Cannot process pool override as there is no selection attribute
");
...
...
@@ -3623,14 +3647,15 @@ sub _resolve_pool_override
# Loop with the attributes and check for a full match
foreach
my
$attr
(
POOL_OVERRIDE_MATCH_ATTRIBUTES
)
{
# If this attribute in the pool override is set, then lets check it
if
(
defined
(
$poolOverride
->
{
$attr
})
&&
$poolOverride
->
{
$attr
}
ne
"")
{
# Check for match or mismatch
if
(
defined
(
$candidate
->
{
$attr
})
&&
$candidate
->
{
$attr
}
eq
$poolOverride
->
{
$attr
})
{
$numMatches
++
;
}
else
{
$numMismatches
++
;
# Check for match or mismatch, only if candidate attribute is defined
if
(
defined
(
$candidate
->
{
$attr
}))
{
if
(
$candidate
->
{
$attr
}
eq
$poolOverride
->
{
$attr
})
{
$numMatches
++
;
}
else
{
$numMismatches
++
;
}
}
}
}
...
...
opentrafficshaper/plugins/tc/tc.pm
View file @
0e8e50eb
...
...
@@ -315,7 +315,7 @@ sub _session_pool_add
# Grab pool
my
$pool
;
if
(
!
defined
(
$pool
=
getPool
(
$pid
)))
{
$logger
->
log
(
LOG_ERR
,"
[TC] Shaper '
remove
' event with non existing pool '%s'
",
$pid
);
$logger
->
log
(
LOG_ERR
,"
[TC] Shaper '
add
' event with non existing pool '%s'
",
$pid
);
return
;
}
...
...
opentrafficshaper/plugins/webserver/pages/limits.pm
View file @
0e8e50eb
...
...
@@ -59,6 +59,7 @@ use opentrafficshaper::plugins::configmanager qw(
getPool
getPoolByName
getPoolShaperState
isPoolOverridden
isPoolReady
getPoolMembers
...
...
@@ -213,9 +214,9 @@ EOF
# if ($pool->{'Status'} eq 'conflict') {
# $icons .= '<span class="glyphicon glyphicon-random" />';
# }
# if ($pool->{'Status'} eq 'conflict'
) {
#
$icons .= '<span class="glyphicon glyphicon-edit" />';
#
}
if
(
isPoolOverridden
(
$pool
->
{'
ID
'})
)
{
$icons
.=
'
<span class="glyphicon glyphicon-edit" />
';
}
my
$urlStatsPool
=
sprintf
('
/statistics/by-pool?pool=%s
',
uri_escape
("
$pool
->{'InterfaceGroupID'}:
$pool
->{'Name'}
"));
my
$urlPoolEdit
=
sprintf
('
/limits/pool-edit?pid=%s
',
uri_escape
(
$pool
->
{'
ID
'}));
...
...
@@ -2010,12 +2011,31 @@ sub pool_override_addedit
push
(
@errors
,"
Friendly name must be specified
");
}
# Make sure we have at least a pool name, username or IP address
my
$poolName
=
isUsername
(
$formData
->
{'
PoolName
'},
ISUSERNAME_ALLOW_ATSIGN
);
my
$username
=
isUsername
(
$formData
->
{'
Username
'},
ISUSERNAME_ALLOW_ATSIGN
);
my
$ipAddress
=
isIPv4
(
$formData
->
{'
IPAddress
'});
# Check the pool name is valid if it was specified
my
$poolName
;
if
(
defined
(
$formData
->
{'
PoolName
'})
&&
$formData
->
{'
PoolName
'}
ne
"")
{
if
(
!
defined
(
$poolName
=
isUsername
(
$formData
->
{'
PoolName
'},
ISUSERNAME_ALLOW_ATSIGN
)))
{
push
(
@errors
,"
Pool name is not valid
");
}
}
# Next check the username
my
$username
;
if
(
defined
(
$formData
->
{'
Username
'})
&&
$formData
->
{'
Username
'}
ne
"")
{
if
(
!
defined
(
$username
=
isUsername
(
$formData
->
{'
Username
'},
ISUSERNAME_ALLOW_ATSIGN
)))
{
push
(
@errors
,"
Username is not valid
");
}
}
# Then the IP
my
$ipAddress
;
if
(
defined
(
$formData
->
{'
IPAddress
'})
&&
$formData
->
{'
IPAddress
'}
ne
"")
{
if
(
!
defined
(
$ipAddress
=
isIPv4
(
$formData
->
{'
IPAddress
'})))
{
push
(
@errors
,"
IP address is not valid
");
}
}
# Then confirm we have at least one of the above
if
(
!
defined
(
$poolName
)
&&
!
defined
(
$username
)
&&
!
defined
(
$ipAddress
))
{
push
(
@errors
,"
A
pool name and/or IP address and/or Username must be specified
");
push
(
@errors
,"
A
t least a valid pool name, username or IP address must be specified to match
");
}
# If the traffic class is ticked, process it
...
...
@@ -2057,7 +2077,7 @@ sub pool_override_addedit
!
defined
(
$txCIR
)
&&
!
defined
(
$txLimit
)
&&
!
defined
(
$rxCIR
)
&&
!
defined
(
$rxLimit
)
)
{
push
(
@errors
,"
Something must be specified to
pool
override
");
push
(
@errors
,"
Something must be specified to override
");
}
my
$expires
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment