Project

General

Profile

Bug #20940

API /api/hosts/:id returns inconsistent set of interfaces flags

Added by Tomáš Strachota over 1 year ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Network
Target version:
-
Difficulty:
trivial
Triaged:
No
Bugzilla link:
Team Backlog:
Marek
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1489486

Description of problem:
API host interfaces response is confusing, when querying it on hosts level the interfaces array returns the field "primary" and "provision", but not the other option fields.

The /api/hosts/:id/interfaces level returns all the fields as expected.

That the /api/hosts/:id interfaces array returns only 2 out of the 5 flag fields is confusing for the user why e.g. the "managed" field is not returned.

If the /api/hosts/:id interfaces array would not have returned any flags then it would be better because then as a user i would be triggered to use the /api/hosts/:id/interfaces API call instead

[crash/LI] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999999}" -XGET https://localhost:443/api/v2/hosts/23 | jq .interfaces
[
  {
    "id": 67,
    "name": "li-lc-1441.hag.hilti.com",
    "ip": "10.92.14.89",
    "mac": "00:50:56:97:44:75",
    "identifier": "ens192",
    "primary": true,
    "provision": true,
    "type": "interface" 
  },
  {
    "id": 66,
    "name": "",
    "ip": "10.92.65.49",
    "mac": "00:50:56:97:00:80",
    "identifier": "ens224",
    "primary": false,
    "provision": false,
    "type": "interface" 
  },
  {
    "id": 65,
    "name": "",
    "ip": null,
    "mac": "00:50:56:97:4b:9a",
    "identifier": "ens32",
    "primary": false,
    "provision": false,
    "type": "interface" 
  }
]
[crash/LI] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999999}" -XGET https://localhost:443/api/v2/hosts/23/interfaces | jq .
{   
  "total": 3,
  "subtotal": 3,
  "page": 1, 
  "per_page": 9999999,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },  
  "results": [
    { 
      "subnet_id": 3,
      "subnet_name": "install6-crash",
      "domain_id": 1,
      "domain_name": "hag.hilti.com",
      "created_at": "2017-08-15 14:53:59 UTC",
      "updated_at": "2017-09-07 12:56:03 UTC",
      "managed": true,
      "identifier": "ens192",
      "id": 67,
      "name": "li-lc-1441.hag.hilti.com",
      "ip": "10.92.14.89",
      "mac": "00:50:56:97:44:75",
      "primary": true,
      "provision": true,
      "type": "interface",
      "virtual": false
    },
    { 
      "subnet_id": null,
      "subnet_name": null,
      "domain_id": 1,
      "domain_name": "hag.hilti.com",
      "created_at": "2017-08-15 14:53:55 UTC",
      "updated_at": "2017-09-07 12:11:06 UTC",
      "managed": true,
      "identifier": "ens32",
      "id": 65,
      "name": "",
      "ip": null,
      "mac": "00:50:56:97:4b:9a",
      "primary": false,
      "provision": false,
      "type": "interface",
      "virtual": false
    },
    { 
      "subnet_id": null,
      "subnet_name": null,
      "domain_id": null,
      "domain_name": null,
      "created_at": "2017-08-15 14:53:59 UTC",
      "updated_at": "2017-09-07 12:11:06 UTC",
      "managed": false,
      "identifier": "ens224",
      "id": 66,
      "name": "",
      "ip": "10.92.65.49",
      "mac": "00:50:56:97:00:80",
      "primary": false,
      "provision": false,
      "type": "interface",
      "virtual": false
    }
  ]
}

Steps to Reproduce:
1. Query /api/v2/hosts/:id look at interfaces array
2.
3.

Actual results:
Interfaces array returned with only "primary" and "provision" flags.

Expected results:
Interfaces array returned with all or none of the flags (compare with /api/v2/hosts/:id/interfaces).

Associated revisions

Revision 54047ea5 (diff)
Added by Amit Karsale 4 months ago

Fixes #20940 - Interfaces shows extra fields in API /api/hosts/id

History

#1 Updated by Tomáš Strachota over 1 year ago

  • Subject changed from API /api/hosts/:id returns inconsistent set of interfaces flags to API /api/hosts/:id returns inconsistent set of interfaces flags
  • Category changed from 19 to Network
  • Target version set to 115

#2 Updated by The Foreman Bot over 1 year ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4853 added

#3 Updated by Amit Karsale 4 months ago

  • Triaged set to No
  • Difficulty set to trivial
  • Assignee set to Amit Karsale

#4 Updated by The Foreman Bot 4 months ago

  • Pull request https://github.com/theforeman/foreman/pull/5981 added

#5 Updated by Amit Karsale 4 months ago

  • Pull request deleted (https://github.com/theforeman/foreman/pull/4853)

#6 Updated by Ondřej Pražák 4 months ago

  • Status changed from Ready For Testing to Closed
  • Fixed in Releases 1.20.0 added

Also available in: Atom PDF