lib/runcible/extensions/consumer.rb in runcible-0.4.12 vs lib/runcible/extensions/consumer.rb in runcible-1.0.0
- old
+ new
@@ -30,66 +30,66 @@
#
# @param [String] id the consumer ID
# @param [String] repo_id the repo ID to bind to
# @param [Boolean] notify_agent sends consumer a notification
# @return [RestClient::Response] set of tasks representing each bind operation
- 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})
+ def bind_all(id, repo_id, notify_agent=true)
+ repository_extension.retrieve_with_details(repo_id)['distributors'].collect do |d|
+ bind(id, repo_id, d['id'], {:notify_agent=>notify_agent})
end.flatten
end
# Unbind a consumer to all repositories with a given ID
#
# @param [String] id the consumer ID
# @param [String] repo_id the repo ID to unbind from
# @return [RestClient::Response] set of tasks representing each unbind operation
- 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'])
+ def unbind_all(id, repo_id)
+ repository_extension.retrieve_with_details(repo_id)['distributors'].collect do |d|
+ unbind(id, repo_id, d['id'])
end.flatten
end
# Install content to a consumer
#
# @param [String] id the consumer ID
# @param [String] type_id the type of content to install (e.g. rpm, errata)
# @param [Array] units array of units to install
# @param [Hash] options to pass to content install
# @return [RestClient::Response] task representing the install operation
- def self.install_content(id, type_id, units, options={})
- self.install_units(id, generate_content(type_id, units), options)
+ def install_content(id, type_id, units, options={})
+ install_units(id, generate_content(type_id, units), options)
end
# Update content on a consumer
#
# @param [String] id the consumer ID
# @param [String] type_id the type of content to update (e.g. rpm, errata)
# @param [Array] units array of units to update
# @param [Hash] options to pass to content update
# @return [RestClient::Response] task representing the update operation
- def self.update_content(id, type_id, units, options={})
- self.update_units(id, generate_content(type_id, units, options), options)
+ def update_content(id, type_id, units, options={})
+ update_units(id, generate_content(type_id, units, options), options)
end
# Uninstall content from a consumer
#
# @param [String] id the consumer ID
# @param [String] type_id the type of content to uninstall (e.g. rpm, errata)
# @param [Array] units array of units to uninstall
# @return [RestClient::Response] task representing the uninstall operation
- def self.uninstall_content(id, type_id, units)
- self.uninstall_units(id, generate_content(type_id, units))
+ def uninstall_content(id, type_id, units)
+ uninstall_units(id, generate_content(type_id, units))
end
# Generate the content units used by other functions
#
# @param [String] type_id the type of content (e.g. rpm, errata)
# @param [Array] units array of units
# @param [Hash] options contains options which may impact the format of the content (e.g :all => true)
# @return [Array] array of formatted content units
- def self.generate_content(type_id, units, options={})
+ def generate_content(type_id, units, options={})
content = []
case type_id
when 'rpm', 'package_group'
unit_key = :name
@@ -121,11 +121,11 @@
# @param [Array] repoids array of repository ids
# @param [Boolean] consumer_report if true, result will list consumers and their
# applicable errata; otherwise, it will list
# errata and the consumers they are applicable to
# @return [RestClient::Response] content applicability hash with details of errata available to consumer(s)
- def self.applicable_errata(ids, repoids = [], consumer_report = true)
+ 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'
@@ -134,10 +134,17 @@
'consumer_criteria' => consumer_criteria,
'repo_criteria' => repo_criteria,
'unit_criteria' => { 'erratum' => { } },
'override_config' => { 'report_style' => report_style }
}
- self.applicability(criteria)
+ applicability(criteria)
+ end
+
+
+ private
+
+ def repository_extension
+ Runcible::Extensions::Repository.new(self.config)
end
end
end
end