]> git.llucax.com Git - software/pymin.git/commitdiff
qos implementation fixes
authorFederico Cuello <fcuello@integratech.com.ar>
Tue, 6 Nov 2007 18:45:37 +0000 (15:45 -0300)
committerFederico Cuello <fcuello@integratech.com.ar>
Tue, 6 Nov 2007 18:45:37 +0000 (15:45 -0300)
pymin/services/__init__.py
pymin/services/qos/__init__.py

index fabf2644c4121f67d395b99f4147648b27ed96c0..ccf62ed302a350de8764c356b12dfb77227624f8 100644 (file)
@@ -8,3 +8,4 @@ from pymin.services.ip import IpHandler
 from pymin.services.proxy import ProxyHandler
 from pymin.services.vrrp import VrrpHandler
 from pymin.services.ppp import PppHandler
 from pymin.services.proxy import ProxyHandler
 from pymin.services.vrrp import VrrpHandler
 from pymin.services.ppp import PppHandler
+from pymin.services.qos import QoSHandler
index 40252ff7825105d770f932d5c1b558fef43e2f9f..ca09d9d3ae69e5c21cb52bc08f41bf169771a136 100644 (file)
@@ -32,16 +32,16 @@ class ClassAlreadyExistsError(ClassError):
 
 class Class(Sequence):
 
 
 class Class(Sequence):
 
-    def __init__(self, id, rate=None):
-        self.id = id
+    def __init__(self, cid, rate=None):
+        self.cid = cid
         self.rate = rate
         self.hosts = list()
 
     def as_tuple(self):
         self.rate = rate
         self.hosts = list()
 
     def as_tuple(self):
-        return (self.id, self.rate)
+        return (self.cid, self.rate)
 
     def __cmp__(self, other):
 
     def __cmp__(self, other):
-        if self.id == other.id
+        if self.cid == other.cid:
             return 0
         return cmp(id(self), id(other))
 
             return 0
         return cmp(id(self), id(other))
 
@@ -52,25 +52,25 @@ class ClassHandler(Handler):
         self.parent = parent
 
     @handler('Adds a class : add <id> <device> <rate>')
         self.parent = parent
 
     @handler('Adds a class : add <id> <device> <rate>')
-    def add(self, id, dev, rate):
+    def add(self, cid, dev, rate):
         if not dev in self.parent.devices:
             raise DeviceNotFoundError(device)
         if not dev in self.parent.devices:
             raise DeviceNotFoundError(device)
-        c = Class(id, dev, rate)
+        c = Class(cid, dev, rate)
         try:
             self.parent.classes.index(c)
         try:
             self.parent.classes.index(c)
-            raise ClassAlreadyExistsError(id  + '->' + dev)
+            raise ClassAlreadyExistsError(cid  + '->' + dev)
         except ValueError:
             self.parent.classes.append(c)
 
     @handler(u'Deletes a class : delete <id> <device>')
         except ValueError:
             self.parent.classes.append(c)
 
     @handler(u'Deletes a class : delete <id> <device>')
-    def delete(self, id, dev):
+    def delete(self, cid, dev):
         if not dev in self.parent.devices:
             raise DeviceNotFoundError(device)
         if not dev in self.parent.devices:
             raise DeviceNotFoundError(device)
-        c = Class(id, dev)
+        c = Class(cid, dev)
         try:
             self.parent.classes.remove(c)
         except ValueError:
         try:
             self.parent.classes.remove(c)
         except ValueError:
-            raise ClassNotFoundError(id + '->' + dev)
+            raise ClassNotFoundError(cid + '->' + dev)
 
     @handler(u'Lists classes : list <dev>')
     def list(self, device):
 
     @handler(u'Lists classes : list <dev>')
     def list(self, device):
@@ -160,7 +160,7 @@ class QoSHandler(Restorable, ConfigWriter, TransactionalHandler):
     _restorable_defaults = dict(
                             devices=dict((dev, Device(dev, mac))
                                 for (dev, mac) in get_network_devices().items()),
     _restorable_defaults = dict(
                             devices=dict((dev, Device(dev, mac))
                                 for (dev, mac) in get_network_devices().items()),
-                            classes = list()
+                            classes = list(),
                             hosts = list()
                             )
 
                             hosts = list()
                             )
 
@@ -182,22 +182,22 @@ class QoSHandler(Restorable, ConfigWriter, TransactionalHandler):
     def _write_config(self):
         r"_write_config() -> None :: Execute all commands."
         for device in self.devices.values():
     def _write_config(self):
         r"_write_config() -> None :: Execute all commands."
         for device in self.devices.values():
-            call(self._render_config('devices', dict(dev=device.name, action='del')), shell=True)
-            call(self._render_config('devices', dict(dev=device.name, action='add')), shell=True)
+            call(self._render_config('device', dict(dev=device.name, action='del')), shell=True)
+            call(self._render_config('device', dict(dev=device.name, action='add')), shell=True)
             for qosclass in device.classes:
                 call(self._render_config('class_add', dict(
                         dev = device.name,
             for qosclass in device.classes:
                 call(self._render_config('class_add', dict(
                         dev = device.name,
-                        id = qosclass.id,
+                        cid = qosclass.cid,
                         rate = qosclass.rate
                     )
                 ), shell=True)
                         rate = qosclass.rate
                     )
                 ), shell=True)
-            for host in classes.hosts:
-                call(self._render_config('host_add', dict(
-                        dev = device.name,
-                        ip = host.ip,
-                        id = qosclass.id
-                    )
-                ), shell=True)
+                for host in qosclass.hosts:
+                    call(self._render_config('host_add', dict(
+                            dev = device.name,
+                            ip = host.ip,
+                            cid = qosclass.cid
+                        )
+                    ), shell=True)
 
     def handle_timer(self):
         self.refresh_devices()
 
     def handle_timer(self):
         self.refresh_devices()