Project

General

Profile

Actions

Bug #23787

closed

Hammer Overriden Smart Variable Formatting Issues

Added by Eric Hansen almost 6 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Smart variables
Target version:
-
Difficulty:
Triaged:
No
Team Backlog:
Fixed in Releases:
Found in Releases:
In Kanboard:

Description

Modify a smart variable like so,
hammer sc-param add-override-value --match fqdn=atm-centos75-orcl12c.automation.local --puppet-class-id 59 --smart-class-parameter-id 944 --value 12.1.0.2

Get an error, like so... no way around it that I see. The variable is a "string" with validation to be one of the values listed. I manually see this JSON format in the GUI as well, so no way I can turn off the validation to get this to work.

Could not create the override value:
Validation failed: Value ["12.1.0.2"] is not one of 12.2.0.1, 12.1.0.2, 11.2.0.1


Files

Capture.JPG View Capture.JPG 36.2 KB Eric Hansen, 06/04/2018 11:14 PM
Actions #1

Updated by Martin Bacovsky almost 6 years ago

  • Status changed from New to Need more information

Eric, could you please provide smart class parameter settings:
hammer sc-param info --id 944
and output of the failing command wit debug mode turned on:
hammer --debug sc-param add-override-value --match fqdn=atm-centos75-orcl12c.automation.local --puppet-class-id 59 --smart-class-parameter-id 944 --value 12.1.0.2

Actions #2

Updated by Eric Hansen almost 6 years ago

I left the ruby warnings, just in case they were somehow important. My understanding is that they are cosmetic.

[root@eh-katello ~]# hammer sc-param info --id 944
/opt/theforeman/tfm/root/usr/share/gems/gems/logging-1.8.2/lib/logging/appender.rb:139: warning: constant ::Fixnum is deprecated
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
Id: 944
Parameter: oracle_version
Default Value: 12.2.0.1
Override: true
Puppet class: oraclebox
Description: Version of Oracle to Install (12.2.0.1, 12.1.0.2, or 11.2.0.1 are currently valid)
Type: string
Hidden Value?: false
Use puppet default: no
Required: false
Validator:
Type:
Rule: 12.2.0.1, 12.1.0.2, 11.2.0.1
Override values:
Merge overrides: no
Merge default value: no
Avoid duplicates: no
Order:
fqdn
hostgroup
os
domain
Values:
1) Id: 9
Match: fqdn=atm-centos75-orcl11g.automation.local
Value: 11.2.0.1
Use puppet default: no
2) Id: 16
Match: fqdn=eh-centos74-ora12201-prod129.qa.catalogic.us
Value: ["12.1.0.2"]
Use puppet default: no
3) Id: 17
Match: fqdn=atm-oel75-orcl12c.automation.local
Value: 12.1.0.2
Use puppet default: no
Environments:
QA_Oracle
Created at: 2018/05/22 01:39:41
Updated at: 2018/06/01 19:56:57


[root@eh-katello ~]# hammer --debug sc-param add-override-value --match fqdn=atm-centos75-orcl12c.automation.local --puppet-class-id 59 --smart-class-parameter-id 944 --value 12.1.0.2
/opt/theforeman/tfm/root/usr/share/gems/gems/logging-1.8.2/lib/logging/appender.rb:139: warning: constant ::Fixnum is deprecated
[ INFO 2018-06-04 18:48:18 Init] Initialization of Hammer CLI (0.12.0) has started...
[DEBUG 2018-06-04 18:48:18 Init] Running at ruby 2.4.3-p205
[ INFO 2018-06-04 18:48:18 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2018-06-04 18:48:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2018-06-04 18:48:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_bootdisk.yml has been loaded
[ INFO 2018-06-04 18:48:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_docker.yml has been loaded
[ INFO 2018-06-04 18:48:18 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_tasks.yml has been loaded
[ INFO 2018-06-04 18:48:18 Init] Configuration from the file /etc/hammer/cli.modules.d/katello.yml has been loaded
[ INFO 2018-06-04 18:48:18 Init] Configuration from the file /root/.hammer/cli.modules.d/foreman.yml has been loaded
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
[DEBUG 2018-06-04 18:48:19 SSLoptions] SSL options: {
:ssl_ca_file => "/etc/pki/katello/certs/katello-server-ca.crt",
:verify_ssl => true
}
[DEBUG 2018-06-04 18:48:19 API] Global headers: {
:content_type => "application/json",
:accept => "application/json;version=2",
"Accept-Language" => "en"
}
[DEBUG 2018-06-04 18:48:19 API] Follow redirects: never
[DEBUG 2018-06-04 18:48:19 Connection] Registered: foreman
[ INFO 2018-06-04 18:48:19 Modules] Extension module hammer_cli_foreman (0.12.0) loaded.
[ INFO 2018-06-04 18:48:19 Modules] Extension module hammer_cli_foreman_bootdisk (0.1.3) loaded.
[ INFO 2018-06-04 18:48:19 HammerCLI::MainCommand] subcommand organization (HammerCLIForeman::Organization) was removed.
[ INFO 2018-06-04 18:48:19 HammerCLI::MainCommand] subcommand organization (HammerCLIKatello::Organization) was created.
[ INFO 2018-06-04 18:48:20 Modules] Extension module hammer_cli_katello (0.12.1) loaded.
[DEBUG 2018-06-04 18:48:20 Init] Using locale 'en'
[DEBUG 2018-06-04 18:48:20 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.0/locale'
[DEBUG 2018-06-04 18:48:20 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.12.0/locale'
[DEBUG 2018-06-04 18:48:20 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.4/locale'
[DEBUG 2018-06-04 18:48:20 Init] 'mo' files for locale domain 'hammer-cli-katello' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_katello-0.12.1/locale'
[ INFO 2018-06-04 18:48:20 HammerCLI::MainCommand] Called with options: {"option_debug"=>true}
[ INFO 2018-06-04 18:48:20 HammerCLIForeman::SmartClassParameter] Called with options: {}
add-override-value command is deprecated and will be removed in one of the future versions. Please use add-matcher command instead.
[ INFO 2018-06-04 18:48:20 HammerCLIForeman::SmartClassParameter::AddMatcherCommand] Called with options: {"option_smart_class_parameter_id"=>944, "option_match"=>"fqdn=atm-centos75-orcl12c.automation.local", "option_value"=>["12.1.0.2"], "option_puppetclass_id"=>59}
[ INFO 2018-06-04 18:48:20 API] Server: https://eh-katello.qa.catalogic.us
[ INFO 2018-06-04 18:48:20 API] POST /api/smart_class_parameters/944/override_values
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
[DEBUG 2018-06-04 18:48:20 API] Params: {
"override_value" => {
"match" => "fqdn=atm-centos75-orcl12c.automation.local",
"value" => [
[0] "12.1.0.2"
]
}
}
[DEBUG 2018-06-04 18:48:20 API] Headers: {}
[DEBUG 2018-06-04 18:48:20 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[ERROR 2018-06-04 18:48:20 API] 500 Internal Server Error
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
[DEBUG 2018-06-04 18:48:20 API] {
"error" => {
"message" => "Validation failed: Match fqdn=atm-centos75-orcl12c.automation.local does not match an existing host"
}
}
[DEBUG 2018-06-04 18:48:20 Exception] Using exception handler HammerCLIForeman::ExceptionHandler#handle_internal_error
[ERROR 2018-06-04 18:48:20 Exception] Validation failed: Match fqdn=atm-centos75-orcl12c.automation.local does not match an existing host
Could not create the override value:
Validation failed: Match fqdn=atm-centos75-orcl12c.automation.local does not match an existing host
[ERROR 2018-06-04 18:48:20 Exception]

RestClient::InternalServerError (500 Internal Server Error):
/opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/abstract_response.rb:223:in `exception_with_response'
/opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/abstract_response.rb:103:in `return!'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:353:in `block in rest_client_call_block'
/opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/request.rb:807:in `process_result'
/opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/request.rb:725:in `block in transmit'
/opt/rh/rh-ruby24/root/usr/share/ruby/net/http.rb:877:in `start'
/opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/request.rb:715:in `transmit'
/opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/request.rb:145:in `execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/request.rb:52:in `execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-2.0.1/lib/restclient/resource.rb:67:in `post'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:327:in `call_client'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:240:in `http_call'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:190:in `call_action'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/api.rb:185:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.2.2/lib/apipie_bindings/resource.rb:21:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.0/lib/hammer_cli/apipie/command.rb:43:in `send_request'
/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.12.0/lib/hammer_cli_foreman/commands.rb:168:in `send_request'
/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.0/lib/hammer_cli/apipie/command.rb:34: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.12.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.12.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.12.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.12.0/bin/hammer:142:in `<top (required)>'
/usr/bin/hammer:22:in `load'
/usr/bin/hammer:22:in `<main>'

Actions #3

Updated by Eric Hansen almost 6 years ago

It looks like you aren't getting what you want because I had removed the host. I recreated the host so that it would match and then reproduced the original problem.

[root@eh-katello ~]# hammer --debug sc-param add-override-value --match fqdn=atm-centos75-orcl12c.automation.local --puppet-class-id 59 --smart-class-parameter-id 944 --value 12.2.0.1
/opt/theforeman/tfm/root/usr/share/gems/gems/logging-1.8.2/lib/logging/appender.rb:139: warning: constant ::Fixnum is deprecated
[ INFO 2018-06-04 19:07:56 Init] Initialization of Hammer CLI (0.12.0) has started...
[DEBUG 2018-06-04 19:07:56 Init] Running at ruby 2.4.3-p205
[ INFO 2018-06-04 19:07:56 Init] Configuration from the file /etc/hammer/cli_config.yml has been loaded
[ INFO 2018-06-04 19:07:56 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman.yml has been loaded
[ INFO 2018-06-04 19:07:56 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_bootdisk.yml has been loaded
[ INFO 2018-06-04 19:07:56 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_docker.yml has been loaded
[ INFO 2018-06-04 19:07:56 Init] Configuration from the file /etc/hammer/cli.modules.d/foreman_tasks.yml has been loaded
[ INFO 2018-06-04 19:07:56 Init] Configuration from the file /etc/hammer/cli.modules.d/katello.yml has been loaded
[ INFO 2018-06-04 19:07:56 Init] Configuration from the file /root/.hammer/cli.modules.d/foreman.yml has been loaded
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
[DEBUG 2018-06-04 19:07:57 SSLoptions] SSL options: {
:ssl_ca_file => "/etc/pki/katello/certs/katello-server-ca.crt",
:verify_ssl => true
}
[DEBUG 2018-06-04 19:07:57 API] Global headers: {
:content_type => "application/json",
:accept => "application/json;version=2",
"Accept-Language" => "en"
}
[DEBUG 2018-06-04 19:07:57 API] Follow redirects: never
[DEBUG 2018-06-04 19:07:57 Connection] Registered: foreman
[ INFO 2018-06-04 19:07:57 Modules] Extension module hammer_cli_foreman (0.12.0) loaded.
[ INFO 2018-06-04 19:07:57 Modules] Extension module hammer_cli_foreman_bootdisk (0.1.3) loaded.
[ INFO 2018-06-04 19:07:57 HammerCLI::MainCommand] subcommand organization (HammerCLIForeman::Organization) was removed.
[ INFO 2018-06-04 19:07:57 HammerCLI::MainCommand] subcommand organization (HammerCLIKatello::Organization) was created.
[ INFO 2018-06-04 19:07:58 Modules] Extension module hammer_cli_katello (0.12.1) loaded.
[DEBUG 2018-06-04 19:07:58 Init] Using locale 'en'
[DEBUG 2018-06-04 19:07:58 Init] 'mo' files for locale domain 'hammer-cli' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.12.0/locale'
[DEBUG 2018-06-04 19:07:58 Init] 'mo' files for locale domain 'hammer-cli-foreman' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.12.0/locale'
[DEBUG 2018-06-04 19:07:58 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.4/locale'
[DEBUG 2018-06-04 19:07:58 Init] 'mo' files for locale domain 'hammer-cli-katello' loaded from '/opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_katello-0.12.1/locale'
[ INFO 2018-06-04 19:07:58 HammerCLI::MainCommand] Called with options: {"option_debug"=>true}
[ INFO 2018-06-04 19:07:58 HammerCLIForeman::SmartClassParameter] Called with options: {}
add-override-value command is deprecated and will be removed in one of the future versions. Please use add-matcher command instead.
[ INFO 2018-06-04 19:07:58 HammerCLIForeman::SmartClassParameter::AddMatcherCommand] Called with options: {"option_smart_class_parameter_id"=>944, "option_match"=>"fqdn=atm-centos75-orcl12c.automation.local", "option_value"=>["12.2.0.1"], "option_puppetclass_id"=>59}
[ INFO 2018-06-04 19:07:58 API] Server: https://eh-katello.qa.catalogic.us
[ INFO 2018-06-04 19:07:58 API] POST /api/smart_class_parameters/944/override_values
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
[DEBUG 2018-06-04 19:07:58 API] Params: {
"override_value" => {
"match" => "fqdn=atm-centos75-orcl12c.automation.local",
"value" => [
[0] "12.2.0.1"
]
}
}
[DEBUG 2018-06-04 19:07:58 API] Headers: {}
[DEBUG 2018-06-04 19:07:58 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
/opt/theforeman/tfm/root/usr/share/gems/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
[DEBUG 2018-06-04 19:07:58 API] Response: {
"created_at" => "2018-06-04 23:07:58 UTC",
"updated_at" => "2018-06-04 23:07:58 UTC",
"id" => 20,
"match" => "fqdn=atm-centos75-orcl12c.automation.local",
"value" => "[\"12.2.0.1\"]",
"omit" => false,
"use_puppet_default" => false
}
[DEBUG 2018-06-04 19:07:58 API] Response headers: {
:date => "Mon, 04 Jun 2018 23:07:58 GMT",
:server => "Apache/2.4.6 (CentOS)",
:foreman_version => "1.17.0",
:foreman_api_version => "2",
:apipie_checksum => "b1547892a54270a0d4a7679f8a3dc5a4",
:cache_control => "max-age=0, private, must-revalidate",
:x_request_id => "08373fe0-3cda-438d-a53f-d89d113f095a",
:x_runtime => "0.340505",
:content_security_policy => "default-src 'self'; child-src 'self'; connect-src 'self' ws: wss:; img-src 'self' data: *.gravatar.com; script-src 'unsafe-eval' 'unsafe-inline' 'self'; style-src 'unsafe-inline' 'self'",
:strict_transport_security => "max-age=631139040; includeSubdomains",
: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] "request_method=POST; path=/",
[1] "_session_id=f171b12aab652517f841b68f9a11ce85; path=/; secure; HttpOnly"
],
:etag => "W/\"79cebd34bd97f0f28ec43d04c19467cb\"",
:status => "201 Created",
:transfer_encoding => "chunked",
:content_type => "application/json; charset=utf-8"
}
Override value created.
[root@eh-katello ~]#

Actions #4

Updated by Eric Hansen almost 6 years ago

So, you can see it is inserting these brackets and quotes when I didn't specify that they be inserted. The data type is a string in the UI. You can see the differences with the brackets (incorrect... me reproducing the problem) and without in the enclosed screenshot Capture.jpg

Below is from the debug output,
[DEBUG 2018-06-04 19:07:58 API] Response: {
"created_at" => "2018-06-04 23:07:58 UTC",
"updated_at" => "2018-06-04 23:07:58 UTC",
"id" => 20,
"match" => "fqdn=atm-centos75-orcl12c.automation.local",
"value" => "[\"12.2.0.1\"]",
"omit" => false,
"use_puppet_default" => false
}

Actions #5

Updated by Martin Bacovsky almost 6 years ago

  • Status changed from Need more information to New

Eric, thanks for the data provided. Fix for the issue will be included in hammer-cli-foreman 0.13.0 which should land in Foreman 1.18. While it was not released yet you could try to update your hammer with build from nightlies. It fixed the issue for me.

yum install http://koji.katello.org/kojifiles/packages/tfm-rubygem-hammer_cli_foreman/0.13.pre.develop/1.201804131135git0d5ab8c.el7/noarch/tfm-rubygem-hammer_cli_foreman-0.13.pre.develop-1.201804131135git0d5ab8c.el7.noarch.rpm
Actions #6

Updated by Ondřej Pražák about 4 years ago

  • Status changed from New to Closed

No longer reproducible and according to the previous comment, this was fixed in foreman 1.18. Feel free to reopen if the issue persists or if I misunderstood.

Actions

Also available in: Atom PDF