Hammer commands throws error "undefined method `closed?' for nil:NilClass"

Solution Verified - Updated -

Issue

  • Hammer commands throws an error:

    [root@satellite ~]# hammer host-collection list
    Error: undefined method `closed?' for nil:NilClass
    
  • Trying hammer with debug logging on shows:

    [root@satellite ~]# hammer -d host-collection list --organization=MyOrg
    [ INFO 2018-01-22 13:57:42 Init] Initialization of Hammer CLI (0.5.1.13) has started...
    [DEBUG 2018-01-22 13:57:42 Init] Running at ruby 2.2.2-p95
    [ INFO 2018-01-22 13:57:42 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
    [ INFO 2018-01-22 13:57:42 Init] Configuration from the file /etc/hammer/cli.modules.d/csv.yml has been loaded
    [ INFO 2018-01-22 13:57:42 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
    [ INFO 2018-01-22 13:57:42 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_admin.yml has been loaded
    [ INFO 2018-01-22 13:57:42 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_admin_logging_core.yml has been loaded
    [ INFO 2018-01-22 13:57:42 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_admin_logging_katello.yml has been loaded
    [ INFO 2018-01-22 13:57:42 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_bootdisk.yml has been loaded
    [ INFO 2018-01-22 13:57:42 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_discovery.yml has been loaded
    [ INFO 2018-01-22 13:57:42 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_docker.yml has been loaded
    [ INFO 2018-01-22 13:57:42 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_remote_execution.yml has been loaded
    [ INFO 2018-01-22 13:57:42 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_tasks.yml has been loaded
    [ INFO 2018-01-22 13:57:42 Init] Configuration from the file /etc/hammer/cli.modules.d/import.yml has been loaded
    [ INFO 2018-01-22 13:57:42 Init] Configuration from the file /etc/hammer/cli.modules.d/katello.yml has been loaded
    [ INFO 2018-01-22 13:57:42 Init] Configuration from the file /root/.hammer/cli_config.yml has been loaded
    [DEBUG 2018-01-22 13:57:42 Connection] Registered: foreman
    [DEBUG 2018-01-22 13:57:42 API] Global headers: {
            :content_type => "application/json",
                  :accept => "application/json;version=2",
        "Accept-Language" => "en"
    }
    [DEBUG 2018-01-22 13:57:42 API] Follow redirects: never
    [ INFO 2018-01-22 13:57:43 Modules] Extension module hammer_cli_foreman (0.5.1.10) loaded
    [ INFO 2018-01-22 13:57:43 Modules] Extension module hammer_cli_foreman_admin (0.0.5) loaded
    [ INFO 2018-01-22 13:57:43 Modules] Extension module hammer_cli_foreman_bootdisk (0.1.3.3) loaded
    [ INFO 2018-01-22 13:57:43 Modules] Extension module hammer_cli_foreman_discovery (0.0.2.3) loaded
    [ INFO 2018-01-22 13:57:43 Modules] Extension module hammer_cli_import (0.11.2) loaded
    [ INFO 2018-01-22 13:57:43 HammerCLI::MainCommand] subcommand organization (HammerCLIForeman::Organization) was removed.
    [ INFO 2018-01-22 13:57:43 HammerCLI::MainCommand] subcommand organization (HammerCLIKatello::Organization) was created.
    [ INFO 2018-01-22 13:57:44 Modules] Extension module hammer_cli_katello (0.0.22.29) loaded
    [DEBUG 2018-01-22 13:57:44 Init] Using locale 'en'
    [DEBUG 2018-01-22 13:57:44 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/locale'
    [DEBUG 2018-01-22 13:57:44 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/locale'
    [DEBUG 2018-01-22 13:57:44 Init] 'mo' files for locale domain 'hammer-cli-csv' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_csv-2.2.1.1/locale'
    [DEBUG 2018-01-22 13:57:44 Init] 'mo' files for locale domain 'hammer_cli_foreman_docker' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman_docker-0.0.6/locale'
    [DEBUG 2018-01-22 13:57:44 Init] 'mo' files for locale domain 'hammer-cli-katello' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_katello-0.0.22.29/locale'
    [ INFO 2018-01-22 13:57:44 HammerCLI::MainCommand] Called with options: {"option_debug"=>true}
    [ INFO 2018-01-22 13:57:44 HammerCLIKatello::HostCollection] Called with options: {}
    [ INFO 2018-01-22 13:57:44 HammerCLIKatello::HostCollection::ListCommand] Called with options: {"option_organization_name"=>"MyOrg"}
    [ INFO 2018-01-22 13:57:44 API] Server: https://satellite.example.com/
    [ INFO 2018-01-22 13:57:44 API] GET /katello/api/organizations
    [DEBUG 2018-01-22 13:57:44 API] Params: {
        :search => "name = \"MyOrg\""
    }
    [DEBUG 2018-01-22 13:57:44 API] Headers: {
        :params => {
            :search => "name = \"MyOrg\""
        }
    }
    [ERROR 2018-01-22 13:57:44 Exception] Error: undefined method `closed?' for nil:NilClass
    Error: undefined method `closed?' for nil:NilClass
    [ERROR 2018-01-22 13:57:44 Exception]
    
    NoMethodError (undefined method `closed?' for nil:NilClass):
        /opt/rh/rh-ruby22/root/usr/share/ruby/net/http/response.rb:329:in `stream_check'
        /opt/rh/rh-ruby22/root/usr/share/ruby/net/http/response.rb:199:in `read_body'
        /opt/rh/rh-ruby22/root/usr/share/ruby/net/http/response.rb:226:in `body'
        /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:375:in `process_data'
        /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:229:in `rescue in http_call'
        /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:220:in `http_call'
        /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:174:in `call_action'
        /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/api.rb:169:in `call'
        /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.0.16/lib/apipie_bindings/resource.rb:14:in `call'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/id_resolver.rb:186:in `resolved_call'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/id_resolver.rb:172:in `find_resource_raw'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/id_resolver.rb:166:in `find_resource'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/id_resolver.rb:143:in `get_id'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/id_resolver.rb:133:in `block (2 levels) in define_id_finders'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:154:in `get_resource_id'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:223:in `block in customized_options'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:220:in `each'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:220:in `customized_options'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:244:in `request_params'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/apipie/command.rb:43:in `send_request'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:190:in `send_request'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:280:in `send_request'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:315:in `retrieve_all'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.10/lib/hammer_cli_foreman/commands.rb:299:in `execute'
        /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
        /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
        /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
        /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
        /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/abstract.rb:24:in `run'
        /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run'
        /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/bin/hammer:125:in `'
        /bin/hammer:23:in `load'
    

Environment

  • Satellite 6.2.13
  • Satellite 6.2.14

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content