commit
f007e56292
6 changed files with 8 additions and 6 deletions
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
1
.gitmodules
vendored
Normal file → Executable file
1
.gitmodules
vendored
Normal file → Executable file
|
@ -1,3 +1,4 @@
|
||||||
[submodule "re2oapi"]
|
[submodule "re2oapi"]
|
||||||
path = re2oapi
|
path = re2oapi
|
||||||
url = https://gitlab.federez.net/re2o/re2oapi.git
|
url = https://gitlab.federez.net/re2o/re2oapi.git
|
||||||
|
branch = master
|
||||||
|
|
0
README.md
Normal file → Executable file
0
README.md
Normal file → Executable file
0
config.ini.example
Normal file → Executable file
0
config.ini.example
Normal file → Executable file
7
main.py
Normal file → Executable file
7
main.py
Normal file → Executable file
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@ api_username = config.get('Re2o', 'username')
|
||||||
def regen_dhcp(api_client):
|
def regen_dhcp(api_client):
|
||||||
host_mac_ip = {}
|
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():
|
if hmi['extension'] not in host_mac_ip.keys():
|
||||||
host_mac_ip[hmi['extension']] = []
|
host_mac_ip[hmi['extension']] = []
|
||||||
host_mac_ip[hmi['extension']].append((hmi['hostname'],
|
host_mac_ip[hmi['extension']].append((hmi['hostname'],
|
||||||
|
@ -33,7 +34,7 @@ def regen_dhcp(api_client):
|
||||||
ipv4=ipv4
|
ipv4=ipv4
|
||||||
) for hostname, mac_address, ipv4 in hmi_list)
|
) 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:
|
with open(filename, 'w+') as f:
|
||||||
f.write(dhcp_leases_content)
|
f.write(dhcp_leases_content)
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ api_client = Re2oAPIClient(api_hostname, api_username, api_password)
|
||||||
|
|
||||||
client_hostname = socket.gethostname().split('.', 1)[0]
|
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 \
|
if service['hostname'] == client_hostname and \
|
||||||
service['service_name'] == 'dhcp' and \
|
service['service_name'] == 'dhcp' and \
|
||||||
service['need_regen']:
|
service['need_regen']:
|
||||||
|
|
2
re2oapi
2
re2oapi
|
@ -1 +1 @@
|
||||||
Subproject commit 5b4523c797bffb90c998d5b424548756baa0c1d2
|
Subproject commit b12df74fe73f351986ff51c8122089644218f8fe
|
Loading…
Add table
Add a link
Reference in a new issue