Class: Moose::Inventory::Operations::RemoveHosts
- Inherits:
-
Object
- Object
- Moose::Inventory::Operations::RemoveHosts
- Includes:
- OperationEventSupport
- Defined in:
- lib/moose_inventory/operations/remove_hosts.rb
Overview
Removes hosts and returns structured progress/warning events.
Instance Method Summary collapse
- #call(names:, dry_run: false) ⇒ Object
-
#initialize(context:) ⇒ RemoveHosts
constructor
A new instance of RemoveHosts.
Constructor Details
#initialize(context:) ⇒ RemoveHosts
Returns a new instance of RemoveHosts.
12 13 14 |
# File 'lib/moose_inventory/operations/remove_hosts.rb', line 12 def initialize(context:) @context = context end |
Instance Method Details
#call(names:, dry_run: false) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/moose_inventory/operations/remove_hosts.rb', line 16 def call(names:, dry_run: false) events = [] warning_count = 0 @dry_run = dry_run if dry_run names.each do |name| warning_count += remove_host(name, events) end emit(events, :dry_run_summary) return operation_result(events: events, warning_count: warning_count) end context.transaction do names.each do |name| warning_count += remove_host(name, events) end end operation_result(events: events, warning_count: warning_count) end |