diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.gitmodules b/.gitmodules old mode 100644 new mode 100755 index 361b0a1..b75ea02 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "re2oapi"] path = re2oapi url = https://gitlab.federez.net/re2o/re2oapi.git + branch = master diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/config.ini.example b/config.ini.example old mode 100644 new mode 100755 diff --git a/main.py b/main.py old mode 100644 new mode 100755 index 46abdec..985967a --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +#!/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}) diff --git a/re2oapi b/re2oapi index 5b4523c..b12df74 160000 --- a/re2oapi +++ b/re2oapi @@ -1 +1 @@ -Subproject commit 5b4523c797bffb90c998d5b424548756baa0c1d2 +Subproject commit b12df74fe73f351986ff51c8122089644218f8fe