Skip to content

Instantly share code, notes, and snippets.

@thuhak
Created October 29, 2019 08:41
Show Gist options
  • Save thuhak/15dc7bc503c7de7b2b4f6828fdef8ca7 to your computer and use it in GitHub Desktop.
Save thuhak/15dc7bc503c7de7b2b4f6828fdef8ca7 to your computer and use it in GitHub Desktop.
get keep alive VIP
import re
def _get_keepalive_vip(conf='/etc/keepalived/keepalived.conf'):
result = []
try:
with open(conf) as f:
pat = re.compile(r'virtual_ipaddress(?:\s|\t\|\n)*\{(.*?)\}', re.DOTALL)
keepalive = f.read()
match = pat.findall(keepalive)
for d in match:
result.extend(d.split())
except:
pass
return set(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment