git://git.onelab.eu
/
util-vserver.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Don't nuke /var/run.
[util-vserver.git]
/
python
/
bwlimit.py
diff --git
a/python/bwlimit.py
b/python/bwlimit.py
index
5f35fe8
..
8fb6159
100644
(file)
--- a/
python/bwlimit.py
+++ b/
python/bwlimit.py
@@
-46,7
+46,7
@@
# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (C) 2006 The Trustees of Princeton University
#
# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (C) 2006 The Trustees of Princeton University
#
-# $Id: bwlimit.py,v 1.1
1 2006/03/15 16:41:21 smuir
Exp $
+# $Id: bwlimit.py,v 1.1
4 2006/12/13 21:48:14 faiyaza
Exp $
#
import sys, os, re, getopt
#
import sys, os, re, getopt
@@
-303,14
+303,17
@@
def tc(cmd):
return run(TC + " " + cmd)
return run(TC + " " + cmd)
-def init(dev
, bwcap
):
+def init(dev
= dev, bwcap = bwmax
):
"""
(Re)initialize the bandwidth limits on this node
"""
"""
(Re)initialize the bandwidth limits on this node
"""
- #
l
oad the module used to manage exempt classes
+ #
L
oad the module used to manage exempt classes
run("/sbin/modprobe ip_set_iphash")
run("/sbin/modprobe ip_set_iphash")
+ # Save current settings
+ paramslist = get(None, dev)
+
# Delete root qdisc 1: if it exists. This will also automatically
# delete any child classes.
for line in tc("qdisc show dev %s" % dev):
# Delete root qdisc 1: if it exists. This will also automatically
# delete any child classes.
for line in tc("qdisc show dev %s" % dev):
@@
-352,6
+355,14
@@
def init(dev, bwcap):
# up here.
on(default_xid, dev, share = default_share)
# up here.
on(default_xid, dev, share = default_share)
+ # Restore old settings
+ for (xid, share,
+ minrate, maxrate,
+ minexemptrate, maxexemptrate,
+ bytes, exemptbytes) in paramslist:
+ if xid not in (root_xid, default_xid):
+ on(xid, dev, share, minrate, maxrate, minexemptrate, maxexemptrate)
+
def get(xid = None, dev = dev):
"""
def get(xid = None, dev = dev):
"""
@@
-497,12
+508,20
@@
def on(xid, dev = dev, share = None, minrate = None, maxrate = None, minexemptra
maxexemptrate = get_tc_rate(maxexemptrate)
# Sanity checks
maxexemptrate = get_tc_rate(maxexemptrate)
# Sanity checks
+ if maxrate < bwmin:
+ maxrate = bwmin
if maxrate > bwcap:
maxrate = bwcap
if maxrate > bwcap:
maxrate = bwcap
+ if minrate < bwmin:
+ minrate = bwmin
if minrate > maxrate:
minrate = maxrate
if minrate > maxrate:
minrate = maxrate
+ if maxexemptrate < bwmin:
+ maxexemptrate = bwmin
if maxexemptrate > bwmax:
maxexemptrate = bwmax
if maxexemptrate > bwmax:
maxexemptrate = bwmax
+ if minexemptrate < bwmin:
+ minexemptrate = bwmin
if minexemptrate > maxexemptrate:
minexemptrate = maxexemptrate
if minexemptrate > maxexemptrate:
minexemptrate = maxexemptrate