Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1359694 - Hostgroup create/update doesn't allow to set list of organizations
Hostgroup create/update doesn't allow to set list of organizations
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Content Management (Show other bugs)
6.2.0
x86_64 Linux
unspecified Severity high (vote)
: 6.2.1
: Unused
Assigned To: Andrew Kofink
sthirugn@redhat.com
: Regression, Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-07-25 06:14 EDT by Stanislav Tkachenko
Modified: 2018-08-31 11 EDT (History)
10 users (show)

See Also:
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 03:11:41 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:1615 normal SHIPPED_LIVE Satellite 6.2.1 bug fix update 2016-08-16 07:09:48 EDT

  None (edit)
Description Stanislav Tkachenko 2016-07-25 06:14:44 EDT
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 03:08:50 EDT
Is this generic hammer or content specific bug?
Comment 5 Oleksandr Shtaier 2016-07-26 03:58:52 EDT
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 06:58:06 EDT
@inecas, this is content specific hammer bug related to changes mentioned in c#1.
Comment 8 Brad Buckingham 2016-07-28 10:29:33 EDT
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 14:40:12 EDT
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 03:11:41 EDT
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

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