ohai 13.8.0 → 13.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -5
- data/lib/ohai/mixin/azure_metadata.rb +1 -1
- data/lib/ohai/plugins/aix/uptime.rb +1 -1
- data/lib/ohai/plugins/azure.rb +23 -15
- data/lib/ohai/plugins/cloud.rb +23 -0
- data/lib/ohai/plugins/darwin/virtualization.rb +13 -0
- data/lib/ohai/version.rb +2 -2
- data/spec/unit/plugins/aix/uptime_spec.rb +9 -5
- data/spec/unit/plugins/cloud_spec.rb +36 -0
- data/spec/unit/plugins/darwin/virtualization_spec.rb +19 -0
- data/spec/unit/plugins/vmware_spec.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac08ce5a211365837e135cb56aac6da7739a18ad4668ea9c13d29ff530b80f3b
|
4
|
+
data.tar.gz: f423edf0da0a9af0ff03a8c0c9179200a626f3b57af5c825ddce62710870e056
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09a90504692248fc72740b5bcb5477b433d99e036a0182980a5b3618e9cb6ca34198641fa52cc35890d705cd68c299d36c58df38dd0b22a697b3def7343c26b7'
|
7
|
+
data.tar.gz: 2558c4c4589659fa4881f2f2f47c03b31277fcd0ca8dc181c4d7a60fd0bce535a6a14d41196a5e194a2e618d17baf5d06294411bb6be221ec142ba74c62c88be
|
data/Gemfile
CHANGED
@@ -4,7 +4,7 @@ gemspec
|
|
4
4
|
|
5
5
|
# NOTE: do not submit PRs to add pry as a dep, add to your Gemfile.local
|
6
6
|
group :development do
|
7
|
-
gem "chefstyle"
|
7
|
+
gem "chefstyle", "= 0.6.0"
|
8
8
|
gem "rake", ">= 10.1.0"
|
9
9
|
gem "rspec-core", "~> 3.0"
|
10
10
|
gem "rspec-expectations", "~> 3.0"
|
@@ -17,10 +17,6 @@ group :ci do
|
|
17
17
|
gem "rspec_junit_formatter"
|
18
18
|
end
|
19
19
|
|
20
|
-
group :changelog do
|
21
|
-
gem "github_changelog_generator", git: "https://github.com/chef/github-changelog-generator"
|
22
|
-
end
|
23
|
-
|
24
20
|
instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
|
25
21
|
|
26
22
|
# If you want to load debugging tools into the bundle exec sandbox,
|
@@ -22,7 +22,7 @@ module Ohai
|
|
22
22
|
module AzureMetadata
|
23
23
|
|
24
24
|
AZURE_METADATA_ADDR = "169.254.169.254" unless defined?(AZURE_METADATA_ADDR)
|
25
|
-
AZURE_METADATA_URL = "/metadata/instance?api-version=2017-
|
25
|
+
AZURE_METADATA_URL = "/metadata/instance?api-version=2017-08-01" unless defined?(AZURE_METADATA_URL)
|
26
26
|
|
27
27
|
# fetch the meta content with a timeout and the required header
|
28
28
|
def http_get(uri)
|
@@ -27,7 +27,7 @@ Ohai.plugin(:Uptime) do
|
|
27
27
|
# 1148-20:54:50
|
28
28
|
# This reads as 1148 days, 20 hours, 54 minutes, 50 seconds since the process was started (elapsed)
|
29
29
|
# who -b does not return the YEAR, so we need something more concrete
|
30
|
-
so = shell_out("LC_ALL=POSIX ps -o etime= -p 1").stdout
|
30
|
+
so = shell_out("LC_ALL=POSIX ps -o etime= -p 1").stdout.strip
|
31
31
|
|
32
32
|
# Here we'll check our shell_out for a dash, which indicates there is a # of days involved
|
33
33
|
# We'll chunk off the days, hours (where applicable), minutes, seconds into seperate vars
|
data/lib/ohai/plugins/azure.rb
CHANGED
@@ -68,9 +68,13 @@ Ohai.plugin(:Azure) do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
# create the basic structure we'll store our data in
|
71
|
-
def
|
71
|
+
def initialize_metadata_mash_compute
|
72
72
|
metadata = Mash.new
|
73
73
|
metadata["compute"] = Mash.new
|
74
|
+
metadata
|
75
|
+
end
|
76
|
+
|
77
|
+
def initialize_metadata_mash_network(metadata)
|
74
78
|
metadata["network"] = Mash.new
|
75
79
|
metadata["network"]["interfaces"] = Mash.new
|
76
80
|
%w{public_ipv4 local_ipv4 public_ipv6 local_ipv6}.each do |type|
|
@@ -93,27 +97,31 @@ Ohai.plugin(:Azure) do
|
|
93
97
|
|
94
98
|
endpoint_data = fetch_metadata
|
95
99
|
return nil if endpoint_data.nil?
|
96
|
-
metadata =
|
100
|
+
metadata = initialize_metadata_mash_compute
|
97
101
|
|
98
102
|
# blindly add everything in compute to our data structure
|
99
103
|
endpoint_data["compute"].each do |k, v|
|
100
104
|
metadata["compute"][k] = v
|
101
105
|
end
|
102
106
|
|
103
|
-
#
|
104
|
-
endpoint_data["network"]
|
105
|
-
metadata
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
107
|
+
# receiving network output is not guaranteed
|
108
|
+
unless endpoint_data["network"].nil?
|
109
|
+
metadata = initialize_metadata_mash_network(metadata)
|
110
|
+
# parse out per interface interface IP data
|
111
|
+
endpoint_data["network"]["interface"].each do |int|
|
112
|
+
metadata["network"]["interfaces"][int["macAddress"]] = Mash.new
|
113
|
+
metadata["network"]["interfaces"][int["macAddress"]]["mac"] = int["macAddress"]
|
114
|
+
metadata["network"]["interfaces"][int["macAddress"]]["public_ipv6"] = fetch_ip_data(int, "ipv6", "publicIpAddress")
|
115
|
+
metadata["network"]["interfaces"][int["macAddress"]]["public_ipv4"] = fetch_ip_data(int, "ipv4", "publicIpAddress")
|
116
|
+
metadata["network"]["interfaces"][int["macAddress"]]["local_ipv6"] = fetch_ip_data(int, "ipv6", "privateIpAddress")
|
117
|
+
metadata["network"]["interfaces"][int["macAddress"]]["local_ipv4"] = fetch_ip_data(int, "ipv4", "privateIpAddress")
|
118
|
+
end
|
112
119
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
120
|
+
# aggregate the total IP data
|
121
|
+
%w{public_ipv4 local_ipv4 public_ipv6 local_ipv6}.each do |type|
|
122
|
+
metadata["network"]["interfaces"].each_value do |val|
|
123
|
+
metadata["network"][type].concat val[type] unless val[type].empty?
|
124
|
+
end
|
117
125
|
end
|
118
126
|
end
|
119
127
|
|
data/lib/ohai/plugins/cloud.rb
CHANGED
@@ -26,6 +26,7 @@ Ohai.plugin(:Cloud) do
|
|
26
26
|
depends "openstack"
|
27
27
|
depends "azure"
|
28
28
|
depends "digital_ocean"
|
29
|
+
depends "softlayer"
|
29
30
|
|
30
31
|
# Class to help enforce the interface exposed to node[:cloud] (OHAI-542)
|
31
32
|
#
|
@@ -295,6 +296,27 @@ Ohai.plugin(:Cloud) do
|
|
295
296
|
@cloud_attr_obj.provider = "digital_ocean"
|
296
297
|
end
|
297
298
|
|
299
|
+
# ----------------------------------------
|
300
|
+
# softlayer
|
301
|
+
# ----------------------------------------
|
302
|
+
|
303
|
+
# Is current cloud softlayer?
|
304
|
+
#
|
305
|
+
# === Return
|
306
|
+
# true:: If softlayer Hash is defined
|
307
|
+
# false:: Otherwise
|
308
|
+
def on_softlayer?
|
309
|
+
softlayer != nil
|
310
|
+
end
|
311
|
+
|
312
|
+
# Fill cloud hash with softlayer values
|
313
|
+
def get_softlayer_values
|
314
|
+
@cloud_attr_obj.add_ipv4_addr(softlayer["public_ipv4"], :public)
|
315
|
+
@cloud_attr_obj.add_ipv4_addr(softlayer["local_ipv4"], :private)
|
316
|
+
@cloud_attr_obj.public_hostname = softlayer["public_fqdn"]
|
317
|
+
@cloud_attr_obj.provider = "softlayer"
|
318
|
+
end
|
319
|
+
|
298
320
|
collect_data do
|
299
321
|
require "ipaddr"
|
300
322
|
|
@@ -308,6 +330,7 @@ Ohai.plugin(:Cloud) do
|
|
308
330
|
get_openstack_values if on_openstack?
|
309
331
|
get_azure_values if on_azure?
|
310
332
|
get_digital_ocean_values if on_digital_ocean?
|
333
|
+
get_softlayer_values if on_softlayer?
|
311
334
|
|
312
335
|
# set node[:cloud] and node[:cloud_v2] hash here
|
313
336
|
cloud_v2 @cloud_attr_obj.cloud_mash
|
@@ -20,6 +20,7 @@
|
|
20
20
|
|
21
21
|
Ohai.plugin(:Virtualization) do
|
22
22
|
provides "virtualization"
|
23
|
+
depends "hardware"
|
23
24
|
|
24
25
|
def vboxmanage_exists?
|
25
26
|
which("VBoxManage")
|
@@ -47,12 +48,24 @@ Ohai.plugin(:Virtualization) do
|
|
47
48
|
virtualization[:systems][:vbox] = "host"
|
48
49
|
end
|
49
50
|
|
51
|
+
if hardware[:boot_rom_version].match?(/VirtualBox/i)
|
52
|
+
virtualization[:system] = "vbox"
|
53
|
+
virtualization[:role] = "guest"
|
54
|
+
virtualization[:systems][:vbox] = "guest"
|
55
|
+
end
|
56
|
+
|
50
57
|
if fusion_exists?
|
51
58
|
virtualization[:system] = "vmware"
|
52
59
|
virtualization[:role] = "host"
|
53
60
|
virtualization[:systems][:vmware] = "host"
|
54
61
|
end
|
55
62
|
|
63
|
+
if hardware[:boot_rom_version].match?(/VMW/i)
|
64
|
+
virtualization[:system] = "vmware"
|
65
|
+
virtualization[:role] = "guest"
|
66
|
+
virtualization[:systems][:vmware] = "guest"
|
67
|
+
end
|
68
|
+
|
56
69
|
if prlctl_exists?
|
57
70
|
virtualization[:system] = "parallels"
|
58
71
|
virtualization[:role] = "host"
|
data/lib/ohai/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2008-
|
3
|
+
# Copyright:: Copyright (c) 2008-2018, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -18,5 +18,5 @@
|
|
18
18
|
|
19
19
|
module Ohai
|
20
20
|
OHAI_ROOT = File.expand_path(File.dirname(__FILE__))
|
21
|
-
VERSION = "13.
|
21
|
+
VERSION = "13.9.0"
|
22
22
|
end
|
@@ -24,15 +24,19 @@ describe Ohai::System, "Aix plugin uptime" do
|
|
24
24
|
@plugin = get_plugin("aix/uptime")
|
25
25
|
allow(@plugin).to receive(:collect_os).and_return(:aix)
|
26
26
|
allow(@plugin).to receive(:shell_out).and_call_original
|
27
|
-
allow(@plugin).to receive(:shell_out).with("LC_ALL=POSIX ps -o etime= -p 1").and_return(mock_shell_out(0, "1148-20:54:50", nil))
|
28
|
-
@plugin.run
|
29
27
|
end
|
30
28
|
|
31
|
-
it "should set uptime_seconds
|
29
|
+
it "should set uptime_seconds and uptime standard case" do
|
30
|
+
allow(@plugin).to receive(:shell_out).with("LC_ALL=POSIX ps -o etime= -p 1").and_return(mock_shell_out(0, "1148-20:54:50", nil))
|
31
|
+
@plugin.run
|
32
32
|
expect(@plugin[:uptime_seconds]).to eq(99262490)
|
33
|
+
expect(@plugin[:uptime]).to eq("1148 days 20 hours 54 minutes 50 seconds")
|
33
34
|
end
|
34
35
|
|
35
|
-
it "should set
|
36
|
-
|
36
|
+
it "should set uptime_seconds and uptime in the whitespace case" do
|
37
|
+
allow(@plugin).to receive(:shell_out).with("LC_ALL=POSIX ps -o etime= -p 1").and_return(mock_shell_out(0, " 2-20:54:50", nil))
|
38
|
+
@plugin.run
|
39
|
+
expect(@plugin[:uptime_seconds]).to eq(248090)
|
40
|
+
expect(@plugin[:uptime]).to eq("2 days 20 hours 54 minutes 50 seconds")
|
37
41
|
end
|
38
42
|
end
|
@@ -86,6 +86,7 @@ describe Ohai::System, "plugin cloud" do
|
|
86
86
|
@plugin[:azure] = nil
|
87
87
|
@plugin[:gce] = nil
|
88
88
|
@plugin[:digital_ocean] = nil
|
89
|
+
@plugin[:softlayer] = nil
|
89
90
|
@plugin.run
|
90
91
|
expect(@plugin[:cloud]).to be_nil
|
91
92
|
expect(@plugin[:cloud_v2]).to be_nil
|
@@ -457,4 +458,39 @@ describe Ohai::System, "plugin cloud" do
|
|
457
458
|
end
|
458
459
|
end
|
459
460
|
|
461
|
+
describe "with softlayer mash" do
|
462
|
+
before do
|
463
|
+
@plugin[:softlayer] = Mash.new
|
464
|
+
@plugin[:softlayer] = { "local_ipv4" => "192.168.0.1",
|
465
|
+
"public_ipv4" => "8.8.8.8",
|
466
|
+
"public_fqdn" => "abc1234.public.com",
|
467
|
+
}
|
468
|
+
end
|
469
|
+
|
470
|
+
it "populates cloud public ip" do
|
471
|
+
@plugin.run
|
472
|
+
expect(@plugin[:cloud][:public_ipv4_addrs][0]).to eq(@plugin[:softlayer][:public_ipv4])
|
473
|
+
end
|
474
|
+
|
475
|
+
it "populates cloud private ip" do
|
476
|
+
@plugin.run
|
477
|
+
expect(@plugin[:cloud][:local_ipv4_addrs][0]).to eq(@plugin[:softlayer][:local_ipv4])
|
478
|
+
end
|
479
|
+
|
480
|
+
it "populates first cloud public ip" do
|
481
|
+
@plugin.run
|
482
|
+
expect(@plugin[:cloud][:public_ipv4_addrs].first).to eq(@plugin[:softlayer][:public_ipv4])
|
483
|
+
end
|
484
|
+
|
485
|
+
it "populates cloud public_hostname" do
|
486
|
+
@plugin.run
|
487
|
+
expect(@plugin[:cloud][:public_hostname]).to eq(@plugin[:softlayer][:public_fqdn])
|
488
|
+
end
|
489
|
+
|
490
|
+
it "populates cloud provider" do
|
491
|
+
@plugin.run
|
492
|
+
expect(@plugin[:cloud][:provider]).to eq("softlayer")
|
493
|
+
end
|
494
|
+
end
|
495
|
+
|
460
496
|
end
|
@@ -29,6 +29,9 @@ describe Ohai::System, "Darwin virtualization platform" do
|
|
29
29
|
allow(plugin).to receive(:ioreg_exists?).and_return(false)
|
30
30
|
allow(plugin).to receive(:vboxmanage_exists?).and_return(false)
|
31
31
|
allow(plugin).to receive(:fusion_exists?).and_return(false)
|
32
|
+
allow(plugin).to receive(:docker_exists?).and_return(false)
|
33
|
+
plugin[:hardware] = Mash.new
|
34
|
+
plugin[:hardware][:boot_rom_version] = "not_a_vm"
|
32
35
|
end
|
33
36
|
|
34
37
|
describe "when detecting OS X virtualization" do
|
@@ -45,6 +48,14 @@ describe Ohai::System, "Darwin virtualization platform" do
|
|
45
48
|
expect(plugin[:virtualization][:systems][:vmware]).to eq("host")
|
46
49
|
end
|
47
50
|
|
51
|
+
it "should set vmware guest if hardware attributes mention vmware" do
|
52
|
+
plugin[:hardware][:boot_rom_version] = "VMW71.00V.6997262.B64.1710270607"
|
53
|
+
plugin.run
|
54
|
+
expect(plugin[:virtualization][:system]).to eq("vmware")
|
55
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
56
|
+
expect(plugin[:virtualization][:systems][:vmware]).to eq("guest")
|
57
|
+
end
|
58
|
+
|
48
59
|
it "should set vbox host if /usr/local/bin/VBoxManage exists" do
|
49
60
|
allow(plugin).to receive(:vboxmanage_exists?).and_return("/usr/local/bin/VBoxManage")
|
50
61
|
plugin.run
|
@@ -53,6 +64,14 @@ describe Ohai::System, "Darwin virtualization platform" do
|
|
53
64
|
expect(plugin[:virtualization][:systems][:vbox]).to eq("host")
|
54
65
|
end
|
55
66
|
|
67
|
+
it "should set vbox guest if hardware attributes mention virtualbox" do
|
68
|
+
plugin[:hardware][:boot_rom_version] = "VirtualBox"
|
69
|
+
plugin.run
|
70
|
+
expect(plugin[:virtualization][:system]).to eq("vbox")
|
71
|
+
expect(plugin[:virtualization][:role]).to eq("guest")
|
72
|
+
expect(plugin[:virtualization][:systems][:vbox]).to eq("guest")
|
73
|
+
end
|
74
|
+
|
56
75
|
it "should set parallels host if /usr/bin/prlctl exists" do
|
57
76
|
allow(plugin).to receive(:prlctl_exists?).and_return("/usr/bin/prlctl")
|
58
77
|
plugin.run
|
@@ -64,6 +64,7 @@ describe Ohai::System, "plugin vmware" do
|
|
64
64
|
plugin[:virtualization][:systems] = Mash.new
|
65
65
|
plugin[:virtualization][:systems][:vmware] = Mash.new
|
66
66
|
allow(File).to receive(:exist?).with("/usr/bin/vmware-toolbox-cmd").and_return(false)
|
67
|
+
plugin.run
|
67
68
|
expect(plugin).not_to have_key(:vmware)
|
68
69
|
end
|
69
70
|
end
|
@@ -73,6 +74,7 @@ describe Ohai::System, "plugin vmware" do
|
|
73
74
|
plugin[:virtualization] = Mash.new
|
74
75
|
plugin[:virtualization][:systems] = Mash.new
|
75
76
|
plugin[:virtualization][:systems][:vbox] = Mash.new
|
77
|
+
plugin.run
|
76
78
|
expect(plugin).not_to have_key(:vmware)
|
77
79
|
end
|
78
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 13.
|
4
|
+
version: 13.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: systemu
|