Bug 1416797

Summary: Ability to add a custom attribute that already exists
Product: Red Hat CloudForms Management Engine Reporter: Gilad Shefer <gshefer>
Component: ProvidersAssignee: Zohar Gal-Or <zgalor>
Status: CLOSED NOTABUG QA Contact: Gilad Shefer <gshefer>
Severity: low Docs Contact:
Priority: low    
Version: 5.7.0CC: fsimonce, greartes, gshefer, jfrey, jhardy, mtayer, obarenbo, twade
Target Milestone: GAFlags: gshefer: automate_bug+
Target Release: 5.8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: container
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1429228 (view as bug list) Environment:
Last Closed: 2017-04-24 15:23:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: Container Management Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1429228    

Description Gilad Shefer 2017-01-26 12:48:49 UTC
Description of problem:
Ability to add a custom attribute (to provider) that already exists

Version-Release number of selected component (if applicable):
5.7.0.17

How reproducible:
100%

Steps to Reproduce:
1. (via API) add custom attributes with name <name>
2. (via API) add custom attributes with name <name>
3.

Actual results:
The custom attribute has successfully added (overrided the existent one)

Expected results:
You should see an error, i.e. "Custom attribute <name> already exists"

Additional info:

Comment 2 Reartes Guillermo 2017-01-29 20:47:22 UTC
Hi,

I did not found "custom" attributes here:
http://manageiq.org/docs/reference/latest/api/appendices/resource_attributes#providers

Are we talking of custom attributes for VMs? (or Instances ,etc, depending on the provider)

I already used "custom attributes" to VMs/Instances, but i did not find other "custom attributes".

In case of custom attributes for VMs/Instances, that behavior (while incorrect) is quite convenient.

Cheers.

Comment 5 Mooli Tayer 2017-04-23 14:09:32 UTC
Gilad Please add:

The request you are using (POST, PUT etc)
the entire body

Comment 6 Gilad Shefer 2017-04-24 11:27:45 UTC
method: post
url: https://<appliance IP>/api/providers/1/custom_attributes

payload:

{
"action": "add",
"resources": [{
    "name": "foo",
    "value": "17"
}]}

Comment 7 Zohar Gal-Or 2017-04-24 12:20:58 UTC
There seems to be an intent in the code to allow "edit" from "add":
https://github.com/ManageIQ/manageiq/blob/master/app/controllers/api/subcollections/custom_attributes.rb#L35-L36

This code is common for Vms and Providers,
and as Guillermo stated in comment 2 this could be quite convenient.

However, this seems to be a confusing behaviour.

Tim, what do you think?

Comment 8 Tim Wade 2017-04-24 15:23:56 UTC
As per conversation in Gitter, this is intended behavior: 

https://gitter.im/ManageIQ/api?at=58fe170e881b89e1017f2eb2