Readme à jour, et quelques modifications sur les noms de variables.
This commit is contained in:
parent
f228493399
commit
4bc4cb7abe
8 changed files with 152 additions and 102 deletions
|
@ -42,31 +42,31 @@ else:
|
|||
ldap_conn = None
|
||||
|
||||
@record_service()
|
||||
def dhcp(ob_id, body=None):
|
||||
"""Regenerates dhcp service taking body into account.
|
||||
def dhcp(ob_id, operations=None):
|
||||
"""Regenerates dhcp service taking operations into account.
|
||||
|
||||
"""
|
||||
|
||||
# http://satyajit.ranjeev.in/2012/01/12/python--dangerous-default-value-as-argument.html
|
||||
# dict are referenced.
|
||||
if body is None:
|
||||
body = {}
|
||||
if operations is None:
|
||||
operations = {}
|
||||
|
||||
if body and isinstance(body, dict):
|
||||
for (mac, ip, name) in body.get("add", []):
|
||||
if operations and isinstance(operations, dict):
|
||||
for (mac, ip, name) in operations.get("add", []):
|
||||
logger.info("Updating DHCP db by adding %s, %s, %s", mac, ip, name)
|
||||
# XXX - Uncommend this when we need to start prod
|
||||
# add_dhcp_host(mac, ip, name)
|
||||
for (mac, ip) in body.get("delete", []):
|
||||
for (mac, ip) in operations.get("delete", []):
|
||||
logger.info("Updating DHCP db by deleting %s, %s", mac, ip)
|
||||
# XXX - Uncommend this when we need to start prod
|
||||
# delete_dhcp_host(mac, ip)
|
||||
for (rmac, rip, mac, ip, name) in body.get("update", []):
|
||||
for (rmac, rip, mac, ip, name) in operations.get("update", []):
|
||||
logger.info("Updating DHCP db by modifying %s, %s to %s, %s, %s", rmac, rip, mac, ip, name)
|
||||
# XXX - Uncommend this when we need to start prod
|
||||
# delete_dhcp_host(rmac, rip)
|
||||
# add_dhcp_host(mac, ip, name)
|
||||
elif body == True:
|
||||
elif operations == True:
|
||||
hosts = {}
|
||||
host_template = """
|
||||
host %(nom)s {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue