Module: ForemanWds::HostExtensions

Defined in:
app/models/concerns/foreman_wds/host_extensions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/models/concerns/foreman_wds/host_extensions.rb', line 3

def self.prepended(base)
  base.class_eval do
    after_build :ensure_wds_client
    before_provision :remove_wds_client

    has_one :wds_facet,
            class_name: '::ForemanWds::WdsFacet',
            foreign_key: :host_id,
            inverse_of: :host,
            dependent: :destroy
  end
end

Instance Method Details

#bare_metal_capabilitiesObject



47
48
49
50
# File 'app/models/concerns/foreman_wds/host_extensions.rb', line 47

def bare_metal_capabilities
  return super + [:wds] if os.nil? || os.family == 'Windows'
  super
end

#can_be_built?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'app/models/concerns/foreman_wds/host_extensions.rb', line 52

def can_be_built?
  super || (wds? && !build?)
end

#capabilitiesObject



42
43
44
45
# File 'app/models/concerns/foreman_wds/host_extensions.rb', line 42

def capabilities
  return super + [:wds] if compute_resource && (os.nil? || os.family == 'Windows')
  super
end

#ensure_wds_facetObject



64
65
66
# File 'app/models/concerns/foreman_wds/host_extensions.rb', line 64

def ensure_wds_facet
  wds_facet || build_wds_facet
end

#unattend_pass(password, suffix = nil) ⇒ Object



68
69
70
71
72
73
74
# File 'app/models/concerns/foreman_wds/host_extensions.rb', line 68

def unattend_pass(password, suffix = nil)
  if suffix.nil?
    suffix = password
    password = Base64.decode64(root_pass)
  end
  Base64.encode64(Encoding::Converter.new('UTF-8', 'UTF-16LE', undef: nil).convert(password + suffix)).delete!("\n")
end

#wds?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'app/models/concerns/foreman_wds/host_extensions.rb', line 60

def wds?
  managed? && wds_build? && SETTINGS[:unattended]
end

#wds_boot_imageObject



18
19
20
# File 'app/models/concerns/foreman_wds/host_extensions.rb', line 18

def wds_boot_image
  ensure_wds_facet.boot_image
end

#wds_boot_image_nameObject



22
23
24
# File 'app/models/concerns/foreman_wds/host_extensions.rb', line 22

def wds_boot_image_name
  ensure_wds_facet.boot_image_name
end

#wds_build?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'app/models/concerns/foreman_wds/host_extensions.rb', line 56

def wds_build?
  provision_method == 'wds'
end

#wds_install_imageObject



26
27
28
# File 'app/models/concerns/foreman_wds/host_extensions.rb', line 26

def wds_install_image
  ensure_wds_facet.install_image
end

#wds_install_image_fileObject



30
31
32
# File 'app/models/concerns/foreman_wds/host_extensions.rb', line 30

def wds_install_image_file
  ensure_wds_facet.install_image_file
end

#wds_install_image_groupObject



34
35
36
# File 'app/models/concerns/foreman_wds/host_extensions.rb', line 34

def wds_install_image_group
  ensure_wds_facet.install_image_group
end

#wds_install_image_nameObject



38
39
40
# File 'app/models/concerns/foreman_wds/host_extensions.rb', line 38

def wds_install_image_name
  ensure_wds_facet.install_image_name
end