facter 4.0.52 → 4.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +202 -0
  3. data/lib/facter.rb +21 -21
  4. data/lib/facter/config.rb +2 -0
  5. data/lib/facter/custom_facts/core/execution/base.rb +7 -3
  6. data/lib/facter/custom_facts/core/execution/popen3.rb +13 -1
  7. data/lib/facter/custom_facts/core/execution/posix.rb +2 -2
  8. data/lib/facter/custom_facts/core/execution/windows.rb +1 -1
  9. data/lib/facter/custom_facts/util/collection.rb +5 -0
  10. data/lib/facter/custom_facts/util/directory_loader.rb +1 -1
  11. data/lib/facter/custom_facts/util/normalization.rb +7 -2
  12. data/lib/facter/custom_facts/util/windows_root.rb +2 -1
  13. data/lib/facter/facts/aix/processors/cores.rb +16 -0
  14. data/lib/facter/facts/aix/processors/threads.rb +16 -0
  15. data/lib/facter/facts/freebsd/is_virtual.rb +1 -5
  16. data/lib/facter/facts/freebsd/virtual.rb +1 -2
  17. data/lib/facter/facts/linux/az_metadata.rb +1 -5
  18. data/lib/facter/facts/linux/cloud/provider.rb +5 -2
  19. data/lib/facter/facts/linux/ec2_metadata.rb +1 -5
  20. data/lib/facter/facts/linux/ec2_userdata.rb +1 -5
  21. data/lib/facter/facts/linux/hypervisors/xen.rb +1 -4
  22. data/lib/facter/facts/linux/is_virtual.rb +1 -5
  23. data/lib/facter/facts/linux/processors/cores.rb +16 -0
  24. data/lib/facter/facts/linux/processors/threads.rb +16 -0
  25. data/lib/facter/facts/linux/virtual.rb +1 -2
  26. data/lib/facter/facts/macosx/os/macosx/version.rb +15 -4
  27. data/lib/facter/facts/macosx/processors/cores.rb +16 -0
  28. data/lib/facter/facts/macosx/processors/threads.rb +16 -0
  29. data/lib/facter/facts/solaris/hypervisors/ldom.rb +1 -1
  30. data/lib/facter/facts/solaris/hypervisors/zone.rb +1 -1
  31. data/lib/facter/facts/solaris/mountpoints.rb +1 -1
  32. data/lib/facter/facts/solaris/processors/cores.rb +16 -0
  33. data/lib/facter/facts/solaris/processors/threads.rb +16 -0
  34. data/lib/facter/facts/windows/az_metadata.rb +1 -5
  35. data/lib/facter/facts/windows/cloud/provider.rb +6 -2
  36. data/lib/facter/facts/windows/ec2_metadata.rb +1 -1
  37. data/lib/facter/facts/windows/ec2_userdata.rb +1 -1
  38. data/lib/facter/facts/windows/gce.rb +1 -1
  39. data/lib/facter/facts/windows/hypervisors/hyperv.rb +1 -1
  40. data/lib/facter/facts/windows/hypervisors/kvm.rb +2 -1
  41. data/lib/facter/facts/windows/hypervisors/virtualbox.rb +2 -2
  42. data/lib/facter/facts/windows/hypervisors/vmware.rb +1 -1
  43. data/lib/facter/facts/windows/hypervisors/xen.rb +3 -1
  44. data/lib/facter/facts/windows/is_virtual.rb +15 -0
  45. data/lib/facter/facts/windows/{virtualization/is_virtual.rb → processors/cores.rb} +4 -4
  46. data/lib/facter/facts/windows/{virtualization/virtual.rb → processors/threads.rb} +4 -4
  47. data/lib/facter/facts/windows/virtual.rb +15 -0
  48. data/lib/facter/framework/cli/cli.rb +13 -15
  49. data/lib/facter/framework/core/cache_manager.rb +2 -2
  50. data/lib/facter/framework/core/fact/external/external_fact_manager.rb +0 -1
  51. data/lib/facter/framework/core/fact/internal/internal_fact_manager.rb +41 -39
  52. data/lib/facter/framework/core/fact_filter.rb +4 -14
  53. data/lib/facter/framework/core/fact_loaders/external_fact_loader.rb +9 -6
  54. data/lib/facter/framework/core/fact_loaders/fact_loader.rb +39 -36
  55. data/lib/facter/framework/core/fact_manager.rb +82 -14
  56. data/lib/facter/framework/core/file_loader.rb +1 -1
  57. data/lib/facter/framework/core/options/config_file_options.rb +7 -0
  58. data/lib/facter/framework/core/options/option_store.rb +3 -1
  59. data/lib/facter/framework/formatters/formatter_helper.rb +3 -5
  60. data/lib/facter/framework/parsers/query_parser.rb +10 -24
  61. data/lib/facter/models/fact_collection.rb +48 -5
  62. data/lib/facter/models/resolved_fact.rb +2 -3
  63. data/lib/facter/models/searched_fact.rb +2 -3
  64. data/lib/facter/resolvers/aix/ffi/ffi_helper.rb +1 -1
  65. data/lib/facter/resolvers/aix/processors.rb +4 -0
  66. data/lib/facter/resolvers/base_resolver.rb +2 -2
  67. data/lib/facter/resolvers/dmi_decode.rb +0 -1
  68. data/lib/facter/resolvers/ec2.rb +8 -1
  69. data/lib/facter/resolvers/linux/hostname.rb +16 -5
  70. data/lib/facter/resolvers/linux/networking.rb +18 -1
  71. data/lib/facter/resolvers/lsb_release.rb +1 -2
  72. data/lib/facter/resolvers/macosx/mountpoints.rb +14 -1
  73. data/lib/facter/resolvers/macosx/processor.rb +16 -1
  74. data/lib/facter/resolvers/mountpoints.rb +16 -8
  75. data/lib/facter/resolvers/networking.rb +6 -3
  76. data/lib/facter/resolvers/partitions.rb +1 -3
  77. data/lib/facter/resolvers/processors_lscpu.rb +44 -0
  78. data/lib/facter/resolvers/ruby.rb +1 -1
  79. data/lib/facter/resolvers/selinux.rb +5 -7
  80. data/lib/facter/resolvers/solaris/ffi/structs.rb +12 -0
  81. data/lib/facter/resolvers/solaris/mountpoints.rb +22 -16
  82. data/lib/facter/resolvers/solaris/networking.rb +20 -5
  83. data/lib/facter/resolvers/solaris/processors.rb +7 -0
  84. data/lib/facter/resolvers/solaris/zone.rb +0 -1
  85. data/lib/facter/resolvers/windows/ffi/identity_ffi.rb +5 -0
  86. data/lib/facter/resolvers/windows/ffi/kernel_ffi.rb +1 -1
  87. data/lib/facter/resolvers/windows/identity.rb +1 -6
  88. data/lib/facter/resolvers/windows/processors.rb +41 -4
  89. data/lib/facter/resolvers/windows/uptime.rb +3 -22
  90. data/lib/facter/resolvers/windows/virtualization.rb +46 -44
  91. data/lib/facter/resolvers/xen.rb +6 -1
  92. data/lib/facter/templates/man.erb +6 -6
  93. data/lib/facter/util/facts/posix/virtual_detector.rb +74 -0
  94. data/lib/facter/util/facts/unit_converter.rb +2 -2
  95. data/lib/facter/util/linux/dhcp.rb +4 -1
  96. data/lib/facter/util/linux/if_inet6.rb +73 -0
  97. data/lib/facter/util/linux/socket_parser.rb +18 -3
  98. data/lib/facter/util/resolvers/http.rb +7 -1
  99. data/lib/facter/util/resolvers/networking/primary_interface.rb +11 -5
  100. data/lib/facter/util/utils.rb +18 -1
  101. data/lib/facter/version.rb +1 -1
  102. metadata +60 -11
  103. data/lib/facter/framework/core/fact_augmenter.rb +0 -37
  104. data/lib/facter/util/facts/virtual_detector.rb +0 -90
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Facter
4
- module FactAugmenter
5
- def self.augment_resolved_facts(searched_facts, resolved_facts)
6
- augumented_resolved_facts = []
7
- searched_facts.each do |searched_fact|
8
- matched_facts = get_resolved_facts_for_searched_fact(searched_fact, resolved_facts)
9
- augment_resolved_fact_for_user_query!(searched_fact, matched_facts)
10
- augumented_resolved_facts.concat(matched_facts)
11
- end
12
-
13
- augumented_resolved_facts
14
- end
15
-
16
- private_class_method def self.get_resolved_facts_for_searched_fact(searched_fact, resolved_facts)
17
- if searched_fact.name.include?('.*')
18
- resolved_facts
19
- .select { |resolved_fact| resolved_fact.name.match(searched_fact.name) }
20
- .reject(&:user_query)
21
- .uniq(&:name)
22
- else
23
- resolved_facts
24
- .select { |resolved_fact| searched_fact.name.eql?(resolved_fact.name) }
25
- .reject(&:user_query)
26
- .uniq(&:name)
27
- end
28
- end
29
-
30
- private_class_method def self.augment_resolved_fact_for_user_query!(searched_fact, matched_facts)
31
- matched_facts.each do |matched_fact|
32
- matched_fact.user_query = searched_fact.user_query
33
- matched_fact.filter_tokens = searched_fact.filter_tokens
34
- end
35
- end
36
- end
37
- end
@@ -1,90 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Facter
4
- module Util
5
- module Facts
6
- class VirtualDetector
7
- def initialize
8
- @log = Facter::Log.new(self)
9
- end
10
-
11
- def platform
12
- fact_value = check_docker_lxc || check_dmi || check_freebsd || check_gce || retrieve_from_virt_what
13
- fact_value ||= check_vmware || check_open_vz || check_vserver || check_xen || check_other_facts
14
- fact_value ||= check_lspci || 'physical'
15
-
16
- fact_value
17
- end
18
-
19
- def check_docker_lxc
20
- @log.debug('Checking Docker and LXC')
21
- Facter::Resolvers::Containers.resolve(:vm)
22
- end
23
-
24
- def check_dmi
25
- @log.debug('Checking DMI')
26
- vendor = Facter::Resolvers::DmiDecode.resolve(:vendor)
27
- @log.debug("dmi detected vendor: #{vendor}")
28
- return 'kvm' if vendor =~ /Amazon/
29
-
30
- 'xen' if vendor =~ /Xen/
31
- end
32
-
33
- def check_gce
34
- @log.debug('Checking GCE')
35
- bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
36
- 'gce' if bios_vendor&.include?('Google')
37
- end
38
-
39
- def check_vmware
40
- @log.debug('Checking VMware')
41
- Facter::Resolvers::Vmware.resolve(:vm)
42
- end
43
-
44
- def retrieve_from_virt_what
45
- @log.debug('Checking virtual_what')
46
- Facter::Resolvers::VirtWhat.resolve(:vm)
47
- end
48
-
49
- def check_open_vz
50
- @log.debug('Checking OpenVZ')
51
- Facter::Resolvers::OpenVz.resolve(:vm)
52
- end
53
-
54
- def check_vserver
55
- @log.debug('Checking VServer')
56
- Facter::Resolvers::VirtWhat.resolve(:vserver)
57
- end
58
-
59
- def check_xen
60
- @log.debug('Checking XEN')
61
- Facter::Resolvers::Xen.resolve(:vm)
62
- end
63
-
64
- def check_freebsd
65
- return unless Object.const_defined?('Facter::Resolvers::Freebsd::Virtual')
66
-
67
- @log.debug('Checking if jailed')
68
- Facter::Resolvers::Freebsd::Virtual.resolve(:vm)
69
- end
70
-
71
- def check_other_facts
72
- @log.debug('Checking others')
73
- product_name = Facter::Resolvers::Linux::DmiBios.resolve(:product_name)
74
- bios_vendor = Facter::Resolvers::Linux::DmiBios.resolve(:bios_vendor)
75
- return 'kvm' if bios_vendor&.include?('Amazon EC2')
76
- return unless product_name
77
-
78
- Facter::Util::Facts::HYPERVISORS_HASH.each { |key, value| return value if product_name.include?(key) }
79
-
80
- nil
81
- end
82
-
83
- def check_lspci
84
- @log.debug('Checking lspci')
85
- Facter::Resolvers::Lspci.resolve(:vm)
86
- end
87
- end
88
- end
89
- end
90
- end