Skip to content

Commit

Permalink
Allow a(aaa)_add with IP from non-existent network
Browse files Browse the repository at this point in the history
  • Loading branch information
pederhan committed Dec 16, 2024
1 parent c2df782 commit 6731515
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mreg_cli/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ def get_by_ip(cls, ip: IP_AddressT) -> Self | None:
:returns: The network if found, None otherwise.
:raises EntityNotFound: If the network is not found.
"""
resp = get(Endpoint.NetworksByIP.with_id(str(ip)))
resp = get(Endpoint.NetworksByIP.with_id(str(ip)), ok404=True)
if not resp:
return None
return cls.model_validate_json(resp.text)
Expand Down
3 changes: 3 additions & 0 deletions mreg_cli/commands/host_submodules/a_aaaa.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ def _add_ip(
network = Network.get_by_ip(ip_or_net.as_ip())
ip = ip_or_net.as_ip()

if not force and not network:
raise ForceMissing(f"Network for {ip} not found, must force")

if not force and network and network.frozen:
raise ForceMissing(f"Network {network.network} is frozen, must force")

Expand Down

0 comments on commit 6731515

Please sign in to comment.