1 # vim: set encoding=utf-8 et sw=4 sts=4 :
4 from subprocess import Popen, PIPE
6 from pymin.seqtools import Sequence
7 from pymin.dispatcher import Handler, handler, HandlerError
8 from pymin.services.util import Restorable, TransactionalHandler, ParametersHandler, call
10 __ALL__ = ('VrrpHandler')
12 pid_filename = 'vrrp.pid'
14 class VrrpHandler(Restorable, ParametersHandler, TransactionalHandler):
15 handler_help = u"Manage VRRP service"
17 _persistent_attrs = 'params'
19 _restorable_defaults = dict(
20 params = dict( ipaddress='192.168.0.1',
27 def __init__(self, pickle_dir='.', config_dir='.', pid_dir='.'):
28 self._persistent_dir = pickle_dir
29 self._pid_dir = pid_dir
32 @handler('Starts the service')
34 if self.params['prio'] != '':
35 #call(('vrrp','-i',self.params[dev],'-v',self.params[id],'-p',self.params[prio],self.params[ipaddress]))
36 print ('vrrp','-i',self.params['dev'],'-v',self.params['id'],'-p',self.params['prio'],self.params['ipaddress'])
38 #call(('vrrp','-i',self.params[dev],'-v',self.params[id],self.params[ipaddress]))
39 print ('vrrp','-i',self.params['dev'],'-v',self.params['id'],self.params['ipaddress'])
41 @handler('Stop the service')
44 f = file(path.join(self._pid_dir, pid_filename ), 'r')
45 #call(('kill','<',f.read()))
46 print(('kill','<',f.read()))
50 @handler('Reloads the service')
56 if __name__ == '__main__':