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,29 +42,29 @@ def fwrecord(fun):
|
|||
FwFactory.register(fun.func_name, fun)
|
||||
|
||||
@record_service()
|
||||
def firewall(ob_id, body=()):
|
||||
def firewall(ob_id, operations=()):
|
||||
"""Regens the specific service
|
||||
|
||||
"""
|
||||
if len(body) != 2:
|
||||
logger.warning("Received body %r, this format is incorrect, discarding.", body)
|
||||
if len(operations) != 2:
|
||||
logger.warning("Received operations %r, this format is incorrect, discarding.", operations)
|
||||
return
|
||||
(service, data) = body
|
||||
(service, data) = operations
|
||||
logger.info("Calling service %s for data %r", service, data)
|
||||
# XXX - Uncomment when in prod
|
||||
#FwFactory.get(service)(data)
|
||||
|
||||
@fwrecord
|
||||
def mac_ip(body):
|
||||
def mac_ip(operations):
|
||||
host_fw = firewall4.firewall()
|
||||
if body and isinstance(body, dict):
|
||||
for (mac, ip) in body.get("add", []):
|
||||
if operations and isinstance(operations, dict):
|
||||
for (mac, ip) in operations.get("add", []):
|
||||
logger.info("Adding mac_ip %s,%s", mac, ip)
|
||||
host_fw.mac_ip_append(mac, ip)
|
||||
for (mac, ip) in body.get("delete", []):
|
||||
for (mac, ip) in operations.get("delete", []):
|
||||
logger.info("Removing mac_ip %s,%s", mac, ip)
|
||||
host_fw.mac_ip_remove(mac, ip)
|
||||
for (rmac, rip, mac, ip) in body.get("update", []):
|
||||
for (rmac, rip, mac, ip) in operations.get("update", []):
|
||||
logger.info("Updating mac_ip %s,%s with %s,%s", rmac, rip, mac, ip)
|
||||
host_fw.mac_ip_remove(rmac, rip)
|
||||
host_fw.mac_ip_append(mac, ip)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue