Class: Runcible::Extensions::ConsumerGroup

Inherits:
Resources::ConsumerGroup show all
Defined in:
lib/runcible/extensions/consumer_group.rb

Class Method Summary collapse

Methods inherited from Resources::ConsumerGroup

associate, create, delete, install_units, path, retrieve, unassociate, uninstall_units, update_units

Methods inherited from Base

add_http_auth_header, add_oauth_header, call, combine_get_params, config, config=, generate_log_message, generate_payload, get_response, log_debug, log_exception, process_response, required_params

Class Method Details

.add_consumers_by_id(id, consumer_ids) ⇒ RestClient::Response

Add consumers by ID to a consumer group

Parameters:

  • id (String)

    the consumer group ID

  • consumer_ids (Array)

    array of consumer IDs to add to the group

Returns:

  • (RestClient::Response)

    list of consumer IDs



34
35
36
# File 'lib/runcible/extensions/consumer_group.rb', line 34

def self.add_consumers_by_id(id, consumer_ids)
  self.associate(id, make_consumer_criteria(consumer_ids))
end

.generate_content(type_id, units) ⇒ Array

Generate the content units used by other functions

Parameters:

  • type_id (String)

    the type of content (e.g. rpm, errata)

  • units (Array)

    array of units

Returns:

  • (Array)

    array of formatted content units



94
95
96
97
98
99
100
101
102
103
# File 'lib/runcible/extensions/consumer_group.rb', line 94

def self.generate_content(type_id, units)
  content = []
  units.each do |unit|
    content_unit = {}
    content_unit[:type_id] = type_id
    content_unit[:unit_key] = { :name => unit }
    content.push(content_unit)
  end
  content
end

.install_content(id, type_id, units) ⇒ RestClient::Response

Install content to a consumer group

Parameters:

  • id (String)

    the consumer group ID

  • type_id (String)

    the type of content to install (e.g. rpm, errata)

  • units (Array)

    array of units to install

Returns:

  • (RestClient::Response)

    task representing the install operation



65
66
67
# File 'lib/runcible/extensions/consumer_group.rb', line 65

def self.install_content(id, type_id, units)
  self.install_units(id, generate_content(type_id, units))
end

.make_consumer_criteria(consumer_ids) ⇒ Hash

Generates consumer criteria query

Parameters:

  • consumer_ids (Array)

    array of consumer IDs

Returns:

  • (Hash)

    the formatted query for consumers



51
52
53
54
55
56
57
# File 'lib/runcible/extensions/consumer_group.rb', line 51

def self.make_consumer_criteria(consumer_ids)
  {:criteria =>
        {:filters =>
          {:id =>{"$in" =>consumer_ids}}
        }
  }
end

.remove_consumers_by_id(id, consumer_ids) ⇒ RestClient::Response

Remove consumers by ID from a consumer group

Parameters:

  • id (String)

    the consumer group ID

  • consumer_ids (Array)

    array of consumer IDs to remove from the group

Returns:

  • (RestClient::Response)

    list of consumer IDs



43
44
45
# File 'lib/runcible/extensions/consumer_group.rb', line 43

def self.remove_consumers_by_id(id, consumer_ids)
  self.unassociate(id, make_consumer_criteria(consumer_ids))
end

.uninstall_content(id, type_id, units) ⇒ RestClient::Response

Uninstall content from a consumer group

Parameters:

  • id (String)

    the consumer group ID

  • type_id (String)

    the type of content to uninstall (e.g. rpm, errata)

  • units (Array)

    array of units to uninstall

Returns:

  • (RestClient::Response)

    task representing the uninstall operation



85
86
87
# File 'lib/runcible/extensions/consumer_group.rb', line 85

def self.uninstall_content(id, type_id, units)
  self.uninstall_units(id, generate_content(type_id, units))
end

.update_content(id, type_id, units) ⇒ RestClient::Response

Update content on a consumer group

Parameters:

  • id (String)

    the consumer group ID

  • type_id (String)

    the type of content to update (e.g. rpm, errata)

  • units (Array)

    array of units to update

Returns:

  • (RestClient::Response)

    task representing the update operation



75
76
77
# File 'lib/runcible/extensions/consumer_group.rb', line 75

def self.update_content(id, type_id, units)
  self.update_units(id, generate_content(type_id, units))
end