Project

General

Profile

Actions

Bug #25167

closed

Hammer error: Error: undefined method `collect’ for

Added by Michael Spindelboeck over 5 years ago. Updated over 5 years ago.

Status:
Resolved
Priority:
Normal
Category:
Foreman commands (obsolete)
Target version:
-
Difficulty:
Triaged:
No
Team Backlog:
Fixed in Releases:
Found in Releases:
In Kanboard:

Description

Problem:
After upgrading to 1.19 I can’t query facts via hammer. I’m running into following error:

[ ~]$ hammer host facts --name=otd2001.xeop.de
Error: undefined method `collect’ for " Matrox Electronics Systems Ltd. MGA G200EH":String

Expected outcome:
Foreman 1.18:
[ ~]$ hammer host facts --name=aesdmp02.dbag.prod
----------------------------|---------------------------------------------------------------------------------
FACT | VALUE
----------------------------|---------------------------------------------------------------------------------
graphiccard | Cirrus Logic GD 5446
lvm_pv_0 | /dev/sda2
lvm_vg_vglocal_pvs | /dev/sda2
root_home | /root
path | /sbin:/bin:/usr/sbin:/usr/bin
rubysitedir | /usr/lib/ruby/site_ruby/1.8
puppet_vardir | /var/lib/puppet
bios_version | 0.5.1
bios_release_date | 01/01/2007
augeasprovider_grub_version | 1
no_nvidia_legacy_driver | 1
lvm_pvs | 1
lvm_vgs | 1
augeasversion | 1.0.0
network_eth0_version | 1.3

Foreman and Proxy versions:
Foreman Version 1.19

[ ~]$ rpm -qa | grep foreman | sort
foreman-1.19.0-1.el7.noarch
foreman-cli-1.19.0-1.el7.noarch
foreman-compute-1.19.0-1.el7.noarch
foreman-console-1.19.0-1.el7.noarch
foreman-debug-1.19.0-1.el7.noarch
foreman-libvirt-1.19.0-1.el7.noarch
foreman-mysql2-1.19.0-1.el7.noarch
foreman-ovirt-1.19.0-1.el7.noarch
foreman-proxy-1.19.0-1.el7.noarch
foreman-release-scl-7-1.el7.noarch
tfm-rubygem-foreman_bootdisk-12.0.0-2.fm1_18.el7.noarch
tfm-rubygem-foreman_bootdisk-doc-12.0.0-2.fm1_18.el7.noarch
tfm-rubygem-foreman_discovery-13.0.1-1.fm1_19.el7.noarch
tfm-rubygem-foreman_discovery-doc-13.0.1-1.fm1_19.el7.noarch
tfm-rubygem-foreman_expire_hosts-5.1.0-3.fm1_18.el7.noarch
tfm-rubygem-foreman_openscap-0.10.2-1.fm1_19.el7.noarch
tfm-rubygem-foreman-tasks-0.13.4-1.fm1_19.el7.noarch
tfm-rubygem-foreman-tasks-core-0.2.5-1.fm1_18.el7.noarch
tfm-rubygem-hammer_cli_foreman-0.14.0-1.el7.noarch
tfm-rubygem-hammer_cli_foreman_discovery-1.0.0-2.el7.noarch

RHEL 7.5 (latest patch)

I have to cut out the fact data. But the result block was valid.
[ ~]$ hammer -d host facts --name=otd2001.xeop.de | tee /tmp/out
[ INFO 2018-09-26T08:24:12 Init] Initialization of Hammer CLI (0.14.0) has started...
[DEBUG 2018-09-26T08:24:12 Init] Running at ruby 2.4.3-p205
[ INFO 2018-09-26T08:24:12 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2018-09-26T08:24:12 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2018-09-26T08:24:12 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_discovery.yml has been loaded
[DEBUG 2018-09-26T08:24:12 SSLoptions] SSL options: {
:verify_ssl => true
}
[DEBUG 2018-09-26T08:24:12 API] Global headers: {
:content_type => "application/json",
:accept => "application/json;version=2",
"Accept-Language" => "en"
}
[DEBUG 2018-09-26T08:24:12 API] Follow redirects: never
[DEBUG 2018-09-26T08:24:12 Connection] Registered: foreman
[ INFO 2018-09-26T08:24:12 Modules] Extension module hammer_cli_foreman (0.14.0) loaded.
[ INFO 2018-09-26T08:24:12 Modules] Extension module hammer_cli_foreman_discovery (1.0.0) loaded.
[DEBUG 2018-09-26T08:24:12 Init] Using locale 'en'
[DEBUG 2018-09-26T08:24:12 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.14.0/locale'
[DEBUG 2018-09-26T08:24:12 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.14.0/locale'
[ INFO 2018-09-26T08:24:12 HammerCLI::MainCommand] Called with options: {"option_debug"=>true}
[ INFO 2018-09-26T08:24:12 HammerCLIForeman::Host] Called with options: {}
[ INFO 2018-09-26T08:24:12 HammerCLIForeman::Host::FactsCommand] Called with options: {"option_name"=>"otd2001.xeop.de"}
[ INFO 2018-09-26T08:24:12 API] Server:
[ INFO 2018-09-26T08:24:12 API] GET /api/hosts
[DEBUG 2018-09-26T08:24:12 API] Params: {
:search => "name = \"otd2001.xeop.de\""
}
[DEBUG 2018-09-26T08:24:12 API] Headers: {
:params => {
:search => "name = \"otd2001.xeop.de\""
}
}
[DEBUG 2018-09-26T08:24:12 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[DEBUG 2018-09-26T08:24:13 API] Response: {
cut out
}
[DEBUG 2018-09-26T08:24:13 API] Response headers: {
:date => "Wed, 26 Sep 2018 06:24:12 GMT",
:server => "Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips Phusion_Passenger/4.0.53",
:foreman_version => "1.19.0",
:foreman_api_version => "2",
:apipie_checksum => "12fcabf6af18999fcfe3f898a15eeac78b497b0a",
:cache_control => "max-age=0, private, must-revalidate",
:x_request_id => "d1c69ea8-47b0-44bb-88e1-788a13207a45",
:x_runtime => "0.082321",
:content_security_policy => "default-src https: data: 'unsafe-inline' 'unsafe-eval'",
:strict_transport_security => "max-age=31536000;",
:x_content_type_options => "nosniff",
:x_download_options => "noopen",
:x_frame_options => "SAMEORIGIN",
:x_permitted_cross_domain_policies => "none",
:x_xss_protection => "1; mode=block",
:x_powered_by => "Phusion Passenger 4.0.53",
:set_cookie => [
[0] "_session_id=6b36edc11b5dfea8e258c8439ef63d82; path=/; secure; HttpOnly; SameSite=Lax"
],
:etag => "W/\"2a219407fbd49e8e58c164c75d6a1de2\"",
:status => "200 OK",
:transfer_encoding => "chunked",
:content_type => "application/json; charset=utf-8"
}
[ INFO 2018-09-26T08:24:13 API] Server: https://puppet.xeop.de/
[ INFO 2018-09-26T08:24:13 API] GET /api/hosts/6562/facts
[DEBUG 2018-09-26T08:24:13 API] Params: {
"page" => 1,
"per_page" => 1000
}
[DEBUG 2018-09-26T08:24:13 API] Headers: {
:params => {
"page" => 1,
"per_page" => 1000
}
}
[DEBUG 2018-09-26T08:24:13 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[DEBUG 2018-09-26T08:24:13 API] Response: {
"total" => 195,
"subtotal" => 195,
"page" => 1,
"per_page" => 1000,
"search" => " host = 6562",
"sort" => {
"by" => nil,
"order" => nil
},
"results" => {
"otd2001.xeop.de" => {
"graphiccard" => " Matrox Electronics Systems Ltd. MGA G200EH",
cut out
}
}
[DEBUG 2018-09-26T08:24:13 API] Response headers: {
:date => "Wed, 26 Sep 2018 06:24:13 GMT",
:server => "Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips Phusion_Passenger/4.0.53",
:foreman_version => "1.19.0",
:foreman_api_version => "2",
:apipie_checksum => "12fcabf6af18999fcfe3f898a15eeac78b497b0a",
:cache_control => "max-age=0, private, must-revalidate",
:x_request_id => "8f2bb22f-3c97-4925-93a4-c021bc4203d6",
:x_runtime => "0.090562",
:content_security_policy => "default-src https: data: 'unsafe-inline' 'unsafe-eval'",
:strict_transport_security => "max-age=31536000;",
:x_content_type_options => "nosniff",
:x_download_options => "noopen",
:x_frame_options => "SAMEORIGIN",
:x_permitted_cross_domain_policies => "none",
:x_xss_protection => "1; mode=block",
:x_powered_by => "Phusion Passenger 4.0.53",
:set_cookie => [
[0] "_session_id=7a4c78c7ce979646aba94b239c25f2ec; path=/; secure; HttpOnly; SameSite=Lax"
],
:etag => "W/\"171a3e6cb7ea95a9650b18492d150c62\"",
:status => "200 OK",
:transfer_encoding => "chunked",
:content_type => "application/json; charset=utf-8"
}
[DEBUG 2018-09-26T08:24:13 Exception] Using exception handler HammerCLIForeman::ExceptionHandler#handle_general_exception
[ERROR 2018-09-26T08:24:13 Exception] Error: undefined method `collect' for " Matrox Electronics Systems Ltd. MGA G200EH":String
Error: undefined method `collect' for " Matrox Electronics Systems Ltd. MGA G200EH":String
[ERROR 2018-09-26T08:24:13 Exception]

NoMethodError (undefined method `collect' for " Matrox Electronics Systems Ltd. MGA G200EH":String):
/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.14.0/lib/hammer_cli_foreman/fact.rb:23:in `block in unhash_facts'
/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.14.0/lib/hammer_cli_foreman/fact.rb:22:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.14.0/lib/hammer_cli_foreman/fact.rb:22:in `inject'
/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.14.0/lib/hammer_cli_foreman/fact.rb:22:in `unhash_facts'
/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.14.0/lib/hammer_cli_foreman/host.rb:193:in `send_request'
/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.14.0/lib/hammer_cli_foreman/commands.rb:259:in `retrieve_all'
/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.14.0/lib/hammer_cli_foreman/commands.rb:243:in `execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.14.0/lib/hammer_cli/abstract.rb:29:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.14.0/lib/hammer_cli/abstract.rb:29:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.14.0/lib/hammer_cli/abstract.rb:29:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:132:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.14.0/bin/hammer:143:in `<top (required)>'
/usr/bin/hammer:23:in `load'
/usr/bin/hammer:23:in `<main>'


Related issues 2 (0 open2 closed)

Related to Foreman - Bug #20891: API hosts/X/facts inconsistent and superfluous hostname hash in results responseClosedShira Maximov09/11/2017Actions
Related to Foreman - Bug #25188: API hosts/X/facts still inconsistentClosedMartin BacovskyActions
Actions

Also available in: Atom PDF