1 # vim: set encoding=utf-8 et sw=4 sts=4 :
3 from pymin.seqtools import Sequence
4 from pymin.dispatcher import handler
5 from pymin.service.util import ContainerNotFoundError, ListSubHandler
7 __all__ = ('HopHandler',)
12 def __init__(self, gateway, device):
13 self.gateway = gateway
17 return (self.gateway, self.device)
19 def __cmp__(self, other):
20 if self.gateway == other.gateway \
21 and self.device == other.device:
23 return cmp(id(self), id(other))
25 class HopHandler(ListSubHandler):
26 handler_help = u"Manage IP hops"
27 _cont_subhandler_attr = 'hops'
28 _cont_subhandler_class = Hop
30 @handler('Add a hop: add <device> <gateway>')
31 def add(self, dev, gw):
32 if not dev in self.parent.devices:
33 raise ContainerNotFoundError(device)
34 return ListSubHandler.add(self, dev, gw)