X-Git-Url: https://git.llucax.com/software/pymin.git/blobdiff_plain/52d87d11873f1a37b21100700f4798a375361f3f..60de22ab6dba022c4a6ed243c15f1e941f8154cd:/pymin/services/ppp/__init__.py diff --git a/pymin/services/ppp/__init__.py b/pymin/services/ppp/__init__.py index 0445df1..868b6d5 100644 --- a/pymin/services/ppp/__init__.py +++ b/pymin/services/ppp/__init__.py @@ -9,7 +9,7 @@ from pymin.services.util import Restorable, ConfigWriter \ __ALL__ = ('PppHandler',) -class ConnectionError(Error, KeyError): +class ConnectionError(HandlerError, KeyError): r""" ConnectionError(hostname) -> ConnectionError instance @@ -67,8 +67,8 @@ class ConnectionHandler(DictSubHandler): 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): @@ -94,16 +94,18 @@ 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) @@ -143,4 +145,4 @@ if __name__ == '__main__': 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()