facter 4.0.23 → 4.0.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4c01aab49dd7e09e17c3ed32dd16db6a14095a160f398443ec3c12f8a99ac0f
4
- data.tar.gz: 31b07ae25da27da958aa2d78ee4b2526092dd38f93564fbfbdd305fc9918fe72
3
+ metadata.gz: 2a87a5fda1ec732928ca868e4df803b7d0b9d68d95f1efd366eeb6497550beff
4
+ data.tar.gz: b324cde69b928d3a21b43d4f40a973b0086a56eba1a30eb5392f1d515513ee52
5
5
  SHA512:
6
- metadata.gz: ed83b3e0dbc7d4f81d9816b2e2820c20d096b8fdfa6b72c448f645de8ea437441f768b3730087f56d92aeca67a9001f35df4b3206a9c7e3162bef7fdc3ab267d
7
- data.tar.gz: e656c9cedecb2c7fb61a30e452ffd1e1c065e16960c1d5ca2a4b9a3c3e34714741ce42874aace47b16a92ce9501bf33306eb517dd2ac5625ef575e0b5c89ede5
6
+ metadata.gz: bd84d157b62b33d1425d971eed5b94dd3c0b4f10e98755bb417b511c4baf5a8f2b48ee53c2ec2a80c7052023b324303ea965231a8bebaa66ca0c9e4553425d84
7
+ data.tar.gz: 8f9ff642fd2214cc77e6e8f7c21287b2265f0a604eba6b707a201e9eef2e77215451562e388f9ef017bc9917219bf58d377bf6e79150cbfa52403569e9ecb23c
@@ -1,5 +1,16 @@
1
1
 
2
2
 
3
+ ## [4.0.24](https://github.com/puppetlabs/facter-ng/tree/4.0.24) (2020-05-26)
4
+
5
+ [Full Changelog](https://github.com/puppetlabs/facter-ng/compare/4.0.23...4.0.24)
6
+
7
+ ### Added
8
+
9
+ - \(FACT-2605\) Add vmware resolver [\#525](https://github.com/puppetlabs/facter-ng/pull/525) ([oanatmaria](https://github.com/oanatmaria))
10
+ - \(FACT-2604\) Add virt-what resolver [\#523](https://github.com/puppetlabs/facter-ng/pull/523) ([oanatmaria](https://github.com/oanatmaria))
11
+
12
+
13
+
3
14
  ## [4.0.23](https://github.com/puppetlabs/facter-ng/tree/4.0.23) (2020-05-22)
4
15
 
5
16
  [Full Changelog](https://github.com/puppetlabs/facter-ng/compare/4.0.22...4.0.23)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.0.23
1
+ 4.0.24
@@ -6,7 +6,8 @@ module Facts
6
6
  FACT_NAME = 'virtual'
7
7
 
8
8
  def call_the_resolver
9
- fact_value = check_docker_lxc || check_gce
9
+ fact_value = check_docker_lxc || check_gce || retrieve_from_virt_what || check_vmware
10
+
10
11
  Facter::ResolvedFact.new(FACT_NAME, fact_value)
11
12
  end
12
13
 
@@ -18,6 +19,14 @@ module Facts
18
19
  def check_docker_lxc
19
20
  Facter::Resolvers::DockerLxc.resolve(:vm)
20
21
  end
22
+
23
+ def check_vmware
24
+ Facter::Resolvers::Vmware.resolve(:vm)
25
+ end
26
+
27
+ def retrieve_from_virt_what
28
+ Facter::Resolvers::VirtWhat.resolve(:vm)
29
+ end
21
30
  end
22
31
  end
23
32
  end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facter
4
+ module Resolvers
5
+ class VirtWhat < BaseResolver
6
+ @semaphore = Mutex.new
7
+ @fact_list ||= {}
8
+
9
+ class << self
10
+ private
11
+
12
+ def post_resolve(fact_name)
13
+ @fact_list.fetch(fact_name) { retrieve_from_virt_what(fact_name) }
14
+ end
15
+
16
+ def retrieve_from_virt_what(fact_name)
17
+ output = Facter::Core::Execution.execute('virt-what', logger: log)
18
+
19
+ @fact_list[:vm] = determine_xen(output)
20
+ @fact_list[:vm] ||= determine_other(output)
21
+ retrieve_vserver unless @fact_list[:vserver]
22
+
23
+ @fact_list[fact_name]
24
+ end
25
+
26
+ def determine_xen(output)
27
+ xen_info = /^xen\n.*/.match(output)
28
+
29
+ return unless xen_info
30
+
31
+ xen_info = xen_info.to_s
32
+ return 'xenu' if xen_info =~ /xen-domu/
33
+ return 'xenhvm' if xen_info =~ /xen-hvm/
34
+ return 'xen0' if xen_info =~ /xen-dom0/
35
+ end
36
+
37
+ def determine_other(output)
38
+ other_vm = output.split("\n").first
39
+ return unless other_vm
40
+
41
+ return 'zlinux' if other_vm =~ /ibm_systemz/
42
+ return retrieve_vserver if other_vm =~ /linux_vserver/
43
+
44
+ other_vm
45
+ end
46
+
47
+ def retrieve_vserver
48
+ proc_status_content = Facter::Util::FileHelper.safe_readlines('/proc/self/status', nil)
49
+ return unless proc_status_content
50
+
51
+ proc_status_content.each do |line|
52
+ parts = line.split("\s")
53
+ next unless parts.size.equal?(2)
54
+
55
+ next unless parts[0] =~ /^s_context:|^VxID:/
56
+ return @fact_list[:vserver] = 'vserver_host' if parts[1] == '0'
57
+
58
+ return @fact_list[:vserver] = 'vserver'
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Facter
4
+ module Resolvers
5
+ class Vmware < BaseResolver
6
+ @semaphore = Mutex.new
7
+ @fact_list ||= {}
8
+
9
+ class << self
10
+ private
11
+
12
+ def post_resolve(fact_name)
13
+ @fact_list.fetch(fact_name) { vmware_command(fact_name) }
14
+ end
15
+
16
+ def vmware_command(fact_name)
17
+ output = Facter::Core::Execution.execute('vmware -v', logger: log)
18
+ return if output.empty?
19
+
20
+ parts = output.split("\s")
21
+ return unless parts.size.equal?(2)
22
+
23
+ @fact_list[:vm] = "#{parts[0].downcase}_#{parts[1].downcase}"
24
+ @fact_list[fact_name]
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facter
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.23
4
+ version: 4.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-22 00:00:00.000000000 Z
11
+ date: 2020-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -733,6 +733,8 @@ files:
733
733
  - lib/resolvers/utils/fingerprint.rb
734
734
  - lib/resolvers/utils/ssh.rb
735
735
  - lib/resolvers/utils/ssh_helper.rb
736
+ - lib/resolvers/virt_what.rb
737
+ - lib/resolvers/vmware.rb
736
738
  - lib/resolvers/windows/dmi_bios_resolver.rb
737
739
  - lib/resolvers/windows/dmi_computersystem_resolver.rb
738
740
  - lib/resolvers/windows/ffi/ffi.rb