add [Aliases] support

This commit is contained in:
Gilles Grandou 2019-10-07 09:19:16 +02:00
parent 841e6043c6
commit df66e50d47
2 changed files with 8 additions and 1 deletions

View File

@ -19,7 +19,7 @@ from ovh import ovh
def load_conf():
global zone_filename, log_filename
global wan_hostname, zone_domain, zone_subdomain
global hosts_list, hosts_ipv4_nat_list
global hosts_list, hosts_ipv4_nat_list, hosts_alias_list
global mail_from, mail_to
conf = configparser.ConfigParser(allow_no_value=True)
@ -36,6 +36,7 @@ def load_conf():
hosts_list = [ host for host in conf['Hosts'] ]
hosts_ipv4_nat_list = [ host for host in conf['NatHosts'] ]
hosts_alias_list = conf['Aliases']
def ping(hostname):
@ -43,6 +44,7 @@ def ping(hostname):
ret = subprocess.run(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return 0 if ret.returncode else 1
def get_ipv6_hosts():
r = sysbus.requete('Devices:get')
@ -51,6 +53,8 @@ def get_ipv6_hosts():
if not 'IPv6Address' in h or not h['IPv6Address']:
continue
hostname = h['Name']
if hostname in hosts_alias_list:
hostname = hosts_alias_list[hostname]
for a in h['IPv6Address']:
if a['Scope'] != 'global' or a['Status'] != 'reachable':
continue

View File

@ -13,6 +13,9 @@ mypc1
mypc2
mypc3
[Aliases]
mypc1-wifi = mypc1
[NatHosts]
mypc2
mypc4