ohai 13.8.0 → 13.9.0

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: ed79bd1846153f8db453aa5c4d5a450522ccb0ffaa7ddb9faf6f1e8f317ec938
4
- data.tar.gz: 504355e9a917477dd61c28ca6f99eda71a31f8882897d05f5a7f006b2b2e45f5
3
+ metadata.gz: ac08ce5a211365837e135cb56aac6da7739a18ad4668ea9c13d29ff530b80f3b
4
+ data.tar.gz: f423edf0da0a9af0ff03a8c0c9179200a626f3b57af5c825ddce62710870e056
5
5
  SHA512:
6
- metadata.gz: 47c46363f70bd81d58a2dd14b6076371c5328498c255b925d860ececef66e241133ddc45d5baa319fc22b301a46ad6e5c71ab295d09f20601d062504fb8fbc24
7
- data.tar.gz: 95eb6bd6fe89046944619277d60a947195416892874a554c21a1d004dfa6f758be1e3ad52d7c9bb997dd6fdb2e3e72b879bee12b810b4592fe9a1bcf19a30f52
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-04-02" unless defined?(AZURE_METADATA_URL)
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
@@ -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 initialize_metadata_mash
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 = initialize_metadata_mash
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
- # parse out per interface interface IP data
104
- endpoint_data["network"]["interface"].each do |int|
105
- metadata["network"]["interfaces"][int["macAddress"]] = Mash.new
106
- metadata["network"]["interfaces"][int["macAddress"]]["mac"] = int["macAddress"]
107
- metadata["network"]["interfaces"][int["macAddress"]]["public_ipv6"] = fetch_ip_data(int, "ipv6", "publicIpAddress")
108
- metadata["network"]["interfaces"][int["macAddress"]]["public_ipv4"] = fetch_ip_data(int, "ipv4", "publicIpAddress")
109
- metadata["network"]["interfaces"][int["macAddress"]]["local_ipv6"] = fetch_ip_data(int, "ipv6", "privateIpAddress")
110
- metadata["network"]["interfaces"][int["macAddress"]]["local_ipv4"] = fetch_ip_data(int, "ipv4", "privateIpAddress")
111
- end
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
- # aggregate the total IP data
114
- %w{public_ipv4 local_ipv4 public_ipv6 local_ipv6}.each do |type|
115
- metadata["network"]["interfaces"].each_value do |val|
116
- metadata["network"][type].concat val[type] unless val[type].empty?
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
 
@@ -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"
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright (c) 2008-2017, Chef Software Inc.
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.8.0"
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 to uptime with days" do
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 uptime to a human readable date with days" do
36
- expect(@plugin[:uptime]).to eq("1148 days 20 hours 54 minutes 50 seconds")
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.8.0
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-03-02 00:00:00.000000000 Z
11
+ date: 2018-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu