Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
opentrafficshaper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yuriy
opentrafficshaper
Commits
7b6dfad7
Commit
7b6dfad7
authored
11 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
Small code cleanup
parent
58717bda
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
opentrafficshaper/plugins/configmanager.pm
+74
-0
74 additions, 0 deletions
opentrafficshaper/plugins/configmanager.pm
with
74 additions
and
0 deletions
opentrafficshaper/plugins/configmanager.pm
+
74
−
0
View file @
7b6dfad7
...
@@ -69,6 +69,7 @@ our (@ISA,@EXPORT,@EXPORT_OK);
...
@@ -69,6 +69,7 @@ our (@ISA,@EXPORT,@EXPORT_OK);
getInterfaceClasses
getInterfaceClasses
getInterfaceDefaultPool
getInterfaceDefaultPool
getInterfaceRate
getInterfaceRate
getInterfaceGroup
getInterfaceGroups
getInterfaceGroups
isInterfaceGroupValid
isInterfaceGroupValid
...
@@ -769,9 +770,12 @@ sub process_override_remove
...
@@ -769,9 +770,12 @@ sub process_override_remove
sub
checkGroupID
sub
checkGroupID
{
{
my
$gid
=
shift
;
my
$gid
=
shift
;
if
(
defined
(
$config
->
{'
groups
'}
->
{
$gid
}))
{
if
(
defined
(
$config
->
{'
groups
'}
->
{
$gid
}))
{
return
$gid
;
return
$gid
;
}
}
return
undef
;
return
undef
;
}
}
...
@@ -780,9 +784,12 @@ sub checkGroupID
...
@@ -780,9 +784,12 @@ sub checkGroupID
sub
checkInterfaceGroupID
sub
checkInterfaceGroupID
{
{
my
$igid
=
shift
;
my
$igid
=
shift
;
if
(
defined
(
$config
->
{'
interface_groups
'}
->
{
$igid
}))
{
if
(
defined
(
$config
->
{'
interface_groups
'}
->
{
$igid
}))
{
return
$igid
;
return
$igid
;
}
}
return
undef
;
return
undef
;
}
}
...
@@ -791,9 +798,12 @@ sub checkInterfaceGroupID
...
@@ -791,9 +798,12 @@ sub checkInterfaceGroupID
sub
checkMatchPriorityID
sub
checkMatchPriorityID
{
{
my
$mpid
=
shift
;
my
$mpid
=
shift
;
if
(
defined
(
$config
->
{'
match_priorities
'}
->
{
$mpid
}))
{
if
(
defined
(
$config
->
{'
match_priorities
'}
->
{
$mpid
}))
{
return
$mpid
;
return
$mpid
;
}
}
return
undef
;
return
undef
;
}
}
...
@@ -802,9 +812,12 @@ sub checkMatchPriorityID
...
@@ -802,9 +812,12 @@ sub checkMatchPriorityID
sub
checkClassID
sub
checkClassID
{
{
my
$cid
=
shift
;
my
$cid
=
shift
;
if
(
defined
(
$config
->
{'
classes
'}
->
{
$cid
}))
{
if
(
defined
(
$config
->
{'
classes
'}
->
{
$cid
}))
{
return
$cid
;
return
$cid
;
}
}
return
undef
;
return
undef
;
}
}
...
@@ -822,6 +835,7 @@ sub getInterface
...
@@ -822,6 +835,7 @@ sub getInterface
# And return it...
# And return it...
return
$res
;
return
$res
;
}
}
return
undef
;
return
undef
;
}
}
...
@@ -838,10 +852,12 @@ sub getInterfaceClasses
...
@@ -838,10 +852,12 @@ sub getInterfaceClasses
{
{
my
$interface
=
shift
;
my
$interface
=
shift
;
# If we have this interface return its classes
# If we have this interface return its classes
if
(
defined
(
$config
->
{'
interfaces
'}
->
{
$interface
}))
{
if
(
defined
(
$config
->
{'
interfaces
'}
->
{
$interface
}))
{
return
dclone
(
$config
->
{'
interfaces
'}
->
{
$interface
}
->
{'
classes
'});
return
dclone
(
$config
->
{'
interfaces
'}
->
{
$interface
}
->
{'
classes
'});
}
}
return
undef
;
return
undef
;
}
}
...
@@ -850,6 +866,8 @@ sub getInterfaceClasses
...
@@ -850,6 +866,8 @@ sub getInterfaceClasses
sub
getInterfaceDefaultPool
sub
getInterfaceDefaultPool
{
{
my
$interface
=
shift
;
my
$interface
=
shift
;
# We don't really need the interface to return the default pool
# We don't really need the interface to return the default pool
return
$config
->
{'
default_pool
'};
return
$config
->
{'
default_pool
'};
}
}
...
@@ -860,10 +878,12 @@ sub getInterfaceRate
...
@@ -860,10 +878,12 @@ sub getInterfaceRate
{
{
my
$interface
=
shift
;
my
$interface
=
shift
;
# If we have this interface return its rate
# If we have this interface return its rate
if
(
defined
(
$config
->
{'
interfaces
'}
->
{
$interface
}))
{
if
(
defined
(
$config
->
{'
interfaces
'}
->
{
$interface
}))
{
return
$config
->
{'
interfaces
'}
->
{
$interface
}
->
{'
rate
'};
return
$config
->
{'
interfaces
'}
->
{
$interface
}
->
{'
rate
'};
}
}
return
undef
;
return
undef
;
}
}
...
@@ -873,17 +893,35 @@ sub getInterfaceGroups
...
@@ -873,17 +893,35 @@ sub getInterfaceGroups
{
{
my
$interface_groups
=
dclone
(
$config
->
{'
interface_groups
'});
my
$interface_groups
=
dclone
(
$config
->
{'
interface_groups
'});
return
$interface_groups
;
return
$interface_groups
;
}
}
# Function to get an interface group
sub
getInterfaceGroup
{
my
$interfaceGroup
=
shift
;
if
(
defined
(
$config
->
{'
interface_groups
'}
->
{
$interfaceGroup
}))
{
return
dclone
(
$config
->
{'
interface_groups
'}
->
{
$interfaceGroup
});
}
return
undef
;
}
# Function to check if interface group is valid
# Function to check if interface group is valid
sub
isInterfaceGroupValid
sub
isInterfaceGroupValid
{
{
my
$interfaceGroup
=
shift
;
my
$interfaceGroup
=
shift
;
if
(
defined
(
$interfaceGroup
)
&&
defined
(
$config
->
{'
interface_groups
'}
->
{
$interfaceGroup
}))
{
if
(
defined
(
$interfaceGroup
)
&&
defined
(
$config
->
{'
interface_groups
'}
->
{
$interfaceGroup
}))
{
return
$interfaceGroup
;
return
$interfaceGroup
;
}
}
return
undef
;
return
undef
;
}
}
...
@@ -893,6 +931,7 @@ sub getMatchPriorities
...
@@ -893,6 +931,7 @@ sub getMatchPriorities
{
{
my
$match_priorities
=
dclone
(
$config
->
{'
match_priorities
'});
my
$match_priorities
=
dclone
(
$config
->
{'
match_priorities
'});
return
$match_priorities
;
return
$match_priorities
;
}
}
...
@@ -901,9 +940,12 @@ sub getMatchPriorities
...
@@ -901,9 +940,12 @@ sub getMatchPriorities
sub
isMatchPriorityValid
sub
isMatchPriorityValid
{
{
my
$matchPriority
=
shift
;
my
$matchPriority
=
shift
;
if
(
defined
(
$matchPriority
)
&&
defined
(
$config
->
{'
match_priorities
'}
->
{
$matchPriority
}))
{
if
(
defined
(
$matchPriority
)
&&
defined
(
$config
->
{'
match_priorities
'}
->
{
$matchPriority
}))
{
return
$matchPriority
;
return
$matchPriority
;
}
}
return
undef
;
return
undef
;
}
}
...
@@ -912,9 +954,12 @@ sub isMatchPriorityValid
...
@@ -912,9 +954,12 @@ sub isMatchPriorityValid
sub
checkStatus
sub
checkStatus
{
{
my
$status
=
shift
;
my
$status
=
shift
;
if
(
$status
eq
"
new
"
||
$status
eq
"
offline
"
||
$status
eq
"
online
"
||
$status
eq
"
conflict
"
||
$status
eq
"
unknown
")
{
if
(
$status
eq
"
new
"
||
$status
eq
"
offline
"
||
$status
eq
"
online
"
||
$status
eq
"
conflict
"
||
$status
eq
"
unknown
")
{
return
$status
return
$status
}
}
return
undef
;
return
undef
;
}
}
...
@@ -923,6 +968,8 @@ sub checkStatus
...
@@ -923,6 +968,8 @@ sub checkStatus
sub
getLimitUsername
sub
getLimitUsername
{
{
my
$lid
=
shift
;
my
$lid
=
shift
;
if
(
defined
(
$limits
->
{
$lid
}))
{
if
(
defined
(
$limits
->
{
$lid
}))
{
return
$limits
->
{
$lid
}
->
{'
Username
'};
return
$limits
->
{
$lid
}
->
{'
Username
'};
}
}
...
@@ -934,9 +981,12 @@ sub getLimitUsername
...
@@ -934,9 +981,12 @@ sub getLimitUsername
sub
getLimitTxInterface
sub
getLimitTxInterface
{
{
my
$lid
=
shift
;
my
$lid
=
shift
;
if
(
defined
(
$limits
->
{
$lid
}))
{
if
(
defined
(
$limits
->
{
$lid
}))
{
return
$config
->
{'
interface_groups
'}
->
{
$limits
->
{
$lid
}
->
{'
InterfaceGroupID
'}}
->
{'
txiface
'};
return
$config
->
{'
interface_groups
'}
->
{
$limits
->
{
$lid
}
->
{'
InterfaceGroupID
'}}
->
{'
txiface
'};
}
}
return
undef
;
return
undef
;
}
}
...
@@ -945,9 +995,12 @@ sub getLimitTxInterface
...
@@ -945,9 +995,12 @@ sub getLimitTxInterface
sub
getLimitRxInterface
sub
getLimitRxInterface
{
{
my
$lid
=
shift
;
my
$lid
=
shift
;
if
(
defined
(
$limits
->
{
$lid
}))
{
if
(
defined
(
$limits
->
{
$lid
}))
{
return
$config
->
{'
interface_groups
'}
->
{
$limits
->
{
$lid
}
->
{'
InterfaceGroupID
'}}
->
{'
rxiface
'};
return
$config
->
{'
interface_groups
'}
->
{
$limits
->
{
$lid
}
->
{'
InterfaceGroupID
'}}
->
{'
rxiface
'};
}
}
return
undef
;
return
undef
;
}
}
...
@@ -956,10 +1009,13 @@ sub getLimitRxInterface
...
@@ -956,10 +1009,13 @@ sub getLimitRxInterface
sub
getLimitMatchPriority
sub
getLimitMatchPriority
{
{
my
$lid
=
shift
;
my
$lid
=
shift
;
if
(
defined
(
$limits
->
{
$lid
}))
{
if
(
defined
(
$limits
->
{
$lid
}))
{
# NK: No actual mappping yet
# NK: No actual mappping yet
return
$limits
->
{
$lid
}
->
{'
MatchPriorityID
'};
return
$limits
->
{
$lid
}
->
{'
MatchPriorityID
'};
}
}
return
undef
;
return
undef
;
}
}
...
@@ -969,10 +1025,12 @@ sub getLimit
...
@@ -969,10 +1025,12 @@ sub getLimit
{
{
my
$lid
=
shift
;
my
$lid
=
shift
;
if
(
defined
(
$limits
->
{
$lid
}))
{
if
(
defined
(
$limits
->
{
$lid
}))
{
my
%limit
=
%
{
$limits
->
{
$lid
}};
my
%limit
=
%
{
$limits
->
{
$lid
}};
return
\
%limit
;
return
\
%limit
;
}
}
return
undef
;
return
undef
;
}
}
...
@@ -1033,6 +1091,7 @@ sub getOverride
...
@@ -1033,6 +1091,7 @@ sub getOverride
my
%override
=
%
{
$overrides
->
{
$oid
}};
my
%override
=
%
{
$overrides
->
{
$oid
}};
return
\
%override
;
return
\
%override
;
}
}
return
undef
;
return
undef
;
}
}
...
@@ -1049,9 +1108,11 @@ sub setShaperState
...
@@ -1049,9 +1108,11 @@ sub setShaperState
{
{
my
(
$lid
,
$state
)
=
@_
;
my
(
$lid
,
$state
)
=
@_
;
if
(
defined
(
$lid
)
&&
defined
(
$limits
->
{
$lid
}))
{
if
(
defined
(
$lid
)
&&
defined
(
$limits
->
{
$lid
}))
{
$limits
->
{
$lid
}
->
{'
_shaper.state
'}
=
$state
;
$limits
->
{
$lid
}
->
{'
_shaper.state
'}
=
$state
;
}
}
return
undef
;
return
undef
;
}
}
...
@@ -1060,9 +1121,12 @@ sub setShaperState
...
@@ -1060,9 +1121,12 @@ sub setShaperState
sub
getShaperState
sub
getShaperState
{
{
my
$lid
=
shift
;
my
$lid
=
shift
;
if
(
defined
(
$lid
)
&&
defined
(
$limits
->
{
$lid
}))
{
if
(
defined
(
$lid
)
&&
defined
(
$limits
->
{
$lid
}))
{
return
$limits
->
{
$lid
}
->
{'
_shaper.state
'};
return
$limits
->
{
$lid
}
->
{'
_shaper.state
'};
}
}
return
undef
;
return
undef
;
}
}
...
@@ -1086,9 +1150,12 @@ sub getTrafficClasses
...
@@ -1086,9 +1150,12 @@ sub getTrafficClasses
sub
getTrafficClassName
sub
getTrafficClassName
{
{
my
$class
=
shift
;
my
$class
=
shift
;
if
(
defined
(
$class
)
&&
defined
(
$config
->
{'
classes
'}
->
{
$class
}))
{
if
(
defined
(
$class
)
&&
defined
(
$config
->
{'
classes
'}
->
{
$class
}))
{
return
$config
->
{'
classes
'}
->
{
$class
};
return
$config
->
{'
classes
'}
->
{
$class
};
}
}
return
undef
;
return
undef
;
}
}
...
@@ -1097,9 +1164,12 @@ sub getTrafficClassName
...
@@ -1097,9 +1164,12 @@ sub getTrafficClassName
sub
isTrafficClassValid
sub
isTrafficClassValid
{
{
my
$class
=
shift
;
my
$class
=
shift
;
if
(
defined
(
$class
)
&&
defined
(
$config
->
{'
classes
'}
->
{
$class
}))
{
if
(
defined
(
$class
)
&&
defined
(
$config
->
{'
classes
'}
->
{
$class
}))
{
return
$class
;
return
$class
;
}
}
return
undef
;
return
undef
;
}
}
...
@@ -1108,10 +1178,13 @@ sub isTrafficClassValid
...
@@ -1108,10 +1178,13 @@ sub isTrafficClassValid
sub
getTrafficPriority
sub
getTrafficPriority
{
{
my
$class
=
shift
;
my
$class
=
shift
;
# NK: Short circuit, our ClassID = Priority
# NK: Short circuit, our ClassID = Priority
if
(
defined
(
$class
)
&&
defined
(
$config
->
{'
classes
'}
->
{
$class
}))
{
if
(
defined
(
$class
)
&&
defined
(
$config
->
{'
classes
'}
->
{
$class
}))
{
return
$class
;
return
$class
;
}
}
return
undef
;
return
undef
;
}
}
...
@@ -1135,6 +1208,7 @@ sub _getAppliedLimitChangeset
...
@@ -1135,6 +1208,7 @@ sub _getAppliedLimitChangeset
{
{
my
(
$orig
,
$new
)
=
@_
;
my
(
$orig
,
$new
)
=
@_
;
my
$res
;
my
$res
;
# Loop through what can change
# Loop through what can change
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment