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 #11872 - Compliance status for hosts #131
Conversation
@xprazak2 - please rebase |
d488d21
to
c05ada0
Compare
@shlomizadok: I rebased |
Quick scan looks good, I'd like to give it another round and test later. Don't forget to either bump https://github.com/theforeman/foreman_openscap/blob/master/lib/foreman_openscap/engine.rb#L38 to 1.10 or wrap the status registration in a condition to keep 1.9- compatibility.
It should be added automatically, did you check the host detail output? |
@@ -8,6 +8,7 @@ module HostExtensions | |||
has_many :asset_policies, :through => :asset, :class_name => "::ForemanOpenscap::AssetPolicy" | |||
has_many :policies, :through => :asset_policies, :class_name => "::ForemanOpenscap::Policy" | |||
has_many :arf_reports, :through => :asset, :class_name => '::ForemanOpenscap::ArfReport' | |||
has_one :scap_status, :class_name => 'HostStatus::ScapStatus', :foreign_key => 'host_id', :dependent => :destroy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does :dependent => :destroy
play nicely with host_statuses that also defines this dependency? (https://github.com/theforeman/foreman/blob/develop/app/models/host/managed.rb#L17) this has_one is subset of host_statuses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it would be probably better to remove it
5dee2d2
to
d0f7c01
Compare
@ares, I removed |
@@ -8,6 +8,7 @@ module HostExtensions | |||
has_many :asset_policies, :through => :asset, :class_name => "::ForemanOpenscap::AssetPolicy" | |||
has_many :policies, :through => :asset_policies, :class_name => "::ForemanOpenscap::Policy" | |||
has_many :arf_reports, :through => :asset, :class_name => '::ForemanOpenscap::ArfReport' | |||
has_one :compliance_status, :class_name => 'HostStatus::ComplianceStatus', :foreign_key => 'host_id' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be named compliace_status_object
, you override it by method with same name below https://github.com/theforeman/foreman_openscap/pull/131/files#diff-c08b2f64bbed0d7a15b0f7241af53d04R50
d0f7c01
to
e82eeb9
Compare
@ares: I changed compliance_status to compliance_status_object |
@@ -8,6 +8,7 @@ module HostExtensions | |||
has_many :asset_policies, :through => :asset, :class_name => "::ForemanOpenscap::AssetPolicy" | |||
has_many :policies, :through => :asset_policies, :class_name => "::ForemanOpenscap::Policy" | |||
has_many :arf_reports, :through => :asset, :class_name => '::ForemanOpenscap::ArfReport' | |||
has_one :compliance_status_object, :class_name => 'HostStatus::ComplianceStatus', :foreign_key => 'host_id' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this association is usually used in scoped search, but I don't see any new definitions in the PR, could you add some? see https://github.com/theforeman/foreman_remote_execution/pull/42/files#diff-e3b1be04f41d99a66e199b0060b84e63R14 for an example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ares: I added scoped search on compliance status
next time pls write a comment to original one so we can see that it's addressed
EDIT: unless it's outdated by git change, then it's optional...
e82eeb9
to
d7bf3ff
Compare
@ares: I added scoped search on compliance status |
@@ -0,0 +1,46 @@ | |||
module HostStatus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be also under ForemanOpenscap
module and hence in app/models/foreman_openscap/host_status (host status might not be needed, but leaving this up to you)
This can happen in development if rails autoloader reloads the code. Restart Foreman and see if it helps, it seems to work for me. The reason is that we refer to class name in engine.rb in initializer (the way that Foreman plugin currently works) but we should do it in |
defafd3
to
890a913
Compare
scoped_search :in => :compliance_status_object, :on => :status, :rename => :compliance_status, | ||
:complete_value => {:compliant => ForemanOpenscap::::ComplianceStatus::COMPLIANT, | ||
:incompliant => ForemanOpenscap::::ComplianceStatus::INCOMPLIANT, | ||
:inconclusive => ForemanOpenscap::::ComplianceStatus::INCONCLUSIVE} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/home/ares/Projekty/Zdrojaky/foreman_openscap/app/models/concerns/foreman_openscap/host_extensions.rb:18: syntax error, unexpected ::, expecting '(' (SyntaxError)
...ompliant => ForemanOpenscap::::ComplianceStatus::COMPLIANT,
...
8a30df7
to
d8a2730
Compare
@@ -8,11 +8,16 @@ module HostExtensions | |||
has_many :asset_policies, :through => :asset, :class_name => "::ForemanOpenscap::AssetPolicy" | |||
has_many :policies, :through => :asset_policies, :class_name => "::ForemanOpenscap::Policy" | |||
has_many :arf_reports, :through => :asset, :class_name => '::ForemanOpenscap::ArfReport' | |||
has_one :compliance_status_object, :class_name => 'ForemanOpenscap::::ComplianceStatus', :foreign_key => 'host_id' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another syntax error
d8a2730
to
8758cb8
Compare
@xprazak2 - Not sure if it's this PR or previous, yet my dashboard now looks like: Also, rubocop is failing. Thanks |
8758cb8
to
c7a975f
Compare
c7a975f
to
94a859b
Compare
Merging. Thanks @xprazak2 ! |
Fixes #11872 - Compliance status for hosts
Current behaviour:
Changes in UI:
Questions and thoughts: