Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #14251 - properly katello-agent status for content hosts #5896

Merged
merged 1 commit into from
Mar 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/katello/host/content_facet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def available_releases
self.content_view.version(self.lifecycle_environment).available_releases
end

def katello_agent_installed?
self.host.installed_packages.where("#{Katello::InstalledPackage.table_name}.name" => 'katello-agent').any?
end

private

def insert_errata_applicability(uuids)
Expand Down
4 changes: 4 additions & 0 deletions app/views/katello/api/v2/content_facet/show.json.rabl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ child :content_facet => :content do
node :lifecycle_environment_library? do |content_facet|
content_facet.lifecycle_environment.library?
end

node :katello_agent_installed do |content_facet|
content_facet.katello_agent_installed?
end
end

child :host_collections => :host_collections do
Expand Down
8 changes: 8 additions & 0 deletions test/models/host/content_facet_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ def test_protected_content_facet_attributes
assert ::Host.new(:name => "foo", :content_facet_attributes => {:uuid => "thisshouldntbeabletobesetbyuser"})
end
end

def test_katello_agent_installed?
refute host.content_facet.katello_agent_installed?

host.installed_packages << Katello::InstalledPackage.create!(:name => 'katello-agent', 'nvra' => 'katello-agent-1.0.x86_64')

assert host.reload.content_facet.katello_agent_installed?
end
end

class ContentFacetErrataTest < ContentFacetBase
Expand Down