Bug 1416797 - Ability to add a custom attribute that already exists
Summary: Ability to add a custom attribute that already exists
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Providers
Version: 5.7.0
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: GA
: 5.8.0
Assignee: Zohar Gal-Or
QA Contact: Gilad Shefer
URL:
Whiteboard: container
Depends On:
Blocks: 1429228
TreeView+ depends on / blocked
 
Reported: 2017-01-26 12:48 UTC by Gilad Shefer
Modified: 2017-04-24 15:23 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1429228 (view as bug list)
Environment:
Last Closed: 2017-04-24 15:23:56 UTC
Category: ---
Cloudforms Team: Container Management
Target Upstream Version:
Embargoed:
gshefer: automate_bug+


Attachments (Terms of Use)

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


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