Module: Content::HostExtensions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/content/host_extensions.rb
Instance Method Summary collapse
- #all_content_view_ids ⇒ Object
- #all_product_ids ⇒ Object
- #attached_repositories ⇒ Object
- #inherited_content_view_ids ⇒ Object
-
#inherited_product_ids ⇒ Object
product_ids from the os default and hostgroup.
-
#params_with_repositories ⇒ Object
adds repository hash to ENC global parameters.
Instance Method Details
#all_content_view_ids ⇒ Object
44 45 46 |
# File 'app/models/concerns/content/host_extensions.rb', line 44 def all_content_view_ids (inherited_content_view_ids + content_view_ids).uniq end |
#all_product_ids ⇒ Object
32 33 34 |
# File 'app/models/concerns/content/host_extensions.rb', line 32 def all_product_ids (inherited_product_ids + product_ids).uniq end |
#attached_repositories ⇒ Object
48 49 50 51 |
# File 'app/models/concerns/content/host_extensions.rb', line 48 def attached_repositories return [] if all_content_view_ids.empty? Content::RepositoryClone.for_content_views(all_content_view_ids) end |
#inherited_content_view_ids ⇒ Object
36 37 38 39 40 41 42 |
# File 'app/models/concerns/content/host_extensions.rb', line 36 def inherited_content_view_ids return [] if hostgroup_id.nil? or environment_id.nil? Content::ContentView.joins(:available_content_views). where(:content_available_content_views => {:environment_id => environment_id}). where(:originator_type => 'Hostgroup', :originator_id => hostgroup_id).pluck('content_content_views.id') end |
#inherited_product_ids ⇒ Object
product_ids from the os default and hostgroup.
25 26 27 28 29 30 |
# File 'app/models/concerns/content/host_extensions.rb', line 25 def inherited_product_ids products = [] products += .product_ids if products += Content::HostgroupProduct.where(:hostgroup_id => hostgroup.path_ids).pluck(:product_id) if hostgroup_id products.uniq end |
#params_with_repositories ⇒ Object
adds repository hash to ENC global parameters
17 18 19 20 21 22 |
# File 'app/models/concerns/content/host_extensions.rb', line 17 def params_with_repositories # convert all repos to a format that puppet create_resource with yumrepo can consume repos = Hash[attached_repositories.map { |repo| [repo.to_label, format_repo(repo)] }] # adds a global parameter called repositories contain all repos params_without_repositories.merge('repositories' => repos) end |