summaryrefslogtreecommitdiff
path: root/python/vyos/keepalived.py
diff options
context:
space:
mode:
authorDmitriyEshenko <dmitriy.eshenko@vyos.io>2020-01-14 21:24:42 +0000
committerDmitriyEshenko <dmitriy.eshenko@vyos.io>2020-01-14 21:24:42 +0000
commit187d34b82f80c9c251c81cf9b96aa8d52e9f21e2 (patch)
treed73a378b2292f53465ae4021bb012ee31b7fcde8 /python/vyos/keepalived.py
parentf7c3e427c19a0137f76a3291c888a21239b3a0db (diff)
downloadvyos-1x-187d34b82f80c9c251c81cf9b96aa8d52e9f21e2.tar.gz
vyos-1x-187d34b82f80c9c251c81cf9b96aa8d52e9f21e2.zip
vrrp: T1884: Keep transition-script native behaviour and implement transaction-script 'stop'
Diffstat (limited to 'python/vyos/keepalived.py')
-rw-r--r--python/vyos/keepalived.py31
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