Bug 1495206

Summary: [Hammer] Satellite doesnt throws error for duplicate subnet parameters
Product: Red Hat Satellite Reporter: Jitendra Yejare <jyejare>
Component: NetworkingAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED NOTABUG QA Contact: Katello QA List <katello-qa-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: bbuckingham, jyejare, mhulan
Target Milestone: Unspecified   
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-09-27 18:06:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1493107    

Description Jitendra Yejare 2017-09-25 13:42:53 UTC
Description of problem:
From hammer, Satellite is not throwing any exception for duplicate subnet parameters. 

Version-Release number of selected component (if applicable):
Satellite 6.3.0 snap 17

How reproducible:
Always

Steps to Reproduce:
1. Create a subnet with two parameters with the same name

Actual results:
Satellite is not throwing an exception for duplicate subnet parameters from hammer. 

# hammer $cliauth subnet set-parameter --name street --value 'Sat Strret' --subnet-id 1
Subnet parameter updated

# hammer $cliauth subnet set-parameter --name street --value 'Sat6 Strret' --subnet-id 1
Subnet parameter updated

The plus point is it doesn't actually add the duplicate parameter in subnet.


Expected results:
From hammer, Satellite should throw an exception while attempting to create a duplicate subnet parameter having same name.

Comment 2 Brad Buckingham 2017-09-25 15:05:37 UTC
Is this a regression to 6.2?

Comment 3 Jitendra Yejare 2017-09-25 16:09:36 UTC
@brad,

There was no parameterized subnets feature in 6.2. This is a new 6.3 feature 'Parameterized Subnets'

Also just now I came to know that set-parameter works as update-parameter as well. Where name is the key to update that particular parameter. 
So instead of throwing 'duplication error', it actually updates the parameter.

With that said, there are some drawbacks using hammer wrt subnet parameters:
1. User will never be alerted for subnet parameter duplication
2. User will never be able to update parameter name as that's the key to update only value

There is another component 'Domain' which has this same functionality and that is there from years.

I am really confused if we should stick set-parameter = update-parameter or we should have an altogether dedicated parameter option that has suboptions to delete, update and create a parameter.

Comment 4 Brad Buckingham 2017-09-25 16:30:32 UTC
Jitendra, Thanks for the quick reply.  I am unfamiliar with this feature; therefore, adding a needinfo for Marek.  He may be able to answer or point us in the right direction.

Comment 5 Jitendra Yejare 2017-09-26 09:35:47 UTC
Also, It is not possible to list the parameters with the current model of parameters for all components in the satellite.

Comment 6 Marek Hulan 2017-09-27 18:06:06 UTC
Jitendra, hammer does not create any duplicate parameter. If the parameter with a given name does not exists, it's created, otherwise, it's updated. That's why it's called set, not create. If you see help, it also indicates this is intended behavior

> hammer subnet -h
> Usage:
>     hammer subnet [OPTIONS] SUBCOMMAND [ARG] ...
> 
> Parameters:
>  SUBCOMMAND                    Subcommand
>  [ARG] ...                     Subcommand arguments
> 
> Subcommands:
>  create                        Create a subnet
>  delete                        Delete a subnet
>  delete-parameter              Delete parameter for a subnet.
>  info                          Show a subnet
>  list                          List of subnets
>  set-parameter                 Create or update parameter for a subnet.
>  update                        Update a subnet

In case the parameter did not exist, hammer replies with 

> New subnet parameter created

while when it was existing parameter, it tells you

> Subnet parameter updated

To update the name of the parameter, just do delete and create. 
If you look at other resources for which you can create parameters, such as domain or os, it works the same way. We should keep it as it is at least for consistency.

Listing parameters for model is already possible. Just see model detail, e.g.

> hammer subnet info --id 1

At the end of the list you see Parameters section.

I assume it's a valid RFE to add "rename-parameter" command, but in that case it would be for all resources, not just subnet. Given the fact we haven't received a report about this for other resources, I would expect it be a low priority. If you think it's valuable, please open a new RFE.

Having said all of above, I'm closing as NOTABUG.