Bug 1309107 - hammer hostgroup update or create command fails when using --organization-ids option
Summary: hammer hostgroup update or create command fails when using --organization-ids...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Hammer
Version: 6.1.6
Hardware: All
OS: Linux
unspecified
medium vote
Target Milestone: Unspecified
Assignee: Andrew Kofink
QA Contact: Jitendra Yejare
URL: http://projects.theforeman.org/issues...
Whiteboard:
: 1324618 1328188 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-02-16 21:25 UTC by Nagoor Shaik
Modified: 2019-08-12 14:04 UTC (History)
10 users (show)

Fixed In Version: rubygem-hammer_cli_katello-0.0.22.18-1,rubygem-hammer_cli_katello-0.0.22.20-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-27 11:29:21 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Foreman Issue Tracker 14686 None None None 2016-04-26 17:08:00 UTC
Foreman Issue Tracker 15313 None None None 2016-06-07 11:50:50 UTC
Foreman Issue Tracker 15693 None None None 2016-07-15 12:58:00 UTC
Red Hat Bugzilla 1357557 None CLOSED A new option --content-view-organization-id added to bunch of hammer sub-commands though intended for hostgroup cmd only 2019-10-08 09:39:46 UTC

Description Nagoor Shaik 2016-02-16 21:25:49 UTC
Description of problem:
hammer hostgroup update or create command fails when using --organization-ids option fails with below error

# hammer hostgroup update --id 1 --lifecycle-environment "Library" --content-view "R7CV" --organization-ids 1
Could not update the hostgroup:
  Error: Could not find organization, please set one of options --organizations, --organization-ids.

Version-Release number of selected component (if applicable):
Satellite 6.1.7 and below

How reproducible:
100%

Steps to Reproduce:
1. Execute the command either to create or update the hostgroup
   
  # hammer hostgroup update --id 1 --lifecycle-environment "Library" --content-view "MyCV" --organization-ids 1
Could not update the hostgroup:
  Error: Could not find organization, please set one of options --organizations, --organization-ids.

Actual results:
Its failing to parse the --organizations-ids flag, however when using --organization "ORG_NAME" it succeeds.

Expected results:
Should work with --organizations-id option as well.

Additional info:

# hammer hostgroup update --id 1 --lifecycle-environment "Library" --content-view "MyCV" --organizations ACME
   Hostgroup updated

The above command works with --organizations flag not with --organizations-id option.

Comment 2 Brad Buckingham 2016-04-13 16:33:14 UTC
Andrew, this one could be a change to foreman or katello; however, it needs to be investigated.  Foreman provides the hostgroup cli; however, katello does extend it to include some additional details (e.g. content view, lifecycle environment & content source).

Comment 3 Andrew Kofink 2016-04-18 15:37:36 UTC
*** Bug 1324618 has been marked as a duplicate of this bug. ***

Comment 4 Andrew Kofink 2016-04-18 15:38:42 UTC
Organization scoped_search doesn't take an ID.

Comment 5 Andrew Kofink 2016-04-18 15:40:38 UTC
Created redmine issue http://projects.theforeman.org/issues/14686 from this bug

Comment 6 Bryan Kearney 2016-04-18 16:07:49 UTC
Upstream bug component is Provisioning

Comment 7 sthirugn@redhat.com 2016-04-18 16:36:34 UTC
Marking this as blocker as https://bugzilla.redhat.com/show_bug.cgi?id=1324618 is now closed as dupe.

Comment 8 Bryan Kearney 2016-04-18 20:07:27 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/14686 has been closed
-------------
Andrew Kofink
Applied in changeset commit:6ee7a8b40807944058c664248570a3031cdb6172.

Comment 9 Brad Buckingham 2016-04-21 15:40:53 UTC
WORKAROUND: 
For any use of the "hammer hostgroup create/update" commands, please use the --organizations parameter instead of the --organization-ids.

Comment 10 Sachin Ghai 2016-05-13 12:07:18 UTC
Still reproducible with sat6.2 GA snap10.1

[root@cloud-qe-3 ~]# hammer   -u admin -p changeme  hostgroup create --name='testgroup'   --content-view-id 2 --lifecycle-environment='dev' --content-source-id=1   --puppet-proxy-id=1 --puppet-ca-proxy-id=1  --domain-id=1   --subnet='libvirt' --architecture='x86_64' --operatingsystem-id=1   --medium-id 8 --partition-table='Kickstart default' --location-ids=1 --organization-ids=1
Could not create the hostgroup:
  Error: Could not find organization, please set one of options --organizations, --organization-ids.


[root@cloud-qe-3 ~]# hammer -u admin -p changeme organization list
---|----------------------|----------------------|------------
ID | NAME                 | LABEL                | DESCRIPTION
---|----------------------|----------------------|------------
1  | Default Organization | Default_Organization |            
---|----------------------|----------------------|------------
[root@cloud-qe-3 ~]#

Comment 11 Andrew Kofink 2016-05-20 16:58:10 UTC
To specify an organization-id for the lifecycle_environment, use the --lifecycle-environment-organization-id option.

Comment 12 Bryan Kearney 2016-06-06 14:22:16 UTC
Sachin:

Does Comment 11 address this?

Comment 13 Andrew Kofink 2016-06-06 17:06:06 UTC
Comment 11 is the implemented fix, once the PRs are merged.

Comment 14 Sachin Ghai 2016-06-07 07:56:30 UTC
Thanks Andrew.

If we are replacing "--organization-id" with new hammer option `--lifecycle-environment-organization-id ` as per comment11 then if a user tries to pass --organization-id then error message should indicate to use --lifecycle-environment-organization-id instead of --organization-id.

Comment 15 Roman Plevka 2016-06-07 09:58:57 UTC
(In reply to Sachin Ghai from comment #14)
> Thanks Andrew.
> 
> If we are replacing "--organization-id" with new hammer option
> `--lifecycle-environment-organization-id `

According to UI, both --organization-id and --le-org-id should exist as they point to different things. --organization-id should specify an organization to which the hostgroup should be assigned whereas --le-org-id together with --lifecycle-environment should specify the LE (as the name of the lifecycle environment name does not need to be unique across the satellite, multiple organizations might have the LE with the same name).

Comment 16 Bryan Kearney 2016-06-07 11:50:45 UTC
Connecting redmine issue http://projects.theforeman.org/issues/15313 from this bug

Comment 17 Bryan Kearney 2016-06-07 11:51:28 UTC
Connecting redmine issue http://projects.theforeman.org/issues/15312 from this bug

Comment 18 Bryan Kearney 2016-06-07 12:12:54 UTC
Upstream bug component is Content Management

Comment 19 Andrew Kofink 2016-06-07 12:51:14 UTC
Just for clarification, here's an example of how you use the options:

hammer hostgroup create --name hg1 --lifecycle-environment le1 --lifecycle-environment-organization-id 1 --organization-ids 1,2

Comment 20 Bryan Kearney 2016-06-08 18:13:01 UTC
Upstream bug component is Hammer

Comment 21 Sachin Ghai 2016-07-08 08:26:43 UTC
Verified with sat6.2 GA snap19.

As per comment19, I understand user need to pass following two cmd line options:

--lifecycle-environment-organization-id 1 
--organization-ids 1,2

But hammer should throw proper error when any of them is missing, like:

example1: create hostgroup without organization-id.
========
hammer hostgroup create --name hg2 --lifecycle-environment 'DEV' --lifecycle-environment-organization-id 1
Hostgroup created


example2: create hostgroup without --lifecycle-environment-organization-id
===========================================================================
 ~]# hammer hostgroup create --name hg1 --lifecycle-environment 'DEV' --organization-ids 1
Could not create the hostgroup:
  Error: Could not find organization, please set one of options --organizations, --organization-ids.

I specified organization-ids 1, however hammer still throwing error, which is misleading.

Any thoughts Andrew ?

Comment 22 Eric Helms 2016-07-11 22:57:49 UTC
I don't see any changes to the BZ that warrant it being back on POST so moving to ASSIGNED.

Comment 23 Andrew Kofink 2016-07-12 16:50:30 UTC
Sachin,

I didn't implement the functionality in example 2, but I'm reworking this BZ in https://bugzilla.redhat.com/show_bug.cgi?id=1354462 to address some regressions.

I plan on implementing --organization-ids to be used for searching for the content view and the lifecycle environment.

i.e.
> hammer hostgroup create --name hg1 --lifecycle-environment Library --organization-ids 1,2,5
> hammer hostgroup create --name hg1 --content-view cv1 --organization-ids 1,2,5

If multiple lifecycle environments or content views are found, you will be required to use an ID instead of automatic name resolution for the LE/CV.

Comment 24 Sachin Ghai 2016-07-19 08:50:27 UTC
Verified with sat6.2 GA snap20.2

case1: with org-id option and life-cycle env name
=====

 ~]# hammer hostgroup create --name hg1 --lifecycle-environment Library --organization-ids 1
Could not create the hostgroup:
  Error: Options --lifecycle-environment-organization-id are required


Case2: 
=========
As per comment23, we need to pass lifecyle-environment-id instead of name in case multiple lifecycle environments or content views are found


 ~]# hammer hostgroup create --name hg1 --lifecycle-environment-id 1 --organization-ids 1
[Foreman] Password for admin: 
Hostgroup created


case3:
======
I'm able to create hostgroup using  --lifecycle-environment-organization-id=1 option

~]# hammer hostgroup create --name hg1 --lifecycle-environment Library  --lifecycle-environment-organization-id=1
[Foreman] Password for admin: 
Hostgroup created


I'm still not able to understand why we can't crate hostgroup with lifecycle-env name and --organization-id ?

Hey Andrew, Could you please clarify

Comment 25 Andrew Kofink 2016-07-19 12:47:49 UTC
Sachin,

Apologies about the confusion -- we've changed the way you pass in organization-id (again). With this BZ, you needed --content-view-organization-id if you use the --content-view option and the --lifecycle-environment-organization-id option if you use the --lifecycle-environment option. You don't need either organization ID if you're using content view (CV) ID or lifecycle environment (LE) ID. Finally, --organizations or --organization-ids is not used at all for resolving IDs of the CV or LE; it only sets the organizations on the hostgroup.

Now, with BZ #1357557, we've opted to just use --organization-id for both CVs and LEs, like you suggested, since the CV and the LE must be from the same organization on a hostgroup.

I've linked BZ #1357557 to this one.

Comment 26 Jitendra Yejare 2016-07-20 11:35:58 UTC
Verified !

@ Sat 6.2 snap 20.3 GA

As per comment 25 , The hostgroup should be able to create and update with option '--organization-id' and the same is tested as below and is expected :

# hammer hostgroup update --id 2 --lifecycle-environment 'DEV' --content-view 'rhel7_cv' --organization-id 1
Hostgroup updated


# hammer hostgroup create --name 'hg2' --lifecycle-environment 'DEV' --content-view 'rhel7_cv' --operatingsystem 'RedHat 7.2' --organization-id 1 --partition-table 'Kickstart default' --subnet 'subnet1'
Hostgroup created


So moving this to 'Verified' state.

Comment 27 Bryan Kearney 2016-07-27 11:29:21 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:1501

Comment 28 Bryan Kearney 2017-08-11 14:16:58 UTC
*** Bug 1328188 has been marked as a duplicate of this bug. ***


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