Description of problem: When we try to update existing host over API with the PUT statement and there is a NIC configuration as part of the API call, we receive the following error: { "data": { "error": { "id": 5469, "errors": { "interfaces.primary": [ "host already has primary interface" ], "interfaces.mac": [ "has already been taken" ], "interfaces.ip": [ "has already been taken" ], "interfaces.name": [ "has already been taken" ] }, "full_messages": [ "Primary host already has primary interface", "Mac has already been taken", "Ip has already been taken", "Name has already been taken" ] } How reproducible: Always, just try to alter the NIC parameters via API with PUT statement, or keep the parameters same. Steps to Reproduce: 1. Create a json file with new host configuration 2. Call the API 3. Actual results: Error messages as mentioned in the Problem Description. Expected results: No errors - if nothing is changed the parameters should be ignored. The API looks like this: { "name": "short-hostname", "architecture_id": 1, "operatingsystem_id": 19, "ptable_id": 208, "medium_id": 21, "location_id": 5, "organization_id": 3, "domain_id": 1, "interfaces_attributes": [ { "ip": "1.2.3.4", "mac": "00:aa:26:bb:13:cc", "type": "interface", "name": "short-hostname.example.com", "subnet_id": 1, "domain_id": 1, "identifier": "", "primary": true } ], In this case the parameters of the NIC has not been changed.
If I understand correctly, user is trying to use Host api to manipulate interfaces, which is usually hard due to correrctly defining all attributes. I'd recommend using the interfaces PAI enpoint directly, see apidoc for interfaces, e.g. GET /api/hosts/:host_id/interfaces
Upstream bug assigned to ymakias
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/10236 has been resolved.
Thanks mhulan for information. To sum up: when user tries to create new interface with host edit API endpoint, the separate NIC API endpoints should be used as mentioned in comment #3. Instead of the documentation update the error message was improved. If that is not enough, please let us know in separate bugzilla, and link this BZ to a new one. Verified with sat 6.10 snap 20. The new error message was shown.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (Moderate: Satellite 6.10 Release), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2021:4702