Class: Katello::Events::DeleteLatestContentViewVersion

Inherits:
Object
  • Object
show all
Defined in:
app/models/katello/events/delete_latest_content_view_version.rb

Constant Summary collapse

EVENT_TYPE =
'delete_latest_content_view_version'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content_view_id) {|_self| ... } ⇒ DeleteLatestContentViewVersion

Returns a new instance of DeleteLatestContentViewVersion.

Yields:

  • (_self)

Yield Parameters:



13
14
15
16
17
# File 'app/models/katello/events/delete_latest_content_view_version.rb', line 13

def initialize(content_view_id)
  @content_view = ::Katello::ContentView.find_by_id(content_view_id)
  Rails.logger.warn "Content View not found for ID #{object_id}" if @content_view.nil?
  yield(self) if block_given?
end

Instance Attribute Details

#content_viewObject (readonly)

Returns the value of attribute content_view.



6
7
8
# File 'app/models/katello/events/delete_latest_content_view_version.rb', line 6

def content_view
  @content_view
end

#metadataObject

Returns the value of attribute metadata.



7
8
9
# File 'app/models/katello/events/delete_latest_content_view_version.rb', line 7

def 
  @metadata
end

#retryObject

Returns the value of attribute retry.



7
8
9
# File 'app/models/katello/events/delete_latest_content_view_version.rb', line 7

def retry
  @retry
end

Class Method Details

.retry_secondsObject



9
10
11
# File 'app/models/katello/events/delete_latest_content_view_version.rb', line 9

def self.retry_seconds
  18
end

Instance Method Details

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/katello/events/delete_latest_content_view_version.rb', line 19

def run
  return unless content_view

  begin
    ForemanTasks.async_task(::Actions::Katello::ContentView::Remove, content_view,
                  content_view_versions: [content_view.latest_version_object],
                  content_view_environments: content_view.latest_version_object.content_view_environments)
  rescue => e
    self.retry = true if e.is_a?(ForemanTasks::Lock::LockConflict)
    deliver_failure_notification
    raise e
  end
end