Class: HostObserver

Inherits:
ActiveRecord::Observer
  • Object
show all
Defined in:
app/models/host_observer.rb

Instance Method Summary collapse

Instance Method Details

#after_validation(host) ⇒ Object

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


7
8
9
10
11
12
13
14
15
16
17
# File 'app/models/host_observer.rb', line 7

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