-
Notifications
You must be signed in to change notification settings - Fork 284
/
bulk_actions.rb
65 lines (56 loc) · 1.89 KB
/
bulk_actions.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
module Katello
class BulkActions
attr_accessor :systems
def initialize(systems)
self.systems = systems
end
def install_packages(packages)
fail Errors::HostCollectionEmptyException if self.systems.empty?
perform_bulk_action do |consumer_group|
consumer_group.install_package(packages)
end
end
def uninstall_packages(packages)
fail Errors::HostCollectionEmptyException if self.systems.empty?
perform_bulk_action do |consumer_group|
consumer_group.uninstall_package(packages)
end
end
def update_packages(packages = nil)
# if no packages are provided, a full system update will be performed (e.g ''yum update' equivalent)
fail Errors::HostCollectionEmptyException if self.systems.empty?
perform_bulk_action do |consumer_group|
consumer_group.update_package(packages)
end
end
def install_package_groups(groups)
fail Errors::HostCollectionEmptyException if self.systems.empty?
perform_bulk_action do |consumer_group|
consumer_group.install_package_group(groups)
end
end
def update_package_groups(groups)
fail Errors::HostCollectionEmptyException if self.systems.empty?
perform_bulk_action do |consumer_group|
consumer_group.install_package_group(groups)
end
end
def uninstall_package_groups(groups)
fail Errors::HostCollectionEmptyException if self.systems.empty?
perform_bulk_action do |consumer_group|
consumer_group.uninstall_package_group(groups)
end
end
private
def perform_bulk_action
consumer_ids = self.systems.collect { |i| i.uuid }
group = Glue::Pulp::ConsumerGroup.new
group.pulp_id = SecureRandom.uuid
group.consumer_ids = consumer_ids
group.set_pulp_consumer_group
yield(group)
ensure
group.del_pulp_consumer_group
end
end
end