Sha256: a9e250cbea072ae730bccbf47fcfdcb330ffae1b446d154a1edc50a364af286c

Contents?: true

Size: 643 Bytes

Versions: 5

Compression:

Stored size: 643 Bytes

Contents

class HostObserver < ActiveRecord::Observer
  observe Host::Base

  # Sets and expire provisioning tokens
  # this has to happen post validation and before the orchesration queue is starting to 
  # process, as the token value is required within the tftp config file manipulations
  def after_validation(host)
    return unless SETTINGS[:unattended]
    # new server in build mode
    if host.new_record? and host.build?
      host.set_token
    end
    # existing server change build mode
    if host.respond_to?(:old) and host.old and host.build? != host.old.build?
      host.build? ? host.set_token : host.expire_tokens
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/app/models/host_observer.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/app/models/host_observer.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/app/models/host_observer.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/app/models/host_observer.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/app/models/host_observer.rb