lib/runcible/extensions/repository.rb in runcible-1.0.2 vs lib/runcible/extensions/repository.rb in runcible-1.0.3
- old
+ new
@@ -58,10 +58,23 @@
else
optional[:importer_type_id] = importer.delete('id') || importer.delete(:id)
optional[:importer_config] = importer
end if importer
+ repo_type = if importer.methods.include?(repo_type)
+ importer.repo_type
+ elsif importer.is_a?(Hash) && importer.has_key?(:repo_type)
+ importer[:repo_type]
+ else
+ nil
+ end
+
+ if optional.has_key?(:importer_type_id) && repo_type
+ # pulp needs _repo-type in order to determine the type of repo to create.
+ optional[:notes] = { '_repo-type' => importer.repo_type }
+ end
+
optional[:distributors] = distributors.collect do |d|
if d.is_a?(Runcible::Models::Distributor)
{'distributor_type' => d.type_id,
"distributor_config" => d.config,
"auto_publish" => d.auto_publish,
@@ -218,9 +231,29 @@
#
# @param [String] id the ID of the repository
# @return [RestClient::Response] the set of repository package group categories
def package_categories(id)
criteria = {:type_ids=>[Runcible::Extensions::PackageCategory.content_type]}
+ unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
+ end
+
+ # Retrieves the puppet module IDs for a single repository
+ #
+ # @param [String] id the ID of the repository
+ # @return [RestClient::Response] the set of repository puppet module IDs
+ def puppet_module_ids(id)
+ criteria = {:type_ids=>[Runcible::Extensions::PuppetModule.content_type],
+ :fields=>{:unit=>[], :association=>['unit_id']}}
+
+ unit_search(id, criteria).collect{|i| i['unit_id']}
+ end
+
+ # Retrieves the puppet modules for a single repository
+ #
+ # @param [String] id the ID of the repository
+ # @return [RestClient::Response] the set of repository puppet modules
+ def puppet_modules(id)
+ criteria = {:type_ids=>[Runcible::Extensions::PuppetModule.content_type]}
unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
end
# Creates or updates a sync schedule for a repository
#