summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2021-07-08 08:43:53 -0500
committerDaniil Baturin <daniil@vyos.io>2021-07-08 08:45:03 -0500
commit859afacfeafcd56cecc065b463e75639b3e72d7e (patch)
tree02ee55194e9c03d481367cfa1b2d8f94bb32540f /src
parentae59f14144ee158f46dbd5716b2c94d14deae829 (diff)
downloadvyos-1x-859afacfeafcd56cecc065b463e75639b3e72d7e.tar.gz
vyos-1x-859afacfeafcd56cecc065b463e75639b3e72d7e.zip
T3663: use inotify-based waiting for keepalived in `show vrrp`
Diffstat (limited to 'src')
-rwxr-xr-xsrc/op_mode/vrrp.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/op_mode/vrrp.py b/src/op_mode/vrrp.py
index 8d1369823..7a1146b9e 100755
--- a/src/op_mode/vrrp.py
+++ b/src/op_mode/vrrp.py
@@ -27,10 +27,9 @@ import vyos.util
def print_summary():
try:
- vyos.keepalived.force_json_dump()
- # Wait for keepalived to produce the data
- # Replace with inotify or similar if it proves problematic
- time.sleep(0.2)
+ json_data = vyos.util.wait_for_file_write_complete(vyos.keepalived.json_file,
+ pre_hook=(lambda: vyos.keepalived.force_json_dump()),
+ timeout=30)
json_data = vyos.keepalived.get_json_data()
vyos.keepalived.remove_vrrp_data("json")
except:
@@ -60,8 +59,9 @@ def print_summary():
def print_statistics():
try:
- vyos.keepalived.force_stats_dump()
- time.sleep(0.2)
+ json_data = vyos.util.wait_for_file_write_complete(vyos.keepalived.stats_file,
+ pre_hook=(lambda: vyos.keepalived.force_stats_dump()),
+ timeout=30)
output = vyos.keepalived.get_statistics()
print(output)
vyos.keepalived.remove_vrrp_data("stats")
@@ -71,8 +71,9 @@ def print_statistics():
def print_state_data():
try:
- vyos.keepalived.force_state_data_dump()
- time.sleep(0.2)
+ json_data = vyos.util.wait_for_file_write_complete(vyos.keepalived.state_file,
+ pre_hook=(lambda: vyos.keepalived.force_state_data_dump()),
+ timeout=30)
output = vyos.keepalived.get_state_data()
print(output)
vyos.keepalived.remove_vrrp_data("state")