Revision ff4bacab
Added by Petr Chalupa over 10 years ago
app/lib/actions/headpin/system/create.rb | ||
---|---|---|
capabiliteis: system.capabilities)
|
||
system.save!
|
||
action_subject system, uuid: cp_create.output[:response][:uuid]
|
||
plan_self
|
||
plan_action ElasticSearch::Reindex, system
|
||
end
|
||
|
app/lib/actions/helpers/presenter.rb | ||
---|---|---|
module Actions
|
||
module Helpers
|
||
# Delegate task information to presenter object
|
||
module Presenter
|
||
module Presenter # TODO rename to Presented?
|
||
|
||
def presenter
|
||
fail NotImplementedError
|
||
... | ... | |
end
|
||
|
||
class Base
|
||
include Algebrick::TypeCheck
|
||
|
||
attr_reader :action
|
||
|
||
... | ... | |
|
||
# Use sub-actions for presenting the data of the task
|
||
class Delegated < Base
|
||
|
||
def initialize(action, *delegated_action_classes)
|
||
@delegated_actions = action.execution_plan.actions.find_all do |subaction|
|
||
delegated_action_classes.any? do |action_class|
|
||
subaction.is_a? action_class
|
||
end
|
||
end
|
||
def initialize(action, delegated_actions)
|
||
(Type! delegated_actions, Array).all? { |a| Type! a, Presenter }
|
||
@delegated_actions = delegated_actions
|
||
end
|
||
|
||
def humanized_output
|
||
@delegated_actions.map(&:humanized_output).compact.join("\n")
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/lib/actions/katello/repository/sync.rb | ||
---|---|---|
end
|
||
|
||
def humanized_name
|
||
_("Synchronize")
|
||
_("Synchronize") # TODO rename class to Synchronize and remove this method, add Sync = Synchronize
|
||
end
|
||
|
||
def presenter
|
||
Helpers::Presenter::Delegated.new(self, Pulp::Repository::Sync)
|
||
Helpers::Presenter::Delegated.new(self, planned_actions(Pulp::Repository::Sync))
|
||
end
|
||
end
|
||
end
|
app/lib/actions/katello/system/package/install.rb | ||
---|---|---|
end
|
||
|
||
def presenter
|
||
Helpers::Presenter::Delegated.new(self, Pulp::Consumer::ContentInstall)
|
||
Helpers::Presenter::Delegated.new(self, planned_actions(Pulp::Consumer::ContentInstall))
|
||
end
|
||
end
|
||
end
|
app/lib/actions/katello/system/package/remove.rb | ||
---|---|---|
action_subject(system, :packages => packages)
|
||
plan_action(Pulp::Consumer::ContentUninstall,
|
||
consumer_uuid: system.uuid,
|
||
type: 'rpm',
|
||
args: packages)
|
||
type: 'rpm',
|
||
args: packages)
|
||
end
|
||
|
||
def humanized_name
|
||
... | ... | |
end
|
||
|
||
def humanized_input
|
||
[input[:packages].join(", ")] + super
|
||
[input[:packages].join(', ')] + super
|
||
end
|
||
|
||
def presenter
|
||
Helpers::Presenter::Delegated.new(self, Pulp::Consumer::ContentUninstall)
|
||
Helpers::Presenter::Delegated.new(
|
||
self, planned_actions(Pulp::Consumer::ContentUninstall))
|
||
end
|
||
|
||
end
|
test/actions/katello/repository_test.rb | ||
---|---|---|
describe 'progress' do
|
||
let :action do
|
||
create_action(action_class).tap do |action|
|
||
# TODO DRY this pattern
|
||
action.execution_plan.stubs(actions: [pulp_action])
|
||
action.stubs(planned_actions: [pulp_action])
|
||
end
|
||
end
|
||
|
test/actions/katello/system/package_test.rb | ||
---|---|---|
describe '#humanized_output' do
|
||
let :action do
|
||
create_action(action_class).tap do |action|
|
||
action.execution_plan.stubs(actions: [pulp_action])
|
||
action.stubs(planned_actions: [pulp_action])
|
||
end
|
||
end
|
||
let(:pulp_action) { fixture_action(pulp_action_class, output: fixture_variant) }
|
||
... | ... | |
|
||
describe '#humanized_output' do
|
||
let :action do
|
||
create_action(action_class).tap do |action|
|
||
action.execution_plan.stubs(actions: [pulp_action])
|
||
create_action_presentation(action_class).tap do |action|
|
||
action.stubs(planned_actions: [pulp_action])
|
||
end
|
||
end
|
||
let(:pulp_action) { fixture_action(pulp_action_class, output: fixture_variant) }
|
Also available in: Unified diff
Update to latest ForemanTasks