Module: ForemanM2::NicOrchestrationExtensions

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/foreman_m2/nic_orchestration_extensions.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#generate_pxe_template(kind) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/models/concerns/foreman_m2/nic_orchestration_extensions.rb', line 26

def generate_pxe_template(kind)
  # this is the only place we generate a template not via a web request
  # therefore some workaround is required to "render" the template.

  # If hybrid building, do not generate the template variables
  @kernel = ''
  @initrd = ''
  @mediapath = ''
  @xen = ''
  unless host.hybrid_build?
    @kernel = host.operatingsystem.kernel(host.arch)
    @initrd = host.operatingsystem.initrd(host.arch)
    if host.operatingsystem.respond_to?(:mediumpath)
      @mediapath = host.operatingsystem.mediumpath(host)
    end
  end

  # Xen requires additional boot files.
  if host.operatingsystem.respond_to?(:xen)
    @xen = host.operatingsystem.xen(host.arch)
  end

  # work around for ensuring that people can use @host 
  # as well, as tftp templates were usually confusing.
  @host = self.host

  return build_pxe_render(kind) if build?
  default_pxe_render(kind)
end

#queue_tftp_createObject



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/models/concerns/foreman_m2/nic_orchestration_extensions.rb', line 56

def queue_tftp_create
  host.operatingsystem.template_kinds.each do |kind|
    queue.create(:name => _('Deploy TFTP %{kind} config for %{host}') % 
                 { :kind => kind, :host => self }, :priority => 20,
                 :action => [self, :setTFTP, kind])
  end
  return unless build
  # Download files if using media
  unless host.hybrid_build?
    queue.create(:name => _('Fetch TFTP boot files for %s') % self, 
                 :priority => 25, :action => [self, :setTFTPBootFiles])
  end
end

#tftp_ready?Boolean

def hybrid_build?

self.provision_method == 'hybrid'

end

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
# File 'app/models/concerns/foreman_m2/nic_orchestration_extensions.rb', line 16

def tftp_ready?
  # host.managed? and managed? should always come first so that 
  # orchestration doesn't
  # even get tested for such objects
  (host.nil? || host.managed?) && 
    managed && provision? && 
    (host.operatingsystem && host.pxe_loader.present?) && 
    (pxe_build? || host.hybrid_build?) && SETTINGS[:unattended]
end