Failed to "Resolve Provisioning Templates" if host contain parameters

CentOS 6.5
Foreman 1.7.5
ruby193-ruby-1.9.3.484-50.el6.centos.alt.x86_64

Resolve template parameters keep failing if host_parameters_attributes
exists.

Started POST "/hosts/template_used?provisioning=build" for 10.100.17.143 at
2015-04-30 04:50:00 -0500
Processing by HostsController#template_used as /
Parameters: {"utf8"=>"✓",
"authenticity_token"=>"x5mJTuyhgKFAWbBzPR1GcbgkMKRTBbRh6eNr0XKIiCI=",
"host"=>{"name"=>"aic1-2", "hostgroup_id"=>"", "environment_id"=>"1",
"puppet_ca_proxy_id"=>"1", "puppet_proxy_id"=>"1", "puppetclass_ids"=>[""],
"managed"=>"t", "progress_report_id"=>"[FILTERED]", "domain_id"=>"3",
"realm_id"=>"", "mac"=>"00:15:b2:a5:f3:4d", "subnet_id"=>"2",
"ip"=>"172.29.60.26",
"interfaces_attributes"=>{"new_interfaces"=>{"_destroy"=>"false",
"type"=>"Nic::Managed", "mac"=>"", "identifier"=>"", "name"=>"",
"domain_id"=>"", "subnet_id"=>"", "ip"=>"", "managed"=>"1", "virtual"=>"0",
"tag"=>"", "attached_to"=>""}}, "architecture_id"=>"1",
"operatingsystem_id"=>"5", "medium_id"=>"20", "ptable_id"=>"7", "disk"=>"",
"root_pass"=>"[FILTERED]",
"host_parameters_attributes"=>{"0"=>{"name"=>"test", "value"=>"[FILTERED]",
"hidden_value"=>"[FILTERED]", "_destroy"=>"false", "nested"=>"",
"id"=>"301"}}, "is_owned_by"=>"1-Users", "enabled"=>"1", "model_id"=>"",
"comment"=>"", "overwrite"=>"false"}, "fakepassword"=>"[FILTERED]",
"provisioning"=>"build"}
Rendered common/404.html.erb within layouts/application (1.6ms)
Rendered layouts/base.html.erb (1.5ms)
Completed 404 Not Found in 29ms (Views: 5.3ms | ActiveRecord: 3.6ms)

The way i have fixed it (locally) is adding :host_parameters_attributes
to except list in "def template_used"

/usr/share/foreman/app/controllers/hosts_controller.rb

def template_used
host = Host.new(params[:host].except(:host_parameters_attributes,
:interfaces_attributes))
templates = host.available_template_kinds(params[:provisioning])
return not_found if templates.empty?
render :partial => 'provisioning', :locals => { :templates => templates
}
end

> CentOS 6.5
> Foreman 1.7.5
> ruby193-ruby-1.9.3.484-50.el6.centos.alt.x86_64
>
> Resolve template parameters keep failing if host_parameters_attributes
> exists.
>
[snip]
>
>
> The way i have fixed it (locally) is adding :host_parameters_attributes
> to except list in "def template_used"
>
> /usr/share/foreman/app/controllers/hosts_controller.rb
>
> def template_used
> host =
> Host.new(params[:host].except(:host_parameters_attributes,
> :interfaces_attributes))
> templates = host.available_template_kinds(params[:provisioning])
> return not_found if templates.empty?
> render :partial => 'provisioning', :locals => { :templates =>
> templates }
> end

Interesting bug, would you mind filing it in Redmine or even better,
sending in your fix as a pull request?

http://projects.theforeman.org/projects/foreman/issues/new
and
Foreman :: Contribute respectively.

Cheers,

··· On 30/04/15 11:01, Avi Tal wrote:


Dominic Cleal
Red Hat Engineering

NP

··· On Friday, May 1, 2015 at 10:49:54 AM UTC+3, Dominic Cleal wrote: > > On 30/04/15 11:01, Avi Tal wrote: > > CentOS 6.5 > > Foreman 1.7.5 > > ruby193-ruby-1.9.3.484-50.el6.centos.alt.x86_64 > > > > Resolve template parameters keep failing if host_parameters_attributes > > exists. > > > [snip] > > > > > > The way i have fixed it (locally) is adding :host_parameters_attributes > > to except list in "def template_used" > > > > /usr/share/foreman/app/controllers/hosts_controller.rb > > > > def template_used > > host = > > Host.new(params[:host].except(*:host_parameters_attributes,* > > :interfaces_attributes)) > > templates = host.available_template_kinds(params[:provisioning]) > > return not_found if templates.empty? > > render :partial => 'provisioning', :locals => { :templates => > > templates } > > end > > Interesting bug, would you mind filing it in Redmine or even better, > sending in your fix as a pull request? > > http://projects.theforeman.org/projects/foreman/issues/new > and > http://theforeman.org/contribute.html respectively. > > Cheers, > > -- > Dominic Cleal > Red Hat Engineering >

http://projects.theforeman.org/issues/10342

Bug includes a pull request list as well.

··· On Friday, May 1, 2015 at 11:10:55 AM UTC+3, Avi Tal wrote: > > NP > > On Friday, May 1, 2015 at 10:49:54 AM UTC+3, Dominic Cleal wrote: >> >> On 30/04/15 11:01, Avi Tal wrote: >> > CentOS 6.5 >> > Foreman 1.7.5 >> > ruby193-ruby-1.9.3.484-50.el6.centos.alt.x86_64 >> > >> > Resolve template parameters keep failing if host_parameters_attributes >> > exists. >> > >> [snip] >> > >> > >> > The way i have fixed it (locally) is adding :host_parameters_attributes >> > to except list in "def template_used" >> > >> > /usr/share/foreman/app/controllers/hosts_controller.rb >> > >> > def template_used >> > host = >> > Host.new(params[:host].except(*:host_parameters_attributes,* >> > :interfaces_attributes)) >> > templates = host.available_template_kinds(params[:provisioning]) >> > return not_found if templates.empty? >> > render :partial => 'provisioning', :locals => { :templates => >> > templates } >> > end >> >> Interesting bug, would you mind filing it in Redmine or even better, >> sending in your fix as a pull request? >> >> http://projects.theforeman.org/projects/foreman/issues/new >> and >> http://theforeman.org/contribute.html respectively. >> >> Cheers, >> >> -- >> Dominic Cleal >> Red Hat Engineering >> >

Great, thanks Avi. Congratulations on your first patch to Foreman core!

··· On 01/05/15 09:37, Avi Tal wrote: > http://projects.theforeman.org/issues/10342 > > Bug includes a pull request list as well.


Dominic Cleal
Red Hat Engineering

Hope to have more with higher complexity.
I am new to ruby but have lot of experience in python. I am currently a
python team leader of great startup.

BTW, I have worked in redhat so I am familiar with foreman (and with ohad)
:wink:

··· On Fri, May 1, 2015, 15:32 Dominic Cleal wrote:

On 01/05/15 09:37, Avi Tal wrote:

Bug #10342: Failed to "Resolve Provisioning Templates" if host contain parameters - Foreman

Bug includes a pull request list as well.

Great, thanks Avi. Congratulations on your first patch to Foreman core!


Dominic Cleal
Red Hat Engineering


You received this message because you are subscribed to a topic in the
Google Groups “foreman-dev” group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/foreman-dev/2boZISXTrs8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.