Class: Runcible::Extensions::Consumer
- Inherits:
-
Resources::Consumer
- Object
- Base
- Resources::Consumer
- Runcible::Extensions::Consumer
- Defined in:
- lib/runcible/extensions/consumer.rb
Class Method Summary collapse
-
.applicable_errata(ids, repoids = [], consumer_report = true) ⇒ RestClient::Response
Retrieve the set of errata that is applicable to a consumer(s).
-
.bind_all(id, repo_id, notify_agent = true) ⇒ RestClient::Response
Bind a consumer to all repositories with a given ID.
-
.generate_content(type_id, units) ⇒ Array
Generate the content units used by other functions.
-
.install_content(id, type_id, units, options = {}) ⇒ RestClient::Response
Install content to a consumer.
-
.unbind_all(id, repo_id) ⇒ RestClient::Response
Unbind a consumer to all repositories with a given ID.
-
.uninstall_content(id, type_id, units) ⇒ RestClient::Response
Uninstall content from a consumer.
-
.update_content(id, type_id, units, options = {}) ⇒ RestClient::Response
Update content on a consumer.
Methods inherited from Resources::Consumer
applicability, bind, create, delete, install_units, path, retrieve, retrieve_binding, retrieve_bindings, retrieve_profile, unbind, uninstall_units, update, update_units, upload_profile
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
.applicable_errata(ids, repoids = [], consumer_report = true) ⇒ RestClient::Response
Retrieve the set of errata that is applicable to a consumer(s)
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/runcible/extensions/consumer.rb', line 118 def self.applicable_errata(ids, repoids = [], consumer_report = true) ids = [ids] if ids.is_a? String consumer_criteria = { 'filters' => { 'id' => { '$in' => ids } } } unless ids.empty? repo_criteria = { 'filters' => { 'id' => { '$in' => repoids } } } unless repoids.empty? report_style = (consumer_report == true) ? 'by_consumer' : 'by_units' criteria = { 'consumer_criteria' => consumer_criteria, 'repo_criteria' => repo_criteria, 'unit_criteria' => { 'erratum' => { } }, 'override_config' => { 'report_style' => report_style } } self.applicability(criteria) end |
.bind_all(id, repo_id, notify_agent = true) ⇒ RestClient::Response
Bind a consumer to all repositories with a given ID
35 36 37 38 39 |
# File 'lib/runcible/extensions/consumer.rb', line 35 def self.bind_all(id, repo_id, notify_agent=true) Runcible::Extensions::Repository.retrieve_with_details(repo_id)['distributors'].collect do |d| self.bind(id, repo_id, d['id'], {:notify_agent=>notify_agent}) end.flatten end |
.generate_content(type_id, units) ⇒ Array
Generate the content units used by other functions
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/runcible/extensions/consumer.rb', line 89 def self.generate_content(type_id, units) content = [] case type_id when 'rpm', 'package_group' unit_key = :name when 'erratum' unit_key = :id else unit_key = :id end units.each do |unit| content_unit = {} content_unit[:type_id] = type_id content_unit[:unit_key] = { unit_key => unit } content.push(content_unit) end content end |
.install_content(id, type_id, units, options = {}) ⇒ RestClient::Response
Install content to a consumer
59 60 61 |
# File 'lib/runcible/extensions/consumer.rb', line 59 def self.install_content(id, type_id, units, ={}) self.install_units(id, generate_content(type_id, units), ) end |
.unbind_all(id, repo_id) ⇒ RestClient::Response
Unbind a consumer to all repositories with a given ID
46 47 48 49 50 |
# File 'lib/runcible/extensions/consumer.rb', line 46 def self.unbind_all(id, repo_id) Runcible::Extensions::Repository.retrieve_with_details(repo_id)['distributors'].collect do |d| self.unbind(id, repo_id, d['id']) end.flatten end |
.uninstall_content(id, type_id, units) ⇒ RestClient::Response
Uninstall content from a consumer
80 81 82 |
# File 'lib/runcible/extensions/consumer.rb', line 80 def self.uninstall_content(id, type_id, units) self.uninstall_units(id, generate_content(type_id, units)) end |
.update_content(id, type_id, units, options = {}) ⇒ RestClient::Response
Update content on a consumer
70 71 72 |
# File 'lib/runcible/extensions/consumer.rb', line 70 def self.update_content(id, type_id, units, ={}) self.update_units(id, generate_content(type_id, units), ) end |