-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compliance information to a server
- Loading branch information
1 parent
cf06313
commit 94a37f5
Showing
8 changed files
with
249 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...odels/manageiq/providers/lenovo/physical_infra_manager/parser/compliance_policy_parser.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module ManageIQ::Providers::Lenovo | ||
class PhysicalInfraManager::Parser::CompliancePolicyParser < PhysicalInfraManager::Parser::ComponentParser | ||
COMPLIANCE_NAME = 'No policy assigned'.freeze | ||
COMPLIANCE_STATUS = { | ||
'no' => 'Non-compliant', | ||
'yes' => 'Compliant', | ||
'' => 'None' | ||
}.freeze | ||
|
||
class << self | ||
def parse_compliance_policy(compliance_policies) | ||
parse_to_hash(compliance_policies) | ||
end | ||
|
||
private | ||
|
||
def map_by_uuid(collection) | ||
collection.collect do |result| | ||
policy_name = result['policyName'] | ||
data = { | ||
:policy_name => policy_name.empty? ? COMPLIANCE_NAME : policy_name, | ||
:status => "#{COMPLIANCE_STATUS[result['endpointCompliant']]} #{result['message'].join(', ')}".strip, | ||
} | ||
# Return a tuple [key, value] for each result | ||
[result['uuid'], data] | ||
end.to_h | ||
end | ||
|
||
def parse_to_hash(persisted_results) | ||
persisted_results.collect do |persisted_result| | ||
if persisted_result.xITEs.present? | ||
map_by_uuid(persisted_result.xITEs) | ||
elsif persisted_result.racklist.present? | ||
map_by_uuid(persisted_result.racklist) | ||
end | ||
end.compact.reduce({}, :merge) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
spec/vcr_cassettes/manageiq/providers/lenovo/physical_infra_manager/full_refresh.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.