Bug 1816003

Summary: [RFE] Add the custom_attributes subcollection to hosts collection
Product: Red Hat CloudForms Management Engine Reporter: Fabien Dupont <fdupont>
Component: APIAssignee: Fabien Dupont <fdupont>
Status: CLOSED ERRATA QA Contact: Md Nadeem <mnadeem>
Severity: high Docs Contact: Red Hat CloudForms Documentation <cloudforms-docs>
Priority: high    
Version: 5.11.4CC: dmetzger, mnadeem, obarenbo, pvala, simaishi
Target Milestone: GAKeywords: ZStream
Target Release: 5.11.5Flags: pm-rhel: cfme-5.11.z+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.11.5.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-05 13:43:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: V2V Target Upstream Version:
Embargoed:

Description Fabien Dupont 2020-03-23 07:00:11 UTC
Description of problem:

The hosts collection doesn't support the custom_attributes subcollection, while the model Host class supports custom attributes.

We want to use custom attributes to specify an IP address for V2V on VMware hosts, in order to make traffic go through the fastest NIC instead of admin NIC.

Comment 2 Fabien Dupont 2020-03-23 09:45:13 UTC
https://github.com/ManageIQ/manageiq-api/pull/783

Comment 3 Fabien Dupont 2020-03-23 13:21:36 UTC
To verify this BZ, one has to use the API.

First, we create custom attributes:

POST /api/hosts/:id/custom_attributes
{
  "action": "add",
  "resources": [
    {
      "name": "ca_1",
      "value": "value_1"
    },
    {
      "name": "ca_2",
      "value": "value_2"
    }
  ]
}


Then, we edit a custom attribute:

POST /api/hosts/:id/custom_attributes
{
  "action": "edit",
  "resources": [
    {
      "name": "ca_1",
      "value": "new_value_1"
    }
  ]
}


And finally delete a custom attribute:

POST /api/hosts/:id/custom_attributes
{
  "action": "delete",
  "resources": [
    {
      "name": "ca_2",
      "value": "value_2"
    }
  ]
}

or

POST /api/hosts/:id/custom_attributes/:ca_id

Comment 4 CFME Bot 2020-03-24 13:16:23 UTC
New commit detected on ManageIQ/manageiq-api/jansa:

https://github.com/ManageIQ/manageiq-api/commit/54fc3e3f5e91aa0d413ec1508da1141f0ca28ed7
commit 54fc3e3f5e91aa0d413ec1508da1141f0ca28ed7
Author:     Brandon Dunne <bdunne>
AuthorDate: Mon Mar 23 13:11:53 2020 +0000
Commit:     Brandon Dunne <bdunne>
CommitDate: Mon Mar 23 13:11:53 2020 +0000

    Merge pull request #783 from fdupont-redhat/bz_1816003

    Add the custom_attributes subcollection to hosts collection

    (cherry picked from commit 3206d5152011555f4b15317665c68b9e89254c67)

    https://bugzilla.redhat.com/show_bug.cgi?id=1816003

 app/controllers/api/hosts_controller.rb | 1 +
 config/api.yml | 9 +
 spec/requests/hosts_spec.rb | 122 +
 3 files changed, 132 insertions(+)

Comment 6 Fabien Dupont 2020-04-22 15:58:40 UTC
There's an error in the API to change the custom attribute. There are 2 possible ways: one by one or bulk.

One by one, you need to specify the id of the custom attribute in the URL:


POST /api/hosts/:id/custom_attributes/:id
{
  "action": "edit",
  "resource": {
    "name": "ca_2",
    "value": "value_2"
  }
}

Bulk, you need to specify the id(s) of the custom attribute(s) in the payload:

POST /api/hosts/:id/custom_attributes
{
  "action": "edit",
  "resources": [
    {
      "id": 3,
      "value": "new_value_3"
    }
  ]
}

The documentation seems to be incorrect in that respect, so please open a BZ for CloudForms API.

Comment 10 errata-xmlrpc 2020-05-05 13:43:34 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, 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/RHBA-2020:2020