Class: Moose::Inventory::Operations::AddGroups

Inherits:
Object
  • Object
show all
Defined in:
lib/moose_inventory/operations/add_groups.rb

Overview

Adds groups and their optional host associations.

Defined Under Namespace

Classes: Event, Result

Constant Summary collapse

AUTOMATIC_GROUP =
'ungrouped'

Instance Method Summary collapse

Constructor Details

#initialize(context:) ⇒ AddGroups

Returns a new instance of AddGroups.



13
14
15
# File 'lib/moose_inventory/operations/add_groups.rb', line 13

def initialize(context:)
  @context = context
end

Instance Method Details

#call(names:, hosts:) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/moose_inventory/operations/add_groups.rb', line 17

def call(names:, hosts:)
  events = []
  warning_count = 0

  context.transaction do
    names.each do |name|
      warning_count += add_group(name, hosts, events)
    end
  end

  Result.new(events: events, warning_count: warning_count)
end