Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1359694 - Hostgroup create/update doesn't allow to set list of organizations
Summary: Hostgroup create/update doesn't allow to set list of organizations
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Content Management
Version: 6.2.0
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: Unspecified
Assignee: Andrew Kofink
QA Contact: sthirugn@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-07-25 10:14 UTC by Stanislav Tkachenko
Modified: 2019-09-26 18:04 UTC (History)
10 users (show)

Fixed In Version: tfm-rubygem-hammer_cli_katello-0.0.22.25-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-08-16 07:11:41 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:1615 0 normal SHIPPED_LIVE Satellite 6.2.1 bug fix update 2016-08-16 11:09:48 UTC

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


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