Module: Orchestration::Tofu::Compute
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/orchestration/tofu/compute.rb
Instance Method Summary collapse
Instance Method Details
#match_macs_to_nics(fog_attr) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/models/concerns/orchestration/tofu/compute.rb', line 6 def match_macs_to_nics(fog_attr) return super unless compute_resource.is_a?(ForemanOpentofu::Tofu) interfaces.select(&:physical?).each do |nic| mac = vm.send(fog_attr) logger.debug "Orchestration::Compute: nic #{nic.inspect} assigned to #{vm.inspect}" nic.mac = mac nic.reset_dhcp_record_cache if nic.respond_to?(:reset_dhcp_record_cache) # delete the cached dhcp_record with old MAC on managed nics return false unless validate_required_foreman_attr(mac, Nic::Base.physical, :mac) end true end |
#setUserData ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/concerns/orchestration/tofu/compute.rb', line 19 def setUserData return super unless compute_resource.is_a?(ForemanOpentofu::Tofu) logger.info "Rendering UserData template for #{name}" template = provisioning_template(kind: 'cloud-init') template ||= provisioning_template(kind: 'user_data') # For some reason this renders as 'built' in spoof view but 'provision' when # actually used. For now, use foreman_url('built') in the template if template.nil? # rubocop:disable Layout/LineLength failure(format(_("Image \"%{image}\" needs user data, but \"%{os}\" is not associated to any provisioning template of the kind user_data. Please associate it with a suitable template or uncheck 'User data' from the image definition."), image: image.name, os: )) # rubocop:enable Layout/LineLength return false end compute_attributes['user_data'] = render_template(template: template) return false if errors.any? true end |