Module: Katello::Glue::InstanceMethods

Defined in:
app/models/katello/glue.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject

we override the destroy method, in order to ensure our queue exists before other callbacks and to process the queue only if we found no errors



77
78
79
80
81
82
# File 'app/models/katello/glue.rb', line 77

def destroy
  @orchestration_for ||= :destroy
  pre_queue
  post_queue
  super
end

#on_destroyObject



30
31
32
33
34
35
36
37
38
39
# File 'app/models/katello/glue.rb', line 30

def on_destroy
  return false unless errors.empty?

  Glue.logger.debug "Processing on destroy pre-queue: #{pre_queue.to_log}" if pre_queue.count > 0
  process(pre_queue)
  yield if block_given?
  Glue.logger.debug "Processing on destroy post-queue: #{post_queue.to_log}" if post_queue.count > 0
  process post_queue
  @orchestration_for = nil
end

#on_saveObject



21
22
23
24
25
26
27
28
# File 'app/models/katello/glue.rb', line 21

def on_save
  Glue.logger.debug "Processing on save pre-queue: #{pre_queue.to_log}" if pre_queue.count > 0
  process pre_queue
  yield if block_given?
  Glue.logger.debug "Processing on save post-queue: #{post_queue.to_log}" if post_queue.count > 0
  process post_queue
  @orchestration_for = nil
end

#orchestration_forObject

type of operation for this orchestration, ie: crud, product promotion



42
43
44
# File 'app/models/katello/glue.rb', line 42

def orchestration_for
  @orchestration_for ||= new_record? ? :create : :update
end

#orchestration_for=(val) ⇒ Object



46
47
48
# File 'app/models/katello/glue.rb', line 46

def orchestration_for=(val)
  @orchestration_for = val.to_sym
end

#post_queueObject



61
62
63
# File 'app/models/katello/glue.rb', line 61

def post_queue
  @post_queue ||= Glue::Queue.new(pre_queue)
end

#pre_queueObject



57
58
59
# File 'app/models/katello/glue.rb', line 57

def pre_queue
  @pre_queue ||= Glue::Queue.new
end

#proxy_error(e) ⇒ Object



84
85
86
# File 'app/models/katello/glue.rb', line 84

def proxy_error(e)
  (e.respond_to?(:response) && !e.response.nil?) ? e.response : e
end

#rollbackObject



50
51
52
53
54
55
# File 'app/models/katello/glue.rb', line 50

def rollback
  Glue.logger.warning "Rollback initiated"
  Glue.logger.warning "Before rollback pre-queue: #{pre_queue.to_log}"
  Glue.logger.warning "Before rollback post-queue: #{post_queue.to_log}"
  fail ActiveRecord::Rollback
end

#valid?(context = nil) ⇒ Boolean

we override this method in order to include checking the after validation callbacks status, as rails by default does not care about their return status.

Returns:

  • (Boolean)


70
71
72
73
# File 'app/models/katello/glue.rb', line 70

def valid?(context = nil)
  super
  errors.empty?
end