Skip to content

Commit

Permalink
Make entity_uuid work for Chef Infra 15 (#371)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Pop <alexpop@users.noreply.github.com>
  • Loading branch information
alexpop authored May 31, 2019
1 parent 9200214 commit 0b32136
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 2 additions & 0 deletions files/default/handler/audit_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def send_report(reporter, server, user, source_location, report)

# TODO: harmonize reporter interface
if reporter == 'chef-visibility' || reporter == 'chef-automate'
# `run_status.entity_uuid` is calling the `entity_uuid` method in libraries/helper.rb
opts = {
entity_uuid: run_status.entity_uuid,
run_id: run_status.run_id,
Expand All @@ -242,6 +243,7 @@ def send_report(reporter, server, user, source_location, report)
chef_org = Chef::Config[:chef_server_url].split('/').last
if chef_url
url = construct_url(chef_url, File.join('organizations', chef_org, 'data-collector'))
# `run_status.entity_uuid` is calling the `entity_uuid` method in libraries/helper.rb
opts = {
entity_uuid: run_status.entity_uuid,
run_id: run_status.run_id,
Expand Down
8 changes: 2 additions & 6 deletions libraries/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ def run_id

# Returns the node's uuid
def entity_uuid
if defined?(Chef) &&
defined?(Chef::DataCollector) &&
defined?(Chef::DataCollector::Messages) &&
defined?(Chef::DataCollector::Messages.node_uuid)
Chef::DataCollector::Messages.node_uuid
end
# the Chef::DataCollector::Messages API here is Chef < 15.0 backcompat and can be removed when Chef 14.x is no longer supported
node[:chef_guid] || defined?(Chef::DataCollector::Messages) && Chef::DataCollector::Messages.node_uuid
end

# Convert the strings in the profile definitions into symbols for handling
Expand Down

0 comments on commit 0b32136

Please sign in to comment.