Set OS default template

Hello !

I can't set my os default templates using hammer cli 0.1.1 :

hammer -u admin -p changeme --version
hammer (0.1.1)

  • hammer_cli_foreman (0.1.1)

hammer -u admin -p changeme --show-ids os info --id 1
Id: 1
Full name: CentOS 6.5
Release name:
Family: Redhat
Name: CentOS
Major version: 6
Minor version: 5
Partition tables:
Redhat_6_Disk30Go_Default5Go (id: 13)
Redhat_6_Disk50Go_Opt20Go (id: 14)
Redhat_6_Disk50Go_Var20Go (id: 15)
Default templates:
Architectures:
i386 (id: 2)
x86_64 (id: 1)
Installation media:
CentOS mirror (id: 7)
Templates:
Redhat default Kickstart (provision, id: 48)
Redhat default PXELinux (PXELinux, id: 42)
Redhat default finish (finish, id: 45)
Parameters:

hammer -u admin -p changeme os set-default-template --config-template-id 48
–id 1
Could not set the os default template:
Error: Received data of unknown format

What am i doing wrong ?

Hello,
can you please provide full debug log of the set-default-template
command (hammer -d …)?
There's a chance that you're using some older version of foreman that
latest hammer is incompatible with.

Regards
Tomas

··· On 06/13/2014 03:19 PM, Alexandre Barth wrote: > Hello ! > I can't set my os default templates using hammer cli 0.1.1 : > hammer -u admin -p changeme --version > hammer (0.1.1) > * hammer_cli_foreman (0.1.1) > hammer -u admin -p changeme --show-ids os info --id 1 > Id: 1 > Full name: CentOS 6.5 > Release name: > Family: Redhat > Name: CentOS > Major version: 6 > Minor version: 5 > Partition tables: > Redhat_6_Disk30Go_Default5Go (id: 13) > Redhat_6_Disk50Go_Opt20Go (id: 14) > Redhat_6_Disk50Go_Var20Go (id: 15) > Default templates: > Architectures: > i386 (id: 2) > x86_64 (id: 1) > Installation media: > CentOS mirror (id: 7) > Templates: > Redhat default Kickstart (provision, id: 48) > Redhat default PXELinux (PXELinux, id: 42) > Redhat default finish (finish, id: 45) > Parameters: > hammer -u admin -p changeme os set-default-template --config-template-id > 48 --id 1 > Could not set the os default template: > Error: Received data of unknown format > What am i doing wrong ? >

I've upgraded Foreman to version 1.5.1 and still have the error.

··· Le vendredi 13 juin 2014 15:19:03 UTC+2, Alexandre Barth a écrit : > > Hello ! > > I can't set my os default templates using hammer cli 0.1.1 : > > hammer -u admin -p changeme --version > hammer (0.1.1) > * hammer_cli_foreman (0.1.1) > > hammer -u admin -p changeme --show-ids os info --id 1 > Id: 1 > Full name: CentOS 6.5 > Release name: > Family: Redhat > Name: CentOS > Major version: 6 > Minor version: 5 > Partition tables: > Redhat_6_Disk30Go_Default5Go (id: 13) > Redhat_6_Disk50Go_Opt20Go (id: 14) > Redhat_6_Disk50Go_Var20Go (id: 15) > Default templates: > Architectures: > i386 (id: 2) > x86_64 (id: 1) > Installation media: > CentOS mirror (id: 7) > Templates: > Redhat default Kickstart (provision, id: 48) > Redhat default PXELinux (PXELinux, id: 42) > Redhat default finish (finish, id: 45) > Parameters: > > hammer -u admin -p changeme os set-default-template --config-template-id > 48 --id 1 > Could not set the os default template: > Error: Received data of unknown format > > What am i doing wrong ? >

hammer -u admin -p changeme -d os set-default-template
–config-template-id 44 --id 1
[ INFO 2014-06-16 14:09:45 Init] Initialization of Hammer CLI (0.1.1) has
started…
[DEBUG 2014-06-16 14:09:45 Init] Running at ruby 1.8.7-p352
[ INFO 2014-06-16 14:09:45 Init] Configuration from the file
/etc/hammer/cli_config.yml has been loaded
[ INFO 2014-06-16 14:09:45 Init] Configuration from the file
/etc/hammer/cli.modules.d/foreman.yml has been loaded
[DEBUG 2014-06-16 14:09:45 Connection] Registered: foreman
[DEBUG 2014-06-16 14:09:45 API] Global headers: {
:content_type => "application/json",
:accept => "application/json;version=2",
"Accept-Language" => "en"
}
[ INFO 2014-06-16 14:09:45 API] GET /apidoc/apipie_checksum
[DEBUG 2014-06-16 14:09:45 API] Params: {}
[DEBUG 2014-06-16 14:09:45 API] Headers: {
:accept => "application/json",
:params => {}
}
[DEBUG 2014-06-16 14:09:45 API] Response {
"checksum" => "539427be20f794ea247db15b46a9091c"
}
[ INFO 2014-06-16 14:09:46 Modules] Extension module hammer_cli_foreman
(0.1.1) loaded
[DEBUG 2014-06-16 14:09:46 Init] Using locale 'en'
[DEBUG 2014-06-16 14:09:46 Init] 'mo' files for locale domain 'hammer-cli'
loaded from '/usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/locale'
[DEBUG 2014-06-16 14:09:46 Init] 'mo' files for locale domain
'hammer-cli-foreman' loaded from
'/usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.1/locale'
[ INFO 2014-06-16 14:09:46 HammerCLI::MainCommand] Called with options:
{"option_username"=>"admin", "option_password"=>"***", "option_debug"=>true}
[ INFO 2014-06-16 14:09:46 HammerCLIForeman::OperatingSystem] Called with
options: {}
[ INFO 2014-06-16 14:09:46
HammerCLIForeman::OperatingSystem::SetOsDefaultTemplate] Called with
options: {"option_id"=>"1", "option_config_template_id"=>"44"}
[ INFO 2014-06-16 14:09:46 API] GET /apidoc/apipie_checksum
[DEBUG 2014-06-16 14:09:46 API] Params: {}
[DEBUG 2014-06-16 14:09:46 API] Headers: {
:accept => "application/json",
:params => {}
}
[DEBUG 2014-06-16 14:09:46 API] Response {
"checksum" => "539427be20f794ea247db15b46a9091c"
}
[ INFO 2014-06-16 14:09:46 API] GET /api/config_templates/44
[DEBUG 2014-06-16 14:09:46 API] Params: {}
[DEBUG 2014-06-16 14:09:46 API] Headers: {
:params => {}
}
[DEBUG 2014-06-16 14:09:46 API] Response {
"template_kind_name" => "provision",
"template" => "<%#\nkind : provision\nname : Redhat
default Kickstart\noses :\n- CentOS 5\n- CentOS 6\n%>\nfoo",
"template_combinations" => [],
"audit_comment" => nil,
"id" => 44,
"operatingsystems" => [
[0] {
"id" => 1,
"fullname" => "CentOS 6.5",
"name" => "CentOS"
},
[1] {
"id" => 2,
"fullname" => "CentOS 5.10",
"name" => "CentOS"
}
],
"updated_at" => "2014-06-16T12:06:50Z",
"template_kind_id" => 4,
"os_default_templates" => [],
"created_at" => "2014-06-16T12:06:50Z",
"snippet" => false,
"name" => "Redhat default Kickstart"
}
[ INFO 2014-06-16 14:09:46 API] GET /apidoc/apipie_checksum
[DEBUG 2014-06-16 14:09:46 API] Params: {}
[DEBUG 2014-06-16 14:09:46 API] Headers: {
:accept => "application/json",
:params => {}
}
[DEBUG 2014-06-16 14:09:46 API] Response {
"checksum" => "539427be20f794ea247db15b46a9091c"
}
[ INFO 2014-06-16 14:09:46 API] GET
/api/operatingsystems/1/os_default_templates
[DEBUG 2014-06-16 14:09:46 API] Params: {}
[DEBUG 2014-06-16 14:09:46 API] Headers: {
:params => {}
}
[DEBUG 2014-06-16 14:09:46 API] Response #<String:0x7f4368cfa4b0
attr_accessor :args = {
:method => :get,
:headers => {
:content_type => "application/json",
:accept => "application/json;version=2",
"Accept-Language" => "en"
},
:timeout => nil,
:oauth => nil,
:url =>
"https://localhost//api/operatingsystems/1/os_default_templates",
:user => "admin",
:password => "changeme"
},
attr_accessor :net_http_res = #<Net::HTTPOK:0x7f4368d004c8
@body_exist = true,
@read = true,
@socket = nil,
attr_reader :body = …String…,
attr_reader :code = "200",
attr_reader :header = {
"apipie-checksum" => [
[0] "539427be20f794ea247db15b46a9091c"
],
"x-rack-cache" => [
[0] "miss"
],
"transfer-encoding" => [
[0] "chunked"
],
"x-runtime" => [
[0] "0.130100"
],
"x-request-id" => [
[0] "26c5f9ae2e58802d892fc8de9541a9cc"
],
"content-type" => [
[0] "application/json; charset=utf-8"
],
"x-powered-by" => [
[0] "Phusion Passenger 4.0.18"
],
"foreman_version" => [
[0] "1.5.0"
],
"cache-control" => [
[0] "must-revalidate, private, max-age=0"
],
"etag" => [
[0] "&quot;c592d730e00bf604c6a99fb07d05c8ca&quot;"
],
"foreman_api_version" => [
[0] "2"
],
"status" => [
[0] "200 OK"
],
"set-cookie" => [
[0] "_session_id=0b0f9293ebce3f551000e9b3e4606d05; path=/;
HttpOnly"
],
"server" => [
[0] "Apache/2.2.15 (CentOS)"
],
"date" => [
[0] "Mon, 16 Jun 2014 12:09:46 GMT"
],
"connection" => [
[0] "close"
],
"x-ua-compatible" => [
[0] "IE=Edge,chrome=1"
]
},
attr_reader :http_version = "1.1",
attr_reader :message = "OK"
>,
attr_reader :code = 200,
attr_reader :headers = {
:status => "200 OK",
:etag => "&quot;c592d730e00bf604c6a99fb07d05c8ca&quot;",
:content_type => "application/json; charset=utf-8",
:x_rack_cache => "miss",
:x_ua_compatible => "IE=Edge,chrome=1",
:set_cookie => [
[0] "_session_id=0b0f9293ebce3f551000e9b3e4606d05; path=/;
HttpOnly"
],
:server => "Apache/2.2.15 (CentOS)",
:x_request_id => "26c5f9ae2e58802d892fc8de9541a9cc",
:connection => "close",
:cache_control => "must-revalidate, private, max-age=0",
:date => "Mon, 16 Jun 2014 12:09:46 GMT",
:x_runtime => "0.130100",
:foreman_version => "1.5.0",
:transfer_encoding => "chunked",
:foreman_api_version => "2",
:x_powered_by => "Phusion Passenger 4.0.18",
:apipie_checksum => "539427be20f794ea247db15b46a9091c"
}
>
[ERROR 2014-06-16 14:09:46 Exception] Error: Received data of unknown format
Could not set the os default template:
Error: Received data of unknown format
[ERROR 2014-06-16 14:09:46 Exception]

RuntimeError (Received data of unknown format):

/usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/commands.rb:73:in
`collection_to_common_format'

/usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/operating_system.rb:158:in
`template_exist?'

/usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.1/lib/hammer_cli_foreman/operating_system.rb:187:in
execute&#39; /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:67:inrun'

/usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/./apipie/…/abstract.rb:22:in
`run'

/usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in
execute&#39; /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:67:inrun'

/usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/./apipie/…/abstract.rb:22:in
`run'

/usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in
execute&#39; /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:67:inrun'

/usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/./apipie/…/abstract.rb:22:in
run&#39; /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:125:inrun'
/usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/bin/hammer:100
/usr/bin/hammer:19:in `load'
/usr/bin/hammer:19

··· Le lundi 16 juin 2014 10:59:33 UTC+2, Tomas Strachota a écrit : > > On 06/13/2014 03:19 PM, Alexandre Barth wrote: > > Hello ! > > I can't set my os default templates using hammer cli 0.1.1 : > > hammer -u admin -p changeme --version > > hammer (0.1.1) > > * hammer_cli_foreman (0.1.1) > > hammer -u admin -p changeme --show-ids os info --id 1 > > Id: 1 > > Full name: CentOS 6.5 > > Release name: > > Family: Redhat > > Name: CentOS > > Major version: 6 > > Minor version: 5 > > Partition tables: > > Redhat_6_Disk30Go_Default5Go (id: 13) > > Redhat_6_Disk50Go_Opt20Go (id: 14) > > Redhat_6_Disk50Go_Var20Go (id: 15) > > Default templates: > > Architectures: > > i386 (id: 2) > > x86_64 (id: 1) > > Installation media: > > CentOS mirror (id: 7) > > Templates: > > Redhat default Kickstart (provision, id: 48) > > Redhat default PXELinux (PXELinux, id: 42) > > Redhat default finish (finish, id: 45) > > Parameters: > > hammer -u admin -p changeme os set-default-template --config-template-id > > 48 --id 1 > > Could not set the os default template: > > Error: Received data of unknown format > > What am i doing wrong ? > > > > Hello, > can you please provide full debug log of the set-default-template > command (hammer -d ...)? > There's a chance that you're using some older version of foreman that > latest hammer is incompatible with. > > Regards > Tomas > > > > >

> I've upgraded Foreman to version 1.5.1 and still have the error.

I've been trying to reproduce the problem but had no luck so far.
Would you mind sharing also the server logs with us?

T.

··· On 06/18/2014 03:23 PM, Alexandre Barth wrote:

Le vendredi 13 juin 2014 15:19:03 UTC+2, Alexandre Barth a écrit :

Hello !
I can't set my os default templates using hammer cli 0.1.1 :
hammer -u admin -p changeme --version
hammer (0.1.1)
  * hammer_cli_foreman (0.1.1)
hammer -u admin -p changeme --show-ids os info --id 1
Id:                 1
Full name:          CentOS 6.5
Release name:
Family:             Redhat
Name:               CentOS
Major version:      6
Minor version:      5
Partition tables:
     Redhat_6_Disk30Go_Default5Go (id: 13)
     Redhat_6_Disk50Go_Opt20Go (id: 14)
     Redhat_6_Disk50Go_Var20Go (id: 15)
Default templates:
Architectures:
     i386 (id: 2)
     x86_64 (id: 1)
Installation media:
     CentOS mirror (id: 7)
Templates:
     Redhat default Kickstart (provision, id: 48)
     Redhat default PXELinux (PXELinux, id: 42)
     Redhat default finish (finish, id: 45)
Parameters:
hammer -u admin -p changeme os set-default-template
--config-template-id 48 --id 1
Could not set the os default template:
   Error: Received data of unknown format
What am i doing wrong ?


You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to foreman-users+unsubscribe@googlegroups.com
mailto:foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com
mailto:foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

hammer -u admin -p changeme --show-ids os info --id 1
Id: 1
Full name: CentOS 6.5
Release name:
Family: Redhat
Name: CentOS
Major version: 6
Minor version: 5
Partition tables:
Redhat_6_Disk30Go_Default5Go (id: 13)
Redhat_6_Disk50Go_Opt20Go (id: 14)
Redhat_6_Disk50Go_Var20Go (id: 15)
Default templates:
Redhat default PXELinux (PXELinux, id: 43)
Architectures:
i386 (id: 2)
x86_64 (id: 1)
Installation media:
CentOS mirror (id: 7)
Templates:
Redhat default Kickstart (provision, id: 41)
Redhat default PXELinux (PXELinux, id: 43)
Redhat default finish (finish, id: 47)
Parameters:

hammer -u admin -p changeme os set-default-template --config-template-id 41
–id 1

produces these logs entries in foreman :

Started GET "/apidoc/apipie_checksum" for ::1 at 2014-06-18 16:06:29 +0200
Processing by Apipie::ApipiesController#apipie_checksum as JSON
Parameters: {"apipy"=>{}}
Rendered
/opt/rh/ruby193/root/usr/share/gems/gems/apipie-rails-0.1.2/app/views/apipie/apipies/apipie_checksum.json.erb
(0.1ms)
Completed 200 OK in 3ms (Views: 2.4ms | ActiveRecord: 0.0ms)

Started GET "/apidoc/apipie_checksum" for ::1 at 2014-06-18 16:06:30 +0200
Processing by Apipie::ApipiesController#apipie_checksum as JSON
Parameters: {"apipy"=>{}}
Rendered
/opt/rh/ruby193/root/usr/share/gems/gems/apipie-rails-0.1.2/app/views/apipie/apipies/apipie_checksum.json.erb
(0.0ms)
Completed 200 OK in 1ms (Views: 0.9ms | ActiveRecord: 0.0ms)

Started GET "/api/config_templates/41" for ::1 at 2014-06-18 16:06:31 +0200
Processing by Api::V2::ConfigTemplatesController#show as JSON
Parameters: {"apiv"=>"v2", "id"=>"41", "config_template"=>{}}
Authorized user admin(foremanadmin CTIBruz)
Rendered api/v2/config_templates/show.json.rabl (9.5ms)
Completed 200 OK in 26ms (Views: 9.4ms | ActiveRecord: 4.4ms)

Started GET "/apidoc/apipie_checksum" for ::1 at 2014-06-18 16:06:31 +0200
Processing by Apipie::ApipiesController#apipie_checksum as JSON
Parameters: {"apipy"=>{}}
Rendered
/opt/rh/ruby193/root/usr/share/gems/gems/apipie-rails-0.1.2/app/views/apipie/apipies/apipie_checksum.json.erb
(0.1ms)
Completed 200 OK in 1ms (Views: 1.1ms | ActiveRecord: 0.0ms)

Started GET "/api/operatingsystems/1/os_default_templates" for ::1 at
2014-06-18 16:06:31 +0200
Processing by Api::V2::OsDefaultTemplatesController#index as JSON
Parameters: {"apiv"=>"v2", "operatingsystem_id"=>"1",
"os_default_template"=>{}}
Authorized user admin(foremanadmin CTIBruz)
Rendered api/v2/os_default_templates/index.json.rabl within
api/v2/layouts/index_layout (4.4ms)
Completed 200 OK in 23ms (Views: 5.1ms | ActiveRecord: 4.4ms)

··· Le mercredi 18 juin 2014 15:40:01 UTC+2, Tomas Strachota a écrit : > > On 06/18/2014 03:23 PM, Alexandre Barth wrote: > > I've upgraded Foreman to version 1.5.1 and still have the error. > > I've been trying to reproduce the problem but had no luck so far. > Would you mind sharing also the server logs with us? > > T. > > > > > Le vendredi 13 juin 2014 15:19:03 UTC+2, Alexandre Barth a écrit : > > > > Hello ! > > I can't set my os default templates using hammer cli 0.1.1 : > > hammer -u admin -p changeme --version > > hammer (0.1.1) > > * hammer_cli_foreman (0.1.1) > > hammer -u admin -p changeme --show-ids os info --id 1 > > Id: 1 > > Full name: CentOS 6.5 > > Release name: > > Family: Redhat > > Name: CentOS > > Major version: 6 > > Minor version: 5 > > Partition tables: > > Redhat_6_Disk30Go_Default5Go (id: 13) > > Redhat_6_Disk50Go_Opt20Go (id: 14) > > Redhat_6_Disk50Go_Var20Go (id: 15) > > Default templates: > > Architectures: > > i386 (id: 2) > > x86_64 (id: 1) > > Installation media: > > CentOS mirror (id: 7) > > Templates: > > Redhat default Kickstart (provision, id: 48) > > Redhat default PXELinux (PXELinux, id: 42) > > Redhat default finish (finish, id: 45) > > Parameters: > > hammer -u admin -p changeme os set-default-template > > --config-template-id 48 --id 1 > > Could not set the os default template: > > Error: Received data of unknown format > > What am i doing wrong ? > > > > -- > > You received this message because you are subscribed to the Google > > Groups "Foreman users" group. > > To unsubscribe from this group and stop receiving emails from it, send > > an email to foreman-user...@googlegroups.com > > <mailto:foreman-users+unsubscribe@googlegroups.com >. > > To post to this group, send email to forema...@googlegroups.com > > > <mailto:forema...@googlegroups.com >. > > Visit this group at http://groups.google.com/group/foreman-users. > > For more options, visit https://groups.google.com/d/optout. > >

I finally solved the problem …

I'm scripting foreman installation and configuration, and this part was the
origin of the problem :

curl -k -u admin:changeme -H "Accept: version=2,application/json" -H
"Content-Type: application/json"
-X PUT -d '{ "value":"100" }'
https://localhost/api/settings/entries_per_page

I affected the value as a string and not integer, i removed double quotes
(100 instead of "100") and now everything is working like a charm.

With "100" as value, the following command doesn't work anymore :

hammer -u admin -p changeme template kinds

which impacts i suppose the default template association command.

··· Le mercredi 18 juin 2014 16:08:41 UTC+2, Alexandre Barth a écrit : > > hammer -u admin -p changeme --show-ids os info --id 1 > Id: 1 > Full name: CentOS 6.5 > Release name: > Family: Redhat > Name: CentOS > Major version: 6 > Minor version: 5 > Partition tables: > Redhat_6_Disk30Go_Default5Go (id: 13) > Redhat_6_Disk50Go_Opt20Go (id: 14) > Redhat_6_Disk50Go_Var20Go (id: 15) > Default templates: > Redhat default PXELinux (PXELinux, id: 43) > Architectures: > i386 (id: 2) > x86_64 (id: 1) > Installation media: > CentOS mirror (id: 7) > Templates: > Redhat default Kickstart (provision, id: 41) > Redhat default PXELinux (PXELinux, id: 43) > Redhat default finish (finish, id: 47) > Parameters: > > hammer -u admin -p changeme os set-default-template --config-template-id > 41 --id 1 > > produces these logs entries in foreman : > > Started GET "/apidoc/apipie_checksum" for ::1 at 2014-06-18 16:06:29 +0200 > Processing by Apipie::ApipiesController#apipie_checksum as JSON > Parameters: {"apipy"=>{}} > Rendered > /opt/rh/ruby193/root/usr/share/gems/gems/apipie-rails-0.1.2/app/views/apipie/apipies/apipie_checksum.json.erb > (0.1ms) > Completed 200 OK in 3ms (Views: 2.4ms | ActiveRecord: 0.0ms) > > > Started GET "/apidoc/apipie_checksum" for ::1 at 2014-06-18 16:06:30 +0200 > Processing by Apipie::ApipiesController#apipie_checksum as JSON > Parameters: {"apipy"=>{}} > Rendered > /opt/rh/ruby193/root/usr/share/gems/gems/apipie-rails-0.1.2/app/views/apipie/apipies/apipie_checksum.json.erb > (0.0ms) > Completed 200 OK in 1ms (Views: 0.9ms | ActiveRecord: 0.0ms) > > > Started GET "/api/config_templates/41" for ::1 at 2014-06-18 16:06:31 +0200 > Processing by Api::V2::ConfigTemplatesController#show as JSON > Parameters: {"apiv"=>"v2", "id"=>"41", "config_template"=>{}} > Authorized user admin(foremanadmin CTIBruz) > Rendered api/v2/config_templates/show.json.rabl (9.5ms) > Completed 200 OK in 26ms (Views: 9.4ms | ActiveRecord: 4.4ms) > > > Started GET "/apidoc/apipie_checksum" for ::1 at 2014-06-18 16:06:31 +0200 > Processing by Apipie::ApipiesController#apipie_checksum as JSON > Parameters: {"apipy"=>{}} > Rendered > /opt/rh/ruby193/root/usr/share/gems/gems/apipie-rails-0.1.2/app/views/apipie/apipies/apipie_checksum.json.erb > (0.1ms) > Completed 200 OK in 1ms (Views: 1.1ms | ActiveRecord: 0.0ms) > > > Started GET "/api/operatingsystems/1/os_default_templates" for ::1 at > 2014-06-18 16:06:31 +0200 > Processing by Api::V2::OsDefaultTemplatesController#index as JSON > Parameters: {"apiv"=>"v2", "operatingsystem_id"=>"1", > "os_default_template"=>{}} > Authorized user admin(foremanadmin CTIBruz) > Rendered api/v2/os_default_templates/index.json.rabl within > api/v2/layouts/index_layout (4.4ms) > Completed 200 OK in 23ms (Views: 5.1ms | ActiveRecord: 4.4ms) > > Le mercredi 18 juin 2014 15:40:01 UTC+2, Tomas Strachota a écrit : >> >> On 06/18/2014 03:23 PM, Alexandre Barth wrote: >> > I've upgraded Foreman to version 1.5.1 and still have the error. >> >> I've been trying to reproduce the problem but had no luck so far. >> Would you mind sharing also the server logs with us? >> >> T. >> >> > >> > Le vendredi 13 juin 2014 15:19:03 UTC+2, Alexandre Barth a écrit : >> > >> > Hello ! >> > I can't set my os default templates using hammer cli 0.1.1 : >> > hammer -u admin -p changeme --version >> > hammer (0.1.1) >> > * hammer_cli_foreman (0.1.1) >> > hammer -u admin -p changeme --show-ids os info --id 1 >> > Id: 1 >> > Full name: CentOS 6.5 >> > Release name: >> > Family: Redhat >> > Name: CentOS >> > Major version: 6 >> > Minor version: 5 >> > Partition tables: >> > Redhat_6_Disk30Go_Default5Go (id: 13) >> > Redhat_6_Disk50Go_Opt20Go (id: 14) >> > Redhat_6_Disk50Go_Var20Go (id: 15) >> > Default templates: >> > Architectures: >> > i386 (id: 2) >> > x86_64 (id: 1) >> > Installation media: >> > CentOS mirror (id: 7) >> > Templates: >> > Redhat default Kickstart (provision, id: 48) >> > Redhat default PXELinux (PXELinux, id: 42) >> > Redhat default finish (finish, id: 45) >> > Parameters: >> > hammer -u admin -p changeme os set-default-template >> > --config-template-id 48 --id 1 >> > Could not set the os default template: >> > Error: Received data of unknown format >> > What am i doing wrong ? >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups "Foreman users" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> > an email to foreman-user...@googlegroups.com >> > . >> > To post to this group, send email to forema...@googlegroups.com >> > . >> > Visit this group at http://groups.google.com/group/foreman-users. >> > For more options, visit https://groups.google.com/d/optout. >> >>

> I finally solved the problem …
>
> I'm scripting foreman installation and configuration, and this part was
> the origin of the problem :
>
> curl -k -u admin:changeme -H "Accept: version=2,application/json" -H
> "Content-Type: application/json"
> -X PUT -d '{ "value":"100" }'
> https://localhost/api/settings/entries_per_page
>
> I affected the value as a string and not integer, i removed double
> quotes (100 instead of "100") and now everything is working like a charm.
>
> With "100" as value, the following command doesn't work anymore :
>
> hammer -u admin -p changeme template kinds
>
> which impacts i suppose the default template association command.

Nice catch! I filed:
http://projects.theforeman.org/issues/6285

This wrong setting would actually break all index api actions. The other
hammer commands were not affected only because they ask for custom
pagination in their api requests.

Thanks for reporting the problem!

Tomas

··· On 06/19/2014 11:28 AM, Alexandre Barth wrote:

Le mercredi 18 juin 2014 16:08:41 UTC+2, Alexandre Barth a écrit :

hammer -u admin -p changeme --show-ids os info --id 1
Id:                 1
Full name:          CentOS 6.5
Release name:
Family:             Redhat
Name:               CentOS
Major version:      6
Minor version:      5
Partition tables:
     Redhat_6_Disk30Go_Default5Go (id: 13)
     Redhat_6_Disk50Go_Opt20Go (id: 14)
     Redhat_6_Disk50Go_Var20Go (id: 15)
Default templates:
     Redhat default PXELinux (PXELinux, id: 43)
Architectures:
     i386 (id: 2)
     x86_64 (id: 1)
Installation media:
     CentOS mirror (id: 7)
Templates:
     Redhat default Kickstart (provision, id: 41)
     Redhat default PXELinux (PXELinux, id: 43)
     Redhat default finish (finish, id: 47)
Parameters:

hammer -u admin -p changeme os set-default-template
--config-template-id 41 --id 1

produces these logs entries in foreman :

Started GET "/apidoc/apipie_checksum" for ::1 at 2014-06-18 16:06:29
+0200
Processing by Apipie::ApipiesController#apipie_checksum as JSON
   Parameters: {"apipy"=>{}}
   Rendered
/opt/rh/ruby193/root/usr/share/gems/gems/apipie-rails-0.1.2/app/views/apipie/apipies/apipie_checksum.json.erb
(0.1ms)
Completed 200 OK in 3ms (Views: 2.4ms | ActiveRecord: 0.0ms)


Started GET "/apidoc/apipie_checksum" for ::1 at 2014-06-18 16:06:30
+0200
Processing by Apipie::ApipiesController#apipie_checksum as JSON
   Parameters: {"apipy"=>{}}
   Rendered
/opt/rh/ruby193/root/usr/share/gems/gems/apipie-rails-0.1.2/app/views/apipie/apipies/apipie_checksum.json.erb
(0.0ms)
Completed 200 OK in 1ms (Views: 0.9ms | ActiveRecord: 0.0ms)


Started GET "/api/config_templates/41" for ::1 at 2014-06-18
16:06:31 +0200
Processing by Api::V2::ConfigTemplatesController#show as JSON
   Parameters: {"apiv"=>"v2", "id"=>"41", "config_template"=>{}}
Authorized user admin(foremanadmin CTIBruz)
   Rendered api/v2/config_templates/show.json.rabl (9.5ms)
Completed 200 OK in 26ms (Views: 9.4ms | ActiveRecord: 4.4ms)


Started GET "/apidoc/apipie_checksum" for ::1 at 2014-06-18 16:06:31
+0200
Processing by Apipie::ApipiesController#apipie_checksum as JSON
   Parameters: {"apipy"=>{}}
   Rendered
/opt/rh/ruby193/root/usr/share/gems/gems/apipie-rails-0.1.2/app/views/apipie/apipies/apipie_checksum.json.erb
(0.1ms)
Completed 200 OK in 1ms (Views: 1.1ms | ActiveRecord: 0.0ms)


Started GET "/api/operatingsystems/1/os_default_templates" for ::1
at 2014-06-18 16:06:31 +0200
Processing by Api::V2::OsDefaultTemplatesController#index as JSON
   Parameters: {"apiv"=>"v2", "operatingsystem_id"=>"1",
"os_default_template"=>{}}
Authorized user admin(foremanadmin CTIBruz)
   Rendered api/v2/os_default_templates/index.json.rabl within
api/v2/layouts/index_layout (4.4ms)
Completed 200 OK in 23ms (Views: 5.1ms | ActiveRecord: 4.4ms)

Le mercredi 18 juin 2014 15:40:01 UTC+2, Tomas Strachota a écrit :

    On 06/18/2014 03:23 PM, Alexandre Barth wrote:
     > I've upgraded Foreman to version 1.5.1 and still have the error.

    I've been trying to reproduce the problem but had no luck so far.
    Would you mind sharing also the server logs with us?

    T.

     >
     > Le vendredi 13 juin 2014 15:19:03 UTC+2, Alexandre Barth a
    écrit :
     >
     >     Hello !
     >     I can't set my os default templates using hammer cli 0.1.1 :
     >     hammer -u admin -p changeme --version
     >     hammer (0.1.1)
     >       * hammer_cli_foreman (0.1.1)
     >     hammer -u admin -p changeme --show-ids os info --id 1
     >     Id:                 1
     >     Full name:          CentOS 6.5
     >     Release name:
     >     Family:             Redhat
     >     Name:               CentOS
     >     Major version:      6
     >     Minor version:      5
     >     Partition tables:
     >          Redhat_6_Disk30Go_Default5Go (id: 13)
     >          Redhat_6_Disk50Go_Opt20Go (id: 14)
     >          Redhat_6_Disk50Go_Var20Go (id: 15)
     >     Default templates:
     >     Architectures:
     >          i386 (id: 2)
     >          x86_64 (id: 1)
     >     Installation media:
     >          CentOS mirror (id: 7)
     >     Templates:
     >          Redhat default Kickstart (provision, id: 48)
     >          Redhat default PXELinux (PXELinux, id: 42)
     >          Redhat default finish (finish, id: 45)
     >     Parameters:
     >     hammer -u admin -p changeme os set-default-template
     >     --config-template-id 48 --id 1
     >     Could not set the os default template:
     >        Error: Received data of unknown format
     >     What am i doing wrong ?
     >
     > --
     > You received this message because you are subscribed to the
    Google
     > Groups "Foreman users" group.
     > To unsubscribe from this group and stop receiving emails from
    it, send
     > an email to foreman-user...@googlegroups.com
     > <mailto:foreman-users+unsubscribe@googlegroups.com>.
     > To post to this group, send email to forema...@googlegroups.com
     > <mailto:forema...@googlegroups.com>.
     > Visit this group at
    http://groups.google.com/group/foreman-users
    <http://groups.google.com/group/foreman-users>.
     > For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>.


You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to foreman-users+unsubscribe@googlegroups.com
mailto:foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com
mailto:foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.