Undefined method 'physical_device' in preseed_networking_setup

Hi,

I try to provision a vm machine with an alias/virtual Interface like eth0:1.
So far so good. After the first build and the final Callback to Foreman I
get an Exception in the foreman log so that the "wget" command to finish
build cancels.

> ActionView::Template::Error: The snippet 'preseed_networking_setup'
threw an error: undefined method 'physical_device' for Nic::Base::Jail
(Nic::Managed)

> /usr/share/foreman/lib/foreman/renderer.rb:87:in `rescue in snippet'

> /usr/share/foreman/lib/foreman/renderer.rb:84:in `snippet'

>
/opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.2.4/lib/safemode/scope.rb:37:in
`method_missing'

I stop build mode manuall directly in foreman. When I try to restart the
build I got that Message from foreman in the webgui as popup before I can
force the build.

Failure parsing Preseed default finish DemoVM : The snippet
'preseed_networking_setup' threw an error: undefined method
'physical_device' for Nic::Base::Jail (Nic::Managed).

In the Snippet "preseed_networking_setup" I found this

<% @host.managed_interfaces.each do |interface| %>
<% next if !interface.managed? || interface.subnet.nil? ||
interface.primary -%>
<% subnet = interface.subnet -%>
<% virtual = interface.virtual? -%>
<% dhcp = subnet.nil? ? false : subnet.dhcp_boot_mode? -%>
real=ip -o link | grep &lt;%= interface.mac -%&gt; | awk &#39;{print $2;}&#39; | sed s/:$//
<% if virtual -%>
real=echo &lt;%= interface.identifier -%&gt; | sed s/&lt;%=* interface.physical_device* -%&gt;/$real/
<% end -%>

But what's the correct Method for interface.physical_device?

Thanks for help,

Tom

> Hi,
>
> I try to provision a vm machine with an alias/virtual Interface like eth0:1.
> So far so good. After the first build and the final Callback to Foreman
> I get an Exception in the foreman log so that the "wget" command to
> finish build cancels.
>
[…]
> In the Snippet "preseed_networking_setup" I found this
>
> <% @host.managed_interfaces.each do |interface| %>
> <% next if !interface.managed? || interface.subnet.nil? ||
> interface.primary -%>
> <% subnet = interface.subnet -%>
> <% virtual = interface.virtual? -%>
> <% dhcp = subnet.nil? ? false : subnet.dhcp_boot_mode? -%>
> real=ip -o link | grep &lt;%= interface.mac -%&gt; | awk &#39;{print $2;}&#39; | sed &gt; s/:$//
> <% if virtual -%>
> real=echo &lt;%= interface.identifier -%&gt; | sed &gt; s/&lt;%=*interface.physical_device* -%&gt;/$real/
> <% end -%>
>
> But what's the correct Method for interface.physical_device?

It should probably be interface.attached_to, it was renamed back in
Foreman 1.7.0. If it works for you, please do send a fix to
https://github.com/theforeman/community-templates/blob/develop/snippets/preseed_networking_setup.erb.

··· On 14/10/16 09:14, Tom K. wrote:


Dominic Cleal
dominic@cleal.org

FWIW, this got fixed in https://github.com/theforeman/community-templates/pull/351

··· On Fri, Oct 14, 2016 at 01:14:38AM -0700, Tom K. wrote: > I try to provision a vm machine with an alias/virtual Interface like eth0:1. > So far so good. After the first build and the final Callback to Foreman I > get an Exception in the foreman log so that the "wget" command to finish > build cancels. > > > ActionView::Template::Error: The snippet 'preseed_networking_setup' > threw an error: undefined method 'physical_device' for Nic::Base::Jail > (Nic::Managed)


Michael Moll

Perfect!
But there are still some other errors. Will report @github

Thanks.

– Tom

··· Am Freitag, 14. Oktober 2016 11:29:31 UTC+2 schrieb Dominic Cleal: > > On 14/10/16 09:14, Tom K. wrote: > > Hi, > > > > I try to provision a vm machine with an alias/virtual Interface like > eth0:1. > > So far so good. After the first build and the final Callback to Foreman > > I get an Exception in the foreman log so that the "wget" command to > > finish build cancels. > > > [..] > > In the Snippet "preseed_networking_setup" I found this > > > > <% @host.managed_interfaces.each do |interface| %> > > <% next if !interface.managed? || interface.subnet.nil? || > > interface.primary -%> > > <% subnet = interface.subnet -%> > > <% virtual = interface.virtual? -%> > > <% dhcp = subnet.nil? ? false : subnet.dhcp_boot_mode? -%> > > real=`ip -o link | grep <%= interface.mac -%> | awk '{print $2;}' | sed > > s/:$//` > > <% if virtual -%> > > real=`echo <%= interface.identifier -%> | sed > > s/<%=*interface.physical_device* -%>/$real/` > > <% end -%> > > > > But what's the correct Method for interface.physical_device? > > It should probably be interface.attached_to, it was renamed back in > Foreman 1.7.0. If it works for you, please do send a fix to > > https://github.com/theforeman/community-templates/blob/develop/snippets/preseed_networking_setup.erb. > > > -- > Dominic Cleal > dom...@cleal.org >