diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e672c2..1b6fec7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - +## Unreleased + +### Added + +- `a_add` & `aaaa_add` `-force` option to force use an IP from a network that cannot be found in MREG. + +### Fixed + +- Commands that try to find networks by IP raising a 404 error instead of a proper error message when no network can be found with the given IP. ## [1.2.2](https://github.com/unioslo/mreg-cli/releases/tag/1.2.2) - 2024-12-09 diff --git a/mreg_cli/api/models.py b/mreg_cli/api/models.py index 31a44da..2f36499 100644 --- a/mreg_cli/api/models.py +++ b/mreg_cli/api/models.py @@ -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) diff --git a/mreg_cli/commands/host_submodules/a_aaaa.py b/mreg_cli/commands/host_submodules/a_aaaa.py index 1d79b70..cd9fa83 100644 --- a/mreg_cli/commands/host_submodules/a_aaaa.py +++ b/mreg_cli/commands/host_submodules/a_aaaa.py @@ -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")