Provisioning template

Hello,

can someone help me to understand below from porivsioning template.

<% subnet = @host.subnet -%> <% if subnet.respond_to?(:dhcp_boot_mode?) -%>
<% dhcp = subnet.dhcp_boot_mode? && !@static -%> <% else -%> <% dhcp = !
@static -%> <% end -%>
network --bootproto <%= dhcp ? 'dhcp' : "static --ip=#{@host.ip} --netmask=
#{subnet.mask} --gateway=#{subnet.gateway} --nameserver=#{[subnet.dns_primary,
subnet.dns_secondary].select(&:present?).join(',')}" %> --device=<%= @host.mac
-%> --hostname <%= @host %>

in above code i understand "subnet = @host.subnet" but then how i know "subnet.dhcp_boot_mode?"
subnet has dhcp_boot_mode param/method to call ??

then subnet.dns_primary ?? are those methods documented anywhere??

Regards,
DJ

> Hello,
>
> can someone help me to understand below from porivsioning template.
>
> <%subnet = @host.subnet -%>
> <%if subnet.respond_to?(:dhcp_boot_mode?) -%>
> <%dhcp = subnet.dhcp_boot_mode? && !@static -%>
> <%else -%>
> <%dhcp = !@static -%>
> <%end -%>
>
> network --bootproto <%=dhcp ? 'dhcp' : "static --ip=#{@host.ip}
> --netmask=#{subnet.mask} --gateway=#{subnet.gateway}
> --nameserver=#{[subnet.dns_primary,
> subnet.dns_secondary].select(&:present?).join(',')}" %>
> --device=<%=@host.mac -%> --hostname <%=@host %>
>
>
>
> in above code i understand "subnet = @host.subnet" but then how i know
> "subnet.dhcp_boot_mode?" subnet has dhcp_boot_mode param/method to call ??

dhcp_boot_mode? is defined in app/models/subnet.rb, and it checks if the
"boot mode" setting on the subnet is DHCP, returning true if it is.

> then subnet.dns_primary ?? are those methods documented anywhere??

http://projects.theforeman.org/projects/foreman/wiki/TemplateWriting
covers some of them, including dns_primary.

dns_primary is the name of the "Primary DNS server" field on the subnet.
There's a list of all fields in db/schema.rb on your installation too.

··· On 20/03/15 10:30, Unix SA wrote:


Dominic Cleal
Red Hat Engineering

Thank you.

··· On Friday, 20 March 2015 16:06:28 UTC+5:30, Dominic Cleal wrote: > > On 20/03/15 10:30, Unix SA wrote: > > Hello, > > > > can someone help me to understand below from porivsioning template. > > > > <%subnet = @host.subnet -%> > > <%if subnet.respond_to?(:dhcp_boot_mode?) -%> > > <%dhcp = subnet.dhcp_boot_mode? && !@static -%> > > <%else -%> > > <%dhcp = !@static -%> > > <%end -%> > > > > network --bootproto <%=dhcp ? 'dhcp' : "static --ip=#{@host.ip} > > --netmask=#{subnet.mask} --gateway=#{subnet.gateway} > > --nameserver=#{[subnet.dns_primary, > > subnet.dns_secondary].select(&:present?).join(',')}" %> > > --device=<%=@host.mac -%> --hostname <%=@host %> > > > > > > > > in above code i understand "subnet = @host.subnet" but then how i know > > "subnet.dhcp_boot_mode?" subnet has dhcp_boot_mode param/method to call > ?? > > dhcp_boot_mode? is defined in app/models/subnet.rb, and it checks if the > "boot mode" setting on the subnet is DHCP, returning true if it is. > > > then subnet.dns_primary ?? are those methods documented anywhere?? > > http://projects.theforeman.org/projects/foreman/wiki/TemplateWriting > covers some of them, including dns_primary. > > dns_primary is the name of the "Primary DNS server" field on the subnet. > There's a list of all fields in db/schema.rb on your installation too. > > -- > Dominic Cleal > Red Hat Engineering >