1 # vim: set encoding=utf-8 et sw=4 sts=4 :
5 from signal import SIGTERM
6 from subprocess import Popen, PIPE
8 from pymin import procman
9 from pymin.seqtools import Sequence
10 from pymin.dispatcher import Handler, handler, HandlerError
11 from pymin.services.util import Restorable, TransactionalHandler, \
12 ReloadHandler, RestartHandler, \
13 ServiceHandler, ParametersHandler, call
15 __ALL__ = ('VrrpHandler',)
17 # FIXME the the command should not use new parameters unless commit where called
18 # i.e. integrate commit with procman to update internal procman parameters.
19 class VrrpHandler(Restorable, ParametersHandler, ReloadHandler, RestartHandler,
20 ServiceHandler, TransactionalHandler):
22 handler_help = u"Manage VRRP service"
24 _persistent_attrs = ['params']
26 _restorable_defaults = dict(
28 ipaddress = '192.168.0.1',
38 command = ['vrrpd', '-i', self.params['dev'], '-v', self.params['id']]
39 if self.params['prio']:
40 command.extend(('-p', self.params['prio']))
41 command.append(self.params['ipaddress'])
44 def _service_start(self):
45 procinfo = procman.get('vrrp')
46 procinfo.command = self._command
47 procinfo.persist = self.params['persist']
50 def _service_stop(self):
53 def _service_restart(self):
54 procinfo = procman.get('vrrp')
55 procinfo.command = self._command
56 procinfo.persist = self.params['persist']
57 procman.restart('vrrp')
59 def __init__(self, pickle_dir='.', config_dir='.', pid_dir='.'):
60 self._persistent_dir = pickle_dir
61 self._pid_dir = pid_dir
62 procman.register('vrrp', None)
63 ServiceHandler.__init__(self)
66 if __name__ == '__main__':