#DEBUG = False
DEBUG = True
-__ALL__ = ('Error', 'ExecutionError', 'ItemError', 'ItemAlreadyExistsError',
+__all__ = ('Error', 'ExecutionError', 'ItemError', 'ItemAlreadyExistsError',
'ItemNotFoundError', 'ContainerError', 'ContainerNotFoundError',
'call', 'get_network_devices', 'Persistent', 'Restorable',
'ConfigWriter', 'ServiceHandler', 'RestartHandler',
def __init__(self, key):
r"Initialize the object. See class documentation for more info."
- self.message = u'Item already exists: "%s"' % key
+ self.message = u'Item already exists: %s' % key
class ItemNotFoundError(ItemError):
r"""
self.name = name
self.mac = mac
self.ppp = ppp
+ self.active = True
self.addrs = dict()
self.routes = list()
def as_tuple(self):
- return (self.name, self.mac, self.addrs)
+ return (self.name, self.mac, self.active, self.addrs)
# do we have the same item? then raise an error
if key in self._vattr():
log.debug(u'ContainerSubHandler.add: allready exists')
- raise ItemAlreadyExistsError(item)
+ if not isinstance(self._attr(), dict):
+ key = self._attr().index(item)
+ raise ItemAlreadyExistsError(key)
# do we have the same item, but logically deleted? then update flags
if key in self._attr():
log.debug(u'ContainerSubHandler.add: was deleted, undeleting it')
log.debug(u'ContainerSubHandler.clear()')
# FIXME broken really, no _delete attribute is setted :S
if isinstance(self._attr(), dict):
- self._attr.clear()
+ self._attr().clear()
else:
self._attr(list())
# do we have the same item? then raise an error
if key in self._vattr(cont):
log.debug(u'ComposedSubHandler.add: allready exists')
- raise ItemAlreadyExistsError(item)
+ if not isinstance(self._attr(), dict):
+ key = self._attr().index(item)
+ raise ItemAlreadyExistsError(key)
# do we have the same item, but logically deleted? then update flags
if key in self._attr(cont):
log.debug(u'ComposedSubHandler.add: was deleted, undeleting it')