from pymin.services.util import Restorable, ConfigWriter \
,TransactionalHandler, DictSubHandler, call
-__ALL__ = ('PppHandler')
+__ALL__ = ('PppHandler',)
-class Error(HandlerError):
- r"""
- Error(command) -> Error instance :: Base ConnectionHandler exception class.
-
- All exceptions raised by the ConnectionHandler inherits from this one, so you can
- easily catch any ConnectionHandler exception.
-
- message - A descriptive error message.
- """
- pass
-
-class ConnectionError(Error, KeyError):
+class ConnectionError(HandlerError, KeyError):
r"""
ConnectionError(hostname) -> ConnectionError instance
handler_help = u"Manages connections for the ppp service"
- _dict_subhandler_attr = 'conns'
- _dict_subhandler_class = Connection
+ _cont_subhandler_attr = 'conns'
+ _cont_subhandler_class = Connection
class PppHandler(Restorable, ConfigWriter, TransactionalHandler):
@handler('Starts the service')
def start(self, name):
if name in self.conns:
- #call(('pon', name))
- print ('pon', name)
+ call(['pppd','call', name],stdout=None, stderr=None)
+ #print ('pon', name)
else:
raise ConnectionNotFoundError(name)
@handler('Stops the service')
def stop(self, name):
if name in self.conns:
- #call(('poff', name))
- print ('poff', name)
+ if path.exists('/var/run/ppp-' + name + '.pid'):
+ pid = file('/var/run/ppp-' + name + '.pid').readline().strip()
+ call(['kill',pid],stdout=None, stderr=None)
+ #print ('poff', name)
else:
raise ConnectionNotFoundError(name)
p.conn.add('ppptunnel_c','dominio\luca','luca',type='TUNNEL',server='192.168.0.23')
p.commit()
print p.conn.list()
- print p.conn.show()
\ No newline at end of file
+ print p.conn.show()