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 1242488 - hammer says "Error: 301 Moved Permanently" when you are missing "https://" in server option
Summary: hammer says "Error: 301 Moved Permanently" when you are missing "https://" in...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer
Version: 6.1.0
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: Unspecified
Assignee: Martin Bacovsky
QA Contact: Lukas Zapletal
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-07-13 12:27 UTC by Jan Hutař
Modified: 2019-09-26 14:53 UTC (History)
8 users (show)

Fixed In Version: foreman-1.15.3-2
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-21 16:51:07 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 11147 0 Normal Closed hammer says "Error: 301 Moved Permanently" when you are missing "https://" in server option 2020-02-25 01:06:37 UTC

Description Jan Hutař 2015-07-13 12:27:21 UTC
Description of problem:
Hammer says "Error: 301 Moved Permanently" when you are missing "https://" in server option. It is not user-friendly and I had to bug developer to find that typo.


Version-Release number of selected component (if applicable):
rubygem-hammer_cli-0.1.4.11-1.el6_6sat.noarch


How reproducible:
always


Steps to Reproduce:
1. hammer --server $(hostname) --username admin --password changeme organization create --label 'satellite-qa' --name 'satellite-qa'


Actual results:
# hammer --server $(hostname) --username admin --password changeme organization create --label 'satellite-qa' --name 'satellite-qa'
Could not create the organization:
  Error: 301 Moved Permanently


Expected results:
Some useful error message explaining what is wrong


Additional info:
Running with "https://" is OK:

# hammer --server https://$(hostname) --username admin --password changeme organization create --label 'satellite-qa' --name 'satellite-qa'
Organization created

Comment 2 RHEL Program Management 2015-07-13 12:44:35 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 4 Bryan Kearney 2015-07-17 15:35:53 UTC
Created redmine issue http://projects.theforeman.org/issues/11147 from this bug

Comment 6 Bryan Kearney 2016-03-08 15:00:59 UTC
Upstream bug assigned to mbacovsk

Comment 7 Bryan Kearney 2016-03-08 15:01:02 UTC
Upstream bug assigned to mbacovsk

Comment 8 Bryan Kearney 2016-03-10 23:01:00 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/11147 has been closed
-------------
Martin Bacovsky
Applied in changeset commit:hammer-cli-foreman|4a9eceb007ad9dcea3d5052b83a1f96bf5e176af.

Comment 9 Martin Bacovsky 2016-04-27 09:15:52 UTC
The change in hammer-cli-foreman requires apipie-bindings >= 0.0.16 to get working (or https://github.com/Apipie/apipie-bindings/pull/41 cherry-picked as well)

Comment 10 Sachin Ghai 2016-05-09 08:01:52 UTC
Reproducible with sat62 GA snap10.1 though error is bit different:

~]# hammer --server $(hostname) -u admin -p changeme product create --name test1 --organization-id 1
Error: undefined method `request' for #<String:0x000000045e36a8>

NoMethodError (undefined method `request' for #<String:0x00000003fce3d0>):
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/exceptions.rb:71:in `method_missing'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.6/lib/hammer_cli_foreman/exception_handler.rb:31:in `handle_moved_permanently'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.6/lib/hammer_cli/exception_handler.rb:28:in `handle_exception'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.6/lib/hammer_cli/messages.rb:26:in `handle_exception'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.6/lib/hammer_cli/abstract.rb:26:in `rescue in run'
 

with "https://" working as expected.
 ~]# hammer --server https://$(hostname) -u admin -p changeme product create --name test1 --organization-id 1
Product created

Comment 12 Martin Bacovsky 2016-05-20 13:07:00 UTC
The issue is fixed by patch in apipie-bindings https://github.com/Apipie/apipie-bindings/pull/44

Comment 17 Lukas Zapletal 2017-08-30 12:18:31 UTC
[root@zzzap ~]# hammer --server $(hostname) --username admin --password changeme ping
Redirection of API call detected.
It seems hammer is configured to use HTTP and the server prefers HTTPS.
Update your server url configuration
you can set 'follow_redirects' to one of :default or :always to enable redirects following

[root@zzzap ~]# vim /etc/hammer/cli.modules.d/foreman.yml 
https://github.com/mbacovsky/hammer-cli-foreman/blob/4a9eceb007ad9dcea3d5052b83a1f96bf5e176af/config/foreman.yml

[root@zzzap ~]# hammer --server $(hostname) --username admin --password changeme ping
candlepin:      
    Status:          ok
    Server Response: Duration: 20ms
candlepin_auth: 
    Status:          ok
    Server Response: Duration: 19ms
pulp:           
    Status:          ok
    Server Response: Duration: 38ms
pulp_auth:      
    Status:          ok
    Server Response: Duration: 23ms
foreman_tasks:  
    Status:          ok
    Server Response: Duration: 362ms

One nitpick tho, the config file has no examples, it is modified by puppet perhaps.

[root@zzzap ~]# rpm -q foreman katello
foreman-1.15.3-2.el7sat.noarch
katello-3.4.4-2.el7sat.noarch

Comment 18 Satellite Program 2018-02-21 16:51:07 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/RHSA-2018:0336


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