Skip to content

Commit

Permalink
Fix hypervisor without any guest
Browse files Browse the repository at this point in the history
As by RedHatSatellite#68, if a host does not have any guest, and facts is not populated, fail.
The resolution is to make use of virtwho option, which will gather the facts from virtwho directly.
Still no fatal error will be given anymore after the patch, but a WARNING in stderr.
This is due to a candlepin bug which does not expose (yet) the facts for a hypervisor.
  • Loading branch information
Rocco83 committed Jul 22, 2019
1 parent ca87f9c commit dbb0128
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions katello-attach-subscription
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,9 @@ def vdcupdate()
system_details[system['name']]=sys
# check if the type requested match the host one
system_type = KatelloAttachSubscription::FactAnalyzer.system_type(sys)
if system_type == KatelloAttachSubscription::FactAnalyzer::HYPERVISOR
STDERR.puts " WARNING: host #{system['name']}' id #{system['id']} has not been recognized. This may happens because of a HYPERVISOR does not have any guest. Try to leverage on virtwho option."
end
# for each item in yaml extract sub
if @options[:debug]
puts " DEBUG: YAML dump with all definitions for the current system"
Expand Down
4 changes: 4 additions & 0 deletions lib/katello_attach_subscription/fact_analyzer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def self.system_type_from_host(host)

def self.system_type(host, facts = nil)
facts = host['facts'] unless facts
# workaround, if a host does not have a valid list of facts, the code will fail in self.system_type_from_facts(facts)
if not facts.is_a?(Hash)
facts = {}
end
self.system_type_from_host(host) || self.system_type_from_facts(facts) || UNKNOWN
end
end
Expand Down

0 comments on commit dbb0128

Please sign in to comment.