diff options
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/keepalived.py | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/python/vyos/keepalived.py b/python/vyos/keepalived.py index 4114aa736..3984ca792 100644 --- a/python/vyos/keepalived.py +++ b/python/vyos/keepalived.py @@ -26,8 +26,6 @@ state_file = '/tmp/keepalived.data' stats_file = '/tmp/keepalived.stats' json_file = '/tmp/keepalived.json' -state_dir = '/var/run/vyos/vrrp/' - def vrrp_running(): if not os.path.exists(vyos.keepalived.pid_file) \ or not vyos.util.process_running(vyos.keepalived.pid_file): @@ -38,6 +36,15 @@ def vrrp_running(): def keepalived_running(): return vyos.util.process_running(pid_file) +## Clear VRRP data after showing +def remove_vrrp_data(data_file): + if data_file == "json" and os.path.exists(json_file): + os.remove(json_file) + elif data_file == "stats" and os.path.exists(stats_file): + os.remove(stats_file) + elif data_file == "state" and os.path.exists(state_file): + os.remove(state_file) + def force_state_data_dump(): pid = vyos.util.read_file(pid_file) os.kill(int(pid), signal.SIGUSR1) @@ -76,26 +83,6 @@ def decode_state(code): return state -## The functions are mainly for transition script wrappers -## to compensate for the fact that keepalived doesn't keep persistent -## state between reloads. -def get_old_state(group): - file = os.path.join(state_dir, "{0}.state".format(group)) - if os.path.exists(file): - with open(file, 'r') as f: - data = f.read().strip() - return data - else: - return None - -def save_state(group, state): - if not os.path.exists(state_dir): - os.makedirs(state_dir) - - file = os.path.join(state_dir, "{0}.state".format(group)) - with open(file, 'w') as f: - f.write(state) - ## These functions are for the old, and hopefully obsolete plaintext ## (non machine-readable) data format introduced by Vyatta back in the days ## They are kept here just in case, if JSON output option turns out or becomes |