Bug 1720664 - Unable to change NIC configuration - update the host update API documentation
Summary: Unable to change NIC configuration - update the host update API documentation
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: 6.4
Hardware: Unspecified
OS: Unspecified
high
high with 1 vote
Target Milestone: 6.10.0
Assignee: satellite6-bugs
QA Contact: tstrych
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-06-14 13:36 UTC by Roman Bobek
Modified: 2021-11-16 14:08 UTC (History)
9 users (show)

Fixed In Version: foreman-2.5.2.6-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-16 14:08:28 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 10236 0 Normal New Wrong error message when one attempts to create second primary/provision interface via API 2021-02-14 12:38:19 UTC
Red Hat Product Errata RHSA-2021:4702 0 None None None 2021-11-16 14:08:40 UTC

Description Roman Bobek 2019-06-14 13:36:48 UTC
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.

Comment 3 Marek Hulan 2019-09-05 08:29:30 UTC
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

Comment 10 Bryan Kearney 2021-06-14 16:03:05 UTC
Upstream bug assigned to ymakias

Comment 11 Bryan Kearney 2021-06-14 16:03:07 UTC
Upstream bug assigned to ymakias

Comment 12 Bryan Kearney 2021-06-16 12:03:27 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/10236 has been resolved.

Comment 17 tstrych 2021-09-24 10:36:31 UTC
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.

Comment 20 errata-xmlrpc 2021-11-16 14:08:28 UTC
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


Note You need to log in before you can comment on or make changes to this bug.