diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-01-15 14:12:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-15 14:12:20 +0800 |
commit | 065a2d415a7d6faa7201e0d21ea73357100304e7 (patch) | |
tree | d73a378b2292f53465ae4021bb012ee31b7fcde8 /python | |
parent | f7c3e427c19a0137f76a3291c888a21239b3a0db (diff) | |
parent | 187d34b82f80c9c251c81cf9b96aa8d52e9f21e2 (diff) | |
download | vyos-1x-065a2d415a7d6faa7201e0d21ea73357100304e7.tar.gz vyos-1x-065a2d415a7d6faa7201e0d21ea73357100304e7.zip |
Merge pull request #207 from DmitriyEshenko/vrrp-nb
vrrp: T1884: Keep transition-script native behaviour and implement tr…
Diffstat (limited to 'python')
-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 |