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 1354462 - Hammer hostgroup create insist on lifecycle environment
Summary: Hammer hostgroup create insist on lifecycle environment
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: Andrew Kofink
QA Contact: Jitendra Yejare
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-07-11 11:40 UTC by Lukas Zapletal
Modified: 2019-09-25 21:29 UTC (History)
6 users (show)

Fixed In Version: rubygem-hammer_cli_katello-0.0.22.21-1,rubygem-hammer_cli_katello-0.0.22.22-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-27 11:36:47 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 15701 0 None None None 2016-07-15 13:08:13 UTC

Description Lukas Zapletal 2016-07-11 11:40:36 UTC
*REGRESSION* (was working in pre-15 drops)

*BLOCKER* (unable to create hostgroup via CLI -> no provisioning)

Some recent change broke hammer cli command:

[root@hp-bl465cg7-01 ~]# hh hostgroup create --name "CentOS 7.0"   --architecture x86_64   --domain nested.lan   --subnet nested.lan   --operatingsystem "CentOS 7.0"   --medium mirror_centos   --partition-table "Kickstart simple"   --puppet-proxy-id 1   --puppet-ca-proxy-id 1   --environment production   --root-pass "$PASS$PASS$PASS"   --organizations "$ORG"   --locations "$LOC"
Could not create the hostgroup:
  Error: lifecycle_environment not found

This was previously working. Now, the problem is it does not respect lifecycle-environment option which was added:

[root@hp-bl465cg7-01 ~]# hh hostgroup create --name "CentOS 7.0"   --architecture x86_64   --domain nested.lan   --subnet nested.lan   --operatingsystem "CentOS 7.0"   --medium mirror_centos   --partition-table "Kickstart simple"   --puppet-proxy-id 1   --puppet-ca-proxy-id 1   --environment production   --root-pass "$PASS$PASS$PASS"   --organizations "$ORG"   --locations "$LOC"   --lifecycle-environment "TestEnv"
Could not create the hostgroup:
  Error: lifecycle_environment not found

You can't provide even numeric ID - all is ignored. Debug mode reveals that due to typo in the codebase perhaps, the CLI tries to search Katello environments via --environment (puppet) option:

[ INFO 2016-07-11 07:34:01 API] GET /katello/api/organizations/1/environments
[DEBUG 2016-07-11 07:34:01 API] Params: {
    "name" => "production"
}
[DEBUG 2016-07-11 07:34:01 API] Headers: {
    :params => {
        "name" => "production"
    }
}
[DEBUG 2016-07-11 07:34:01 API] Response: {
       "total" => 0,
    "subtotal" => 0,
        "page" => 1,
    "per_page" => 20,
       "error" => nil,
      "search" => nil,
        "sort" => {
           "by" => nil,
        "order" => nil
    },
     "results" => []
}

The query is "production" while I expect it to be "TestEnv".

This bug is unfortunate as it blocks automated CLI installation and setup of provisioning. Hostgroup is a must in provisioning setups (for activation key).

Comment 4 Andrew Kofink 2016-07-11 15:14:56 UTC
Created redmine issue http://projects.theforeman.org/issues/15647 from this bug

Comment 5 Lukas Zapletal 2016-07-18 07:21:35 UTC
I can't get it working. Do you test the patch downstream during review?

[root@dell-pem610-01 ~]# rpm -q tfm-rubygem-hammer_cli_katello
tfm-rubygem-hammer_cli_katello-0.0.22.21-1.el7sat.noarch

[root@dell-pem610-01 ~]# hh hostgroup create --name "CentOS 7.0"   --architecture x86_64   --domain nested.lan   --subnet nested.lan   --operatingsystem "CentOS 7.0"   --medium mirror_centos   --partition-table "Kickstart simple"   --puppet-proxy-id 1   --puppet-ca-proxy-id 1   --environment production   --root-pass "$PASS$PASS$PASS"   --organizations "$ORG"   --locations "$LOC"   --lifecycle-environment "TestEnv"
Could not create the hostgroup:
  Error: Options --lifecycle-environment-organization-id are required
  
  See: 'hammer hostgroup create --help'

[root@dell-pem610-01 ~]# hh hostgroup create --name "CentOS 7.0"   --architecture x86_64   --domain nested.lan   --subnet nested.lan   --operatingsystem "CentOS 7.0"   --medium mirror_centos   --partition-table "Kickstart simple"   --puppet-proxy-id 1   --puppet-ca-proxy-id 1   --environment production   --root-pass "$PASS$PASS$PASS"   --organizations "$ORG"   --locations "$LOC"   --lifecycle-environment "TestEnv"   --lifecycle-environment-organization-id 1
Could not create the hostgroup:
  Error: found more than one environment

It looks like the cause is the one which Martin described in comment 3:

[ INFO 2016-07-18 03:20:49 API] GET /api/environments
[DEBUG 2016-07-18 03:20:49 API] Params: {
    "name" => "production"
}
[DEBUG 2016-07-18 03:20:49 API] Headers: {
    :params => {
        "name" => "production"
    }
}
[DEBUG 2016-07-18 03:20:49 API] Response: {
       "total" => 3,
    "subtotal" => 3,
        "page" => 1,
    "per_page" => 100,
      "search" => nil,
        "sort" => {
           "by" => nil,
        "order" => nil
    },
     "results" => [
        [0] {
            "created_at" => "2016-07-18 00:49:01 UTC",
            "updated_at" => "2016-07-18 00:49:01 UTC",
                  "name" => "KT_MyOrg_Library_TestCV_2",
                    "id" => 2
        },
        [1] {
            "created_at" => "2016-07-18 00:49:39 UTC",
            "updated_at" => "2016-07-18 00:49:39 UTC",
                  "name" => "KT_MyOrg_TestEnv_TestCV_2",
                    "id" => 3
        },
        [2] {
            "created_at" => "2016-07-18 00:04:51 UTC",
            "updated_at" => "2016-07-18 00:04:51 UTC",
                  "name" => "production",
                    "id" => 1
        }
    ]
}

Comment 7 Lukas Zapletal 2016-07-19 06:55:30 UTC
It works!

$ hh hostgroup create --name "CentOS 7.0"   --architecture x86_64   --domain nested.lan   --subnet nested.lan   --operatingsystem "CentOS 7.0"   --medium mirror_centos   --partition-table "Kickstart simple"   --puppet-proxy-id 1   --puppet-ca-proxy-id 1   --environment production   --root-pass "$PASS$PASS$PASS"   --organizations "$ORG"   --locations "$LOC"   --lifecycle-environment "TestEnv" --lifecycle-environment-organization-id 1
Hostgroup created

I have to say the --lifecycle-environment-organization-id is a bit clunky, but what we can do in this stage. Created feature for the future versions: http://projects.theforeman.org/issues/15730

Thanks!

Comment 8 Andrew Kofink 2016-07-19 13:33:23 UTC
Lukas,

Now, with BZ #1357557, we've opted to just use --organization-id for both CVs and LEs, since the CV and the LE must be from the same organization on a hostgroup. I hesitate to try to resolve CV/LE IDs with the --organizations/--organization-ids option since there is a chance you have identically named CVs/LEs across different organizations. The --organization-ids/--organizations option is just for assigning the hostgroup to those organizations.

Comment 9 Jitendra Yejare 2016-07-20 12:03:13 UTC
Verified !

@ Sat 6.2 snap 20.3 GA

I can see that hostgroup can be created with and without lifecycle-environment as below and is expected :

# hammer hostgroup create --name "hg3" --architecture x86_64 --domain 'rhq.lab.eng.bos.redhat.com' --subnet 'subnet1' --operatingsystem "RedHat 7.2" --medium 'Default_Organization/Library/rhel7_pro/rhel7_pro_repo' --partition-table 'Kickstart default' --puppet-proxy-id 1 --puppet-ca-proxy-id 1 --environment 'production' --root-pass "$PASS$PASS$PASS" --organization-id 1 --location-ids 2 --lifecycle-environment "DEV"
Hostgroup created

# hammer hostgroup create --name "hg4" --architecture x86_64 --domain 'rhq.lab.eng.bos.redhat.com' --subnet 'subnet1' --operatingsystem "RedHat 7.2" --medium 'Default_Organization/Library/rhel7_pro/rhel7_pro_repo' --partition-table 'Kickstart default' --puppet-proxy-id 1 --puppet-ca-proxy-id 1 --environment 'production' --root-pass "$PASS$PASS$PASS" --organization-id 1 --location-ids 2
Hostgroup created

The Hostgroup 'hg4' above is located in 'Any Context' and not in organization-id 1. If it is not the expected behavior feel free to open another bug.

Moving this bug to 'Verified' state.

Comment 10 Bryan Kearney 2016-07-27 11:36:47 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


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