Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1192556 - Apipie-bindings 0.0.11 breaks hammer-cli-import
Apipie-bindings 0.0.11 breaks hammer-cli-import
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Transitions (Show other bugs)
Nightly
Unspecified Unspecified
urgent Severity urgent (vote)
: Unspecified
: Unused
Assigned To: Grant Gainey
Lukas Pramuk
: Regression, Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-02-13 11:58 EST by Grant Gainey
Modified: 2017-02-23 15:31 EST (History)
5 users (show)

See Also:
Fixed In Version: rubygem-hammer_cli_import-0.10.7-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-08-12 01:25:39 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 RHSA-2015:1592 normal SHIPPED_LIVE Important: Red Hat Satellite 6.1.1 on RHEL 6 2015-08-12 05:04:35 EDT

  None (edit)
Description Grant Gainey 2015-02-13 11:58:36 EST
Description of problem:

Something changed in apipie-bindings that causes hammer-cli-import's usethereof to break with 

Error: undefined method `[]' for nil:NilClass

Version-Release number of selected component (if applicable):

hammer-cli-import-0.10.6
ruby193-rubygem-apipie-params-0.0.3-2.el6sat.noarch
rubygem-apipie-bindings-0.0.11-1.el6_6sat.noarch

How reproducible:

Anything that attempts to actually use apipie-bindings, in hammer-import - e.g.:

hammer -v import organization --csv-file /tmp/exports/users.csv --debug --verbose

Actual results:

[root@ibm-ls21-04 tmp]# hammer -v import organization --csv-file /tmp/exports/users.csv --debug --verbose
/usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.4/lib/hammer_cli/./apipie/../abstract.rb:68: warning: already initialized constant DEFAULT_LABEL_INDENT
[ERROR 2015-02-13 11:54:08 Exception] Error: undefined method `[]' for nil:NilClass
Error: undefined method `[]' for nil:NilClass
[ERROR 2015-02-13 11:54:08 Exception] 

NoMethodError (undefined method `[]' for nil:NilClass):
    /usr/lib/ruby/gems/1.8/gems/hammer_cli_import-0.10.6/lib/hammer_cli_import/base.rb:118:in `api_init'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli_import-0.10.6/lib/hammer_cli_import/base.rb:547:in `execute'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.4/lib/hammer_cli/./apipie/../abstract.rb:23:in `run'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.4/lib/hammer_cli/./apipie/../abstract.rb:23:in `run'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.4/lib/hammer_cli/./apipie/../abstract.rb:23:in `run'
    /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:125:in `run'
    /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.4/bin/hammer:108
    /usr/bin/hammer:19:in `load'
    /usr/bin/hammer:19

Expected results:

Creation of organizations (for example)

Additional info:

The failing line is

        @api_usr = @api.instance_variable_get('@client').instance_variable_get('@options')[:user]

from this initialization method:

      def api_init
        @api = HammerCLIForeman.foreman_api_connection.api
        @api_usr = @api.instance_variable_get('@client').instance_variable_get('@options')[:user]
        @api_pwd = @api.instance_variable_get('@client').instance_variable_get('@options')[:password]
        nil
      end

Used to work, no longer does.

MUST BE FIXED before 6.1 releases.
Comment 2 Grant Gainey 2015-02-13 14:10:09 EST
PR#16 submitted
Comment 3 Martin Bacovsky 2015-02-16 06:29:22 EST
My comment from the PR, just for a record:

Depending on instance variables is error prone, as they are not part of the library interface and can change even between minor versions.

If I understand it correctly the credentials obtained in the code above are used only for calling repository upload-content command from import. I'd suggest to reuse existing connection which will also prevent issues when we e.g. introduce other auth methods to hammer.

I'd suggest to call the upload-content command as follows:

        require('hammer_cli_katello/repository')
        HammerCLIKatello::Repository::UploadContentCommand.new("", context).run({'id' => <id>, 'path' => <path>})
Comment 4 Grant Gainey 2015-02-17 14:58:30 EST
katello/hammer-cli-import.git:
eb7228cf69f213713e5c9766e897d4fd9af4a883
b7580590543f17e2b01ad893bc1637732a100453
Comment 7 Lukas Pramuk 2015-03-10 04:58:30 EDT
VERIFIED. rubygem-hammer_cli_import-0.10.6.3-1.el6_6sat

# hammer import organization --verbose --csv-file /tmp/exports/users.csv --upload-manifests-from '/tmp/manifests''
/usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.4/lib/hammer_cli/./apipie/../abstract.rb:68: warning: already initialized constant DEFAULT_LABEL_INDENT
Importing from /tmp/exports/users.csv
Creating new organization: RED HAT SATELLITE ENGINEERING
Uploading manifest /tmp/manifests/RED_HAT_SATELLITE_ENGINEERING.zip to org-id 3
Waiting for the task [4b8d6deb-4594-4913-affb-ef5e30b47bcb] .................
Creating new organization: Organization #2
Uploading manifest /tmp/manifests/Organization__2.zip to org-id 4
Waiting for the task [6f5e9af6-4a48-4f7c-829b-7b83f52f4714] ..........
Creating new organization: Organization #3
Uploading manifest /tmp/manifests/Organization__3.zip to org-id 5
Waiting for the task [3946507d-7ec2-48f4-8924-41d71e3d97d8] ..........
Summary
  Created 3 organizations.
  Uploaded 3 manifests.
Comment 8 Bryan Kearney 2015-08-11 09:22:48 EDT
This bug is slated to be released with Satellite 6.1.
Comment 9 errata-xmlrpc 2015-08-12 01:25:39 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/RHSA-2015:1592

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