Feature #1361 » foreman-4.0-subnet-fields-in-provisioning-templates.patch
db/schema.rb 2011-11-17 09:32:29.000000000 -0600 | ||
---|---|---|
create_table "subnets", :force => true do |t|
|
||
t.string "network", :limit => 15
|
||
t.string "mask", :limit => 15
|
||
t.string "gateway", :limit => 15
|
||
t.string "dns", :limit => 15
|
||
t.integer "domain_id"
|
||
t.integer "priority"
|
||
t.string "ranges", :limit => 512
|
||
--
|
||
app/models/subnet.rb | 6 ++++--
|
||
app/views/subnets/_fields.html.erb | 2 ++
|
||
migrate/20111116_add_gateway_and_dns_to_subnets.rb | 11 +++++++++++
|
||
3 files changed, 17 insertions(+), 2 deletions(-)
|
||
create mode 100644 migrate/20111116_add_gateway_and_dns_to_subnets.rb
|
app/models/subnet.rb | ||
---|---|---|
belongs_to :dhcp, :class_name => "SmartProxy"
|
||
belongs_to :tftp, :class_name => "SmartProxy"
|
||
belongs_to :domain
|
||
validates_presence_of :network, :mask, :domain_id, :name
|
||
validates_presence_of :network, :mask, :gateway, :dns, :domain_id, :name
|
||
validates_uniqueness_of :network
|
||
validates_format_of :network, :with => Net::Validations::IP_REGEXP
|
||
validates_format_of :mask, :with => Net::Validations::IP_REGEXP
|
||
validates_format_of :gateway, :with => Net::Validations::IP_REGEXP
|
||
validates_format_of :dns , :with => Net::Validations::IP_REGEXP
|
||
validates_uniqueness_of :name, :scope => :domain_id
|
||
default_scope :order => 'priority'
|
||
before_destroy Ensure_not_used_by.new(:hosts, :sps)
|
||
scoped_search :on => [:name, :network, :mask], :complete_value => true
|
||
scoped_search :on => [:name, :network, :mask, :gateway, :dns], :complete_value => true
|
||
scoped_search :in => :domain, :on => :name, :rename => :domain, :complete_value => true
|
||
# Subnets are displayed in the form of their network network/network mask
|
app/views/subnets/_fields.html.erb | ||
---|---|---|
:help_inline => "Domains in which this subnet is part" %>
|
||
<%= text_f f, :network %>
|
||
<%= text_f f, :mask, :help_inline => "Netmask for this subnet", :label => "Netmask" %>
|
||
<%= text_f f, :gateway, :help_inline => "Gateway for this subnet", :label => "Gateway" %>
|
||
<%= text_f f, :dns, :help_inline => "Primary DNS for this subnet", :label => "DNS" %>
|
||
<%= select_f f, :dhcp_id, Feature.find_by_name("DHCP").smart_proxies, :id, :name, :include_blank => "None",
|
||
:help_inline => "DHCP Proxy to use within this subnet", :label => "DHCP Proxy" %>
|
migrate/20111116_add_gateway_and_dns_to_subnets.rb | ||
---|---|---|
class AddSubnetAndDomainToHostGroups < ActiveRecord::Migration
|
||
def self.up
|
||
add_column :subnets, :gateway, :string, :limit => 15
|
||
add_column :subnets, :dns, :string, :limit => 15
|
||
end
|
||
def self.down
|
||
remove_column :subnets, :gateway
|
||
remove_column :subnets, :dns
|
||
end
|
||
end
|
||
-
|
app/helpers/unattended_helper.rb | ||
---|---|---|
@host.root_pass
|
||
end
|
||
def subnet
|
||
subnet = Subnet.find(@host.subnet_id)
|
||
{:gateway => subnet.gateway , :mask => subnet.mask, :dns => subnet.dns }
|
||
end
|
||
end
|
lib/foreman/renderer.rb | ||
---|---|---|
end
|
||
def unattended_render template
|
||
allowed_helpers = [ :foreman_url, :grub_pass, :snippet, :snippets, :ks_console, :root_pass, :multiboot, :jumpstart_path, :install_path,
|
||
allowed_helpers = [ :foreman_url, :grub_pass, :snippet, :snippets, :ks_console, :root_pass, :subnet, :multiboot, :jumpstart_path, :install_path,
|
||
:miniroot, :media_path]
|
||
allowed_variables = ({:arch => @arch, :host => @host, :osver => @osver, :mediapath => @mediapath, :static => @static,
|
||
:yumrepo => @yumrepo, :dynamic => @dynamic, :epel => @epel, :kernel => @kernel, :initrd => @initrd,
|