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
|
# File 'lib/confctl/cli/generation.rb', line 11
def remove
machines = select_machines(args[0])
gens = select_generations(machines, args[1])
changed_hosts = []
if gens.empty?
puts 'No generations found'
return
end
ask_confirmation! do
puts 'The following generations will be removed:'
list_generations(gens)
puts
puts "Garbage collection: #{opts[:remote] && opts[:gc] ? 'yes' : 'no'}"
end
gens.each do |gen|
puts "Removing #{gen.presence_str} generation #{gen.host}@#{gen.name}"
gen.destroy
changed_hosts << gen.host unless changed_hosts.include?(gen.host)
end
return unless opts[:remote] && opts[:gc]
machines_gc = {}
machines.each do |host, machine|
next unless changed_hosts.include?(host)
m =
if machine.carried?
machine.carrier_machine
else
machine
end
machines_gc[m.name] = m if m.target_host
end
run_gc(ConfCtl::MachineList.new(machines: machines_gc))
end
|