Bug 1359694

Summary: Hostgroup create/update doesn't allow to set list of organizations
Product: Red Hat Satellite Reporter: Stanislav Tkachenko <stkachen>
Component: Content ManagementAssignee: Andrew Kofink <akofink>
Status: CLOSED ERRATA QA Contact: sthirugn <sthirugn>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: akofink, bbuckingham, bkearney, inecas, mbacovsk, mmccune, oshtaier, sghai, sthirugn, zhunting
Target Milestone: UnspecifiedKeywords: Regression, Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: tfm-rubygem-hammer_cli_katello-0.0.22.25-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-08-16 07:11:41 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:

Description Stanislav Tkachenko 2016-07-25 10:14:44 UTC
Description of problem:
It is not possible to set several organizations during hostgroup create/update from CLI using --organization-id option, though it is possible trough UI/API.

According to bug 1309107 option --organization-ids should be replaced with --organization-id. However, *-ids option still present but works only if --lifecycle-environment and --location-ids not specified. And *-id option doesn't allow to set list of organizations or does not set organizations at all if -lifecycle-environment and --location-ids not specified. Please see examples below.

Several examples:
1. Create hostgroup using --organization-ids, --lifecycle-environment and --location-ids:
# hammer -v -u admin -p changeme hostgroup create --lifecycle-environment="pi7djt" --location-ids="19" --organization-ids="18,8" --name="test10"

Exception] Error: Could not find organization, please set one of options --organizations, --organization-ids.
Could not create the hostgroup:

2. Create hostgroup using --organization-ids only:
# hammer -v -u admin -p changeme hostgroup create --organization-ids="18,8" --name="test11"

# hammer -u admin -p changeme hostgroup info --name="test11"
Id:                     13
Name:                   test11
Organizations:          
    AlyxZXWCqzPP
    pIK2ar
Parent Id:

3. Create hostgroup using --organization-id, --lifecycle-environment and --location-ids:
# hammer -v -u admin -p changeme hostgroup create --lifecycle-environment="pi7djt" --location-ids="19" --organization-id="18,8" --name="test12"

# hammer -u admin -p changeme hostgroup info --name="test12"
Id:                     14
Name:                   test12
Locations:              
    2gX7xfNRzq
Organizations:          
    pIK2ar
Parent Id:

4. Create hostgroup using --organization-id only:
# hammer -v -u admin -p changeme hostgroup create --organization-id="18,8" --name="test13"

# hammer -u admin -p changeme hostgroup info --name="test13"
Id:                     15
Name:                   test13
Parameters:             
Parent Id:


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

How reproducible:
Always

Steps to Reproduce:
1. Create organization entity
2. Check options in examples above
3. Use hammer to create hostgroup linked to that organization

Actual results:
Depending on the provided options hostgroup would be linked to the one organization or no organizations at all.

Expected results:
Hostgroup should be linked to the all provided organizations

Additional info:

Comment 4 Ivan Necas 2016-07-26 07:08:50 UTC
Is this generic hammer or content specific bug?

Comment 5 Oleksandr Shtaier 2016-07-26 07:58:52 UTC
This is a hammer specific bug as we can add multiple organizations to hostgroup through both API and WebUI. We could do that from hammer too, but not now

Comment 7 Martin Bacovsky 2016-07-26 10:58:06 UTC
@inecas, this is content specific hammer bug related to changes mentioned in c#1.

Comment 8 Brad Buckingham 2016-07-28 14:29:33 UTC
The user can still associate organizations with a hostgroup via the CLI; however, it must be done using the --organization-ids (or --organizations) parameters.  The use of --organization-id (or --organization) is reserved for use when --lifecycle-environment is included, to support resolving the specific environment. 

The following are a few examples:

SCENARIO 1: (valid)
-----------
hammer> hostgroup create --name groupA --organization-ids 1,3
Hostgroup created
hammer> hostgroup info --name groupA
Id:                     6
Name:                   groupA
Title:                  groupA
Puppet CA Proxy Id:     
Puppet Master Proxy Id: 
Puppetclasses:          

Parameters:             

Organizations:          
    Default Organization
    org2
Parent Id:

SCENARIO 2: (valid)
-----------
hammer> hostgroup create --name groupB --organization-ids 1,3 --lifecycle-environment dev --organization-id 1
Hostgroup created
hammer> hostgroup info --name groupB
Id:                     7
Name:                   groupB
Title:                  groupB
Puppet CA Proxy Id:     
Puppet Master Proxy Id: 
Puppetclasses:          

Parameters:             

Organizations:          
    Default Organization
    org2
Parent Id:

SCENARIO 3: (error expected; however, error text should indicate --organization or --organization id
-----------
hammer> hostgroup create --name groupC --organization-ids 1,3 --lifecycle-environment dev
Could not create the hostgroup:
  Error: Could not find organization, please set one of options --organizations, --organization-ids.
hammer> 

SCENARIO 4: (valid alternative, specifying lifecycle environment id)
-----------
hammer> hostgroup create --name groupC --organization-ids 1,3 --lifecycle-environment-id 3
Hostgroup created
hammer> 


Based on the above, the command is working as expected in Satellite 6.2; however, the error message for SCENARIO 3 needs to be updated to reflect the correct parameters.  We'll work on addressing that with this bug.

Comment 11 sthirugn@redhat.com 2016-08-05 18:40:12 UTC
Verified in satellite-6.2.0-21.2.el7sat.noarch.  Works in the same way as explained in Comment 8.  bbuckingham++ for taking time to explain all the valid/error scenarios - great documentation!


hammer> hostgroup create --name hostgroup1 --organization-ids 1,3
Hostgroup created

hammer> hostgroup info --name hostgroup1
Id:                     4
Name:                   hostgroup1
Title:                  hostgroup1
Puppet CA Proxy Id:     
Puppet Master Proxy Id: 
Puppetclasses:          

Parameters:             

Organizations:          
    Default Organization
    testorg1
Parent Id:

hammer> hostgroup create --name hostgroup2 --organization-ids 1,3 --lifecycle-environment QE --organization-id=1
Hostgroup created

hammer> hostgroup info --name hostgroup2
Id:                     5
Name:                   hostgroup2
Title:                  hostgroup2
Puppet CA Proxy Id:     
Puppet Master Proxy Id: 
Puppetclasses:          

Parameters:             

Organizations:          
    Default Organization
    testorg1
Parent Id:

hammer> hostgroup create --name hostgroup3 --organization-ids 1,3 --lifecycle-environment QE
[ERROR 2016-08-05 14:36:14 Exception] Error: At least one of options --organization-id, --organization is required

See: ' hostgroup create --help'
Could not create the hostgroup:
  Error: At least one of options --organization-id, --organization is required
  
  See: ' hostgroup create --help'

hammer> hostgroup create --name hostgroup3 --organization-ids 1,3 --lifecycle-environment-id=2
Hostgroup created

hammer> hostgroup info --name hostgroup3
Id:                     6
Name:                   hostgroup3
Title:                  hostgroup3
Puppet CA Proxy Id:     
Puppet Master Proxy Id: 
Puppetclasses:          

Parameters:             

Organizations:          
    Default Organization
    testorg1
Parent Id:

Comment 14 errata-xmlrpc 2016-08-16 07:11:41 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-2016:1615