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) ⇒ 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.
-
#regenerate_applicability_by_ids(ids) ⇒ RestClient::Response
Regenerate the applicability for a set of consumers.
-
#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, #regenerate_applicability, #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, #format_payload_json, #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) ⇒ RestClient::Response
Retrieve the set of errata that is applicable to a consumer(s)
172 173 174 175 176 177 178 179 180 |
# File 'lib/runcible/extensions/consumer.rb', line 172 def applicable_errata(ids) ids = [ids] if ids.is_a? String criteria = { 'criteria' => { 'filters' => { 'id' => { '$in' => ids } } }, 'content_types' => [Runcible::Extensions::Errata.content_type] } 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 146 147 148 149 150 151 |
# 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 if unit.is_a?(Hash) #allow user to pass in entire unit content_unit[:unit_key] = unit else content_unit[:unit_key] = { unit_key => unit } end 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 |
#regenerate_applicability_by_ids(ids) ⇒ RestClient::Response
Regenerate the applicability for a set of consumers
157 158 159 160 161 162 |
# File 'lib/runcible/extensions/consumer.rb', line 157 def regenerate_applicability_by_ids(ids) criteria = { 'consumer_criteria' => { 'filters' => { 'id' => { '$in' => ids } } } } regenerate_applicability(criteria) 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 |