Module: HostTemplateHelpers

Included in:
Host::Managed
Defined in:
app/models/host_template_helpers.rb

Overview

These helpers are provided as convenience methods available to the writers of templates and are mixed in to Host

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#url_optionsObject

used by url_for to generate the path correctly


36
37
38
39
40
41
# File 'app/models/host_template_helpers.rb', line 36

def url_options
  url_options = (@url_options || {}).deep_dup()
  url_options[:protocol] = "http://"
  url_options[:host] = Setting[:foreman_url] if Setting[:foreman_url]
  url_options
end

Instance Method Details

#foreman_url(action = "provision") ⇒ Object

returns the URL for Foreman based on the required action


27
28
29
30
31
# File 'app/models/host_template_helpers.rb', line 27

def foreman_url(action = "provision")
  url_for :only_path => false, :controller => "/unattended",
          :action => action,
          :token => (@host.token.value unless @host.token.nil?)
end

#install_pathObject

Calculates the media's path in relation to the domain and convert host to an IP


5
6
7
# File 'app/models/host_template_helpers.rb', line 5

def install_path
  operatingsystem.interpolate_medium_vars(operatingsystem.media_path(medium, domain), architecture.name, operatingsystem)
end

#jumpstart_pathObject

Calculates the jumpstart path in relation to the domain and convert host to an IP


10
11
12
# File 'app/models/host_template_helpers.rb', line 10

def jumpstart_path
  operatingsystem.jumpstart_path medium, domain
end

#media_pathObject


22
23
24
# File 'app/models/host_template_helpers.rb', line 22

def media_path
  operatingsystem.medium_uri(self)
end

#minirootObject


18
19
20
# File 'app/models/host_template_helpers.rb', line 18

def miniroot
  operatingsystem.initrd(architecture)
end

#multibootObject


14
15
16
# File 'app/models/host_template_helpers.rb', line 14

def multiboot
  operatingsystem.pxe_prefix(architecture) + "-multiboot"
end