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
15843637
Commit
15843637
authored
11 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
Added some configuration helper functions
This replaces the need to directly access $limits
parent
40ff47be
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
+49
-12
49 additions, 12 deletions
opentrafficshaper/plugins/configmanager.pm
with
49 additions
and
12 deletions
opentrafficshaper/plugins/configmanager.pm
+
49
−
12
View file @
15843637
...
@@ -37,7 +37,9 @@ our (@ISA,@EXPORT,@EXPORT_OK);
...
@@ -37,7 +37,9 @@ our (@ISA,@EXPORT,@EXPORT_OK);
@EXPORT
=
qw(
@EXPORT
=
qw(
)
;
)
;
@EXPORT_OK
=
qw(
@EXPORT_OK
=
qw(
getLimit
getLimits
getLimits
getLimitUsername
setLimitAttribute
setLimitAttribute
getLimitAttribute
getLimitAttribute
...
@@ -546,14 +548,20 @@ sub processChanges
...
@@ -546,14 +548,20 @@ sub processChanges
sub
checkGroupID
sub
checkGroupID
{
{
my
$gid
=
shift
;
my
$gid
=
shift
;
return
$gid
if
(
defined
(
$groups
->
{
$gid
}));
if
(
defined
(
$groups
->
{
$gid
}))
{
return
$gid
;
}
return
;
}
}
# Function to check the class ID exists
# Function to check the class ID exists
sub
checkClassID
sub
checkClassID
{
{
my
$cid
=
shift
;
my
$cid
=
shift
;
return
$cid
if
(
defined
(
$classes
->
{
$cid
}));
if
(
defined
(
$classes
->
{
$cid
}))
{
return
$cid
;
}
return
;
}
}
# Function to check if the status is ok
# Function to check if the status is ok
...
@@ -563,13 +571,35 @@ sub checkStatus
...
@@ -563,13 +571,35 @@ sub checkStatus
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
;
}
# Function to return a limit username
sub
getLimitUsername
{
my
$lid
=
shift
;
if
(
defined
(
$limits
->
{
$lid
}))
{
return
$limits
->
{
$lid
}
->
{'
Username
'};
}
return
;
}
}
# Function to return list of limits
# Function to return a limit
sub
getLimit
{
my
$lid
=
shift
;
if
(
defined
(
$limits
->
{
$lid
}))
{
my
%limit
=
%
{
$limits
->
{
$lid
}};
return
\
%limit
;
}
return
;
}
# Function to return a list of limit ID's
sub
getLimits
sub
getLimits
{
{
return
$limits
;
return
(
keys
%
{
$limits
})
;
}
}
# Function to set a limit attribute
# Function to set a limit attribute
...
@@ -577,7 +607,12 @@ sub setLimitAttribute
...
@@ -577,7 +607,12 @@ sub setLimitAttribute
{
{
my
(
$lid
,
$attr
,
$value
)
=
@_
;
my
(
$lid
,
$attr
,
$value
)
=
@_
;
$limits
->
{
$lid
}
->
{'
attributes
'}
->
{
$attr
}
=
$value
;
# Only set it if it exists
if
(
defined
(
$limits
->
{
$lid
}))
{
$limits
->
{
$lid
}
->
{'
attributes
'}
->
{
$attr
}
=
$value
;
}
return
;
}
}
# Function to get a limit attribute
# Function to get a limit attribute
...
@@ -589,9 +624,8 @@ sub getLimitAttribute
...
@@ -589,9 +624,8 @@ sub getLimitAttribute
# Check if attribute exists first
# Check if attribute exists first
if
(
defined
(
$limits
->
{
$lid
})
&&
defined
(
$limits
->
{
$lid
}
->
{'
attributes
'})
&&
defined
(
$limits
->
{
$lid
}
->
{'
attributes
'}
->
{
$attr
}))
{
if
(
defined
(
$limits
->
{
$lid
})
&&
defined
(
$limits
->
{
$lid
}
->
{'
attributes
'})
&&
defined
(
$limits
->
{
$lid
}
->
{'
attributes
'}
->
{
$attr
}))
{
return
$limits
->
{
$lid
}
->
{'
attributes
'}
->
{
$attr
};
return
$limits
->
{
$lid
}
->
{'
attributes
'}
->
{
$attr
};
}
else
{
return
undef
;
}
}
return
;
}
}
# Function to set shaper state on a limit
# Function to set shaper state on a limit
...
@@ -599,15 +633,19 @@ sub setShaperState
...
@@ -599,15 +633,19 @@ sub setShaperState
{
{
my
(
$lid
,
$state
)
=
@_
;
my
(
$lid
,
$state
)
=
@_
;
$limits
->
{
$lid
}
->
{'
_shaper.state
'}
=
$state
;
if
(
defined
(
$limits
->
{
$lid
}))
{
$limits
->
{
$lid
}
->
{'
_shaper.state
'}
=
$state
;
}
}
}
# Function to get shaper state on a limit
# Function to get shaper state on a limit
sub
getShaperState
sub
getShaperState
{
{
my
$lid
=
shift
;
my
$lid
=
shift
;
if
(
defined
(
$limits
->
{
$lid
}))
{
return
$limits
->
{
$lid
}
->
{'
_shaper.state
'};
return
$limits
->
{
$lid
}
->
{'
_shaper.state
'};
}
return
;
}
}
# Function to get traffic classes
# Function to get traffic classes
...
@@ -620,7 +658,6 @@ sub getTrafficClasses
...
@@ -620,7 +658,6 @@ sub getTrafficClasses
sub
getPriorityName
sub
getPriorityName
{
{
my
$prio
=
shift
;
my
$prio
=
shift
;
return
$classes
->
{
$prio
};
return
$classes
->
{
$prio
};
}
}
...
...
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