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

Fix getting facts for hosts from the API #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions katello-attach-subscription
Original file line number Diff line number Diff line change
Expand Up @@ -1080,12 +1080,14 @@ def vdcupdate()
if @options[:debug]
puts " DEBUG: Checking the number of socket for #{sys["name"]}"
end
# get the facts for the current host from a api call to fact_values
facts = @api.resource(:fact_values).action(:index).call(:organization_id => 1, :per_page => 100000, :search => "host = #{sys['name']}")
# if the number of socket is setted, we can find the value from cpu::cpu_socket(s)
if sys.has_key?("facts") and sys["facts"].is_a?(Hash) and sys["facts"].has_key?("cpu::cpu_socket(s)")
if facts.has_key?('results') and facts['results'].is_a?(Hash) and facts['results'].has_key?(sys['name']) and facts['results'][sys['name']].is_a?(Hash) and facts['results'][sys['name']].has_key?("cpu::cpu_socket(s)")
# if the field is present check if it's a valid entry or not, if not exit with error
if sys["facts"]["cpu::cpu_socket(s)"].to_i > 0
if facts['results'][sys['name']]['cpu::cpu_socket(s)'].to_i > 0
# set sys_socket to the value of cpu::cpu_socket(s)
sys_socket = sys["facts"]["cpu::cpu_socket(s)"].to_i
sys_socket = facts['results'][sys['name']]['cpu::cpu_socket(s)'].to_i
if @options[:debug]
puts " DEBUG: Setting sys_socket to #{sys_socket} for #{sys["name"]}"
end
Expand Down
2 changes: 2 additions & 0 deletions lib/katello_attach_subscription/fact_analyzer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class FactAnalyzer
UNKNOWN = 'Unknown'.freeze

def self.system_type_from_facts(facts)
return unless facts.is_a?(Hash)

if (not facts['virt::host_type'].nil? and facts['virt::host_type'] != 'Not Applicable') or
(facts['virt::is_guest'] and facts['virt::is_guest'].to_s.downcase != 'false') or
facts['virt::uuid']
Expand Down