Class: Runcible::Extensions::Consumer
- Inherits:
-
Resources::Consumer
- Object
- Base
- Resources::Consumer
- Runcible::Extensions::Consumer
- Defined in:
- lib/runcible/extensions/consumer.rb
Instance Method Summary collapse
-
#activate_node(id, update_strategy = "additive") ⇒ RestClient::Response
Activate a consumer as a pulp node.
-
#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, type_id, options = {}) ⇒ RestClient::Response
Bind a consumer to all repositories with a given ID.
-
#deactivate_node(id) ⇒ RestClient::Response
Deactivate a consumer as a pulp node.
-
#generate_content(type_id, units, options = {}) ⇒ 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, type_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, #generate_log_message, #generate_payload, #get_response, #initialize, #lazy_config=, #log_debug, #log_exception, #logger, #path, #process_response, #required_params
Constructor Details
This class inherits a constructor from Runcible::Base
Instance Method Details
#activate_node(id, update_strategy = "additive") ⇒ RestClient::Response
Activate a consumer as a pulp node
61 62 63 64 65 |
# File 'lib/runcible/extensions/consumer.rb', line 61 def activate_node(id, update_strategy="additive") delta = {:notes=>{'_child-node' => true, '_node-update-strategy' => update_strategy}} self.update(id, delta) end |
#applicable_errata(ids, repoids = [], consumer_report = true) ⇒ RestClient::Response
Retrieve the set of errata that is applicable to a consumer(s)
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/runcible/extensions/consumer.rb', line 155 def 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 } } applicability(criteria) end |
#bind_all(id, repo_id, type_id, options = {}) ⇒ RestClient::Response
Bind a consumer to all repositories with a given ID
38 39 40 41 42 |
# File 'lib/runcible/extensions/consumer.rb', line 38 def bind_all(id, repo_id, type_id, ={}) repository_extension.retrieve_with_details(repo_id)['distributors'].collect do |d| bind(id, repo_id, d['id'], ) if d['distributor_type_id'] == type_id end.reject{|f| f.nil?}.flatten end |
#deactivate_node(id) ⇒ RestClient::Response
Deactivate a consumer as a pulp node
71 72 73 74 75 |
# File 'lib/runcible/extensions/consumer.rb', line 71 def deactivate_node(id) delta = {:notes=>{'child-node' => nil, 'update_strategy' => nil}} self.update(id, :delta=>delta) end |
#generate_content(type_id, units, options = {}) ⇒ Array
Generate the content units used by other functions
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/runcible/extensions/consumer.rb', line 115 def generate_content(type_id, units, ={}) content = [] case type_id when 'rpm', 'package_group' unit_key = :name when 'erratum' unit_key = :id when 'repository' unit_key = :repo_id else unit_key = :id end if [:all] content_unit = {} content_unit[:type_id] = type_id content_unit[:unit_key] = {} content.push(content_unit) elsif units.nil? content = [{:unit_key=> nil, :type_id=>type_id}] else units.each do |unit| content_unit = {} content_unit[:type_id] = type_id content_unit[:unit_key] = { unit_key => unit } content.push(content_unit) end end content end |
#install_content(id, type_id, units, options = {}) ⇒ RestClient::Response
Install content to a consumer
84 85 86 |
# File 'lib/runcible/extensions/consumer.rb', line 84 def install_content(id, type_id, units, ={}) install_units(id, generate_content(type_id, units), ) end |
#unbind_all(id, repo_id, type_id) ⇒ RestClient::Response
Unbind a consumer to all repositories with a given ID
50 51 52 53 54 |
# File 'lib/runcible/extensions/consumer.rb', line 50 def unbind_all(id, repo_id, type_id) repository_extension.retrieve_with_details(repo_id)['distributors'].collect do |d| unbind(id, repo_id, d['id']) if d['distributor_type_id'] == type_id end.reject{|f| f.nil?}.flatten end |
#uninstall_content(id, type_id, units) ⇒ RestClient::Response
Uninstall content from a consumer
105 106 107 |
# File 'lib/runcible/extensions/consumer.rb', line 105 def uninstall_content(id, type_id, units) uninstall_units(id, generate_content(type_id, units)) end |
#update_content(id, type_id, units, options = {}) ⇒ RestClient::Response
Update content on a consumer
95 96 97 |
# File 'lib/runcible/extensions/consumer.rb', line 95 def update_content(id, type_id, units, ={}) update_units(id, generate_content(type_id, units, ), ) end |