Class: Actions::Katello::Environment::Destroy

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

Instance Method Summary collapse

Instance Method Details

#finalizeObject



42
43
44
45
46
47
48
49
# File 'app/lib/actions/katello/environment/destroy.rb', line 42

def finalize
  environment = ::Katello::KTEnvironment.find(input['kt_environment']['id'])

  # CapsuleLifecycleEnvironment can cause issues when auditing, it will try to associate the audit to the deleted taxonomy
  ::Katello::CapsuleLifecycleEnvironment.without_auditing do
    environment.destroy!
  end
end

#humanized_inputObject



38
39
40
# File 'app/lib/actions/katello/environment/destroy.rb', line 38

def humanized_input
  ["'#{input['kt_environment']['name']}'"] + super
end

#humanized_nameObject



34
35
36
# File 'app/lib/actions/katello/environment/destroy.rb', line 34

def humanized_name
  _("Delete Lifecycle Environment")
end

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



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/lib/actions/katello/environment/destroy.rb', line 12

def plan(env, options = {})
  fail env.errors.full_messages.join(" ") unless env.deletable?

  skip_repo_destroy = options.fetch(:skip_repo_destroy, false)
  organization_destroy = options.fetch(:organization_destroy, false)
  sequence do
    action_subject(env)

    concurrence do
      env.content_view_environments.each do |cve|
        plan_action(ContentView::Remove, cve.content_view, :content_view_environments => [cve], :skip_repo_destroy => skip_repo_destroy, :organization_destroy => organization_destroy)
      end
    end

    if organization_destroy
      env.delete_host_and_hostgroup_associations
    end

    plan_self
  end
end