Class: Actions::Katello::ContentViewEnvironment::Destroy

Inherits:
Base
  • Object
show all
Defined in:
app/lib/actions/katello/content_view_environment/destroy.rb

Instance Method Summary collapse

Instance Method Details

#finalizeObject



27
28
29
30
31
32
33
34
# File 'app/lib/actions/katello/content_view_environment/destroy.rb', line 27

def finalize
  cv_env = ::Katello::ContentViewEnvironment.find_by(:id => input[:id])
  if cv_env.nil?
    output[:response] = "Content view with ID #{input[:id]} is (probably) already deleted"
  else
    cv_env.destroy!
  end
end

#plan(cv_env, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/lib/actions/katello/content_view_environment/destroy.rb', line 5

def plan(cv_env, options = {})
  skip_repo_destroy = options.fetch(:skip_repo_destroy, false)
  organization_destroy = options.fetch(:organization_destroy, false)
  content_view = cv_env.content_view
  environment = cv_env.environment
  content_view.check_remove_from_environment!(environment) unless organization_destroy

  sequence do
    concurrence do
      unless skip_repo_destroy
        content_view.repos(environment).each do |repo|
          # no need to update the content view environment since it's
          # getting destroyed so skip_environment_update
          plan_action(Repository::Destroy, repo, skip_environment_update: true)
        end
      end
    end
    plan_action(Candlepin::Environment::Destroy, cp_id: cv_env.cp_id) unless organization_destroy
    plan_self(:id => cv_env.id)
  end
end