Skip to content

Commit 5c19881

Browse files
committed
fix cleanup for kea
1 parent 5715578 commit 5c19881

1 file changed

Lines changed: 14 additions & 23 deletions

File tree

  • python/ironic-understack/ironic_understack/dhcp

python/ironic-understack/ironic_understack/dhcp/kea.py

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -90,33 +90,24 @@ def _update_host_reservation(self, hw_address, boot_file_prefix=None, remove=Fal
9090
found = False
9191
for reservation in reservations:
9292
if reservation.get("hw-address") == hw_address:
93-
# reservation["option-data"] = [
94-
# {
95-
# "name": "boot-file-base",
96-
# "data": boot_file_prefix,
97-
# "always-send": True,
98-
# }
99-
# ]
100-
reservation["client-classes"] = ["BOOTSRV_A"]
93+
if not remove:
94+
reservation["client-classes"] = ["BOOTSRV_A"]
95+
else:
96+
reservations.pop(reservation)
10197
found = True
10298
break
10399
if not found:
104-
reservations.append(
105-
{
106-
"hw-address": hw_address,
107-
# "option-data": [
108-
# {
109-
# "name": "boot-file-base",
110-
# "data": boot_file_prefix,
111-
# "always-send": True,
112-
# },
113-
# ],
114-
"client-classes": ["BOOTSRV_A"],
115-
}
116-
)
117-
dhcp4_config["reservations"] = reservations
100+
if not remove:
101+
reservations.append(
102+
{
103+
"hw-address": hw_address,
104+
"client-classes": ["BOOTSRV_A"],
105+
}
106+
)
107+
dhcp4_config["reservations"] = reservations
108+
else:
109+
return True
118110

119-
print(dhcp4_config)
120111
config["arguments"]["Dhcp4"] = dhcp4_config
121112
self.set_config(config["arguments"])
122113
return True

0 commit comments

Comments
 (0)