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 class VrrpHandler(Restorable, ParametersHandler, TransactionalHandler):
13 handler_help = u"Manage VRRP service"
15 _persistent_attrs = 'params'
17 _restorable_defaults = dict(
18 params = dict( ipaddress='192.168.0.1',
25 def __init__(self, pickle_dir='.', config_dir='.', pid_dir='.'):
26 self._persistent_dir = pickle_dir
27 self._pid_dir = pid_dir
30 @handler('Starts the service')
32 if self.params['prio'] != '':
33 call(('/usr/local/bin/vrrpd','-i',self.params['dev'],'-v',self.params['id'],'-p',self.params['prio'],self.params['ipaddress']))
34 #print ('vrrpd','-i',self.params['dev'],'-v',self.params['id'],'-p',self.params['prio'],self.params['ipaddress'])
36 call(('/usr/local/bin/vrrpd','-i',self.params['dev'],'-v',self.params['id'],self.params['ipaddress']))
37 #print ('vrrpd','-i',self.params['dev'],'-v',self.params['id'],self.params['ipaddress'])
39 @handler('Stop the service')
42 pid = 'vrrpd' + '_' + self.params['dev'] + '_' + self.params['id'] + '.pid'
43 f = file(path.join(self._pid_dir, pid ), 'r')
44 call(('kill',f.read().strip('\n')))
45 #print('kill','<',f.read())
49 @handler('Reloads the service')
55 if __name__ == '__main__':