Commit f007e562 authored by klafyvel's avatar klafyvel
Browse files

Merge branch 'crans' into 'master'

Crans

See merge request !1
parents 072eb642 8ad669a5
File mode changed from 100644 to 100755
[submodule "re2oapi"]
path = re2oapi
url = https://gitlab.federez.net/re2o/re2oapi.git
branch = master
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
#!/usr/bin/env python3
from configparser import ConfigParser
import socket
......@@ -13,7 +14,7 @@ api_username = config.get('Re2o', 'username')
def regen_dhcp(api_client):
host_mac_ip = {}
for hmi in api_client.list_hostmacip():
for hmi in api_client.list("dhcp/hostmacip/"):
if hmi['extension'] not in host_mac_ip.keys():
host_mac_ip[hmi['extension']] = []
host_mac_ip[hmi['extension']].append((hmi['hostname'],
......@@ -33,7 +34,7 @@ def regen_dhcp(api_client):
ipv4=ipv4
) for hostname, mac_address, ipv4 in hmi_list)
filename = 'dhcp{extension}.list'.format(extension=extension)
filename = 'generated/dhcp{extension}.list'.format(extension=extension)
with open(filename, 'w+') as f:
f.write(dhcp_leases_content)
......@@ -41,9 +42,9 @@ api_client = Re2oAPIClient(api_hostname, api_username, api_password)
client_hostname = socket.gethostname().split('.', 1)[0]
for service in api_client.list_servicesregen():
for service in api_client.list("services/regen"):
if service['hostname'] == client_hostname and \
service['service_name'] == 'dhcp' and \
service['need_regen']:
regen_dhcp(api_client)
api_client.patch(service['api_url'], data={'need_regen': False})
regen_dhcp(api_client)
api_client.patch(service['api_url'], data={'need_regen': False})
Subproject commit 5b4523c797bffb90c998d5b424548756baa0c1d2
Subproject commit b12df74fe73f351986ff51c8122089644218f8fe
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment