ohai 15.1.5 → 15.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/lib/ohai/common/dmi.rb +3 -0
  4. data/lib/ohai/dsl/plugin.rb +3 -0
  5. data/lib/ohai/dsl/plugin/versionvii.rb +4 -2
  6. data/lib/ohai/hints.rb +3 -1
  7. data/lib/ohai/loader.rb +7 -4
  8. data/lib/ohai/mash.rb +1 -1
  9. data/lib/ohai/mixin/constant_helper.rb +1 -0
  10. data/lib/ohai/mixin/ec2_metadata.rb +4 -3
  11. data/lib/ohai/mixin/gce_metadata.rb +2 -3
  12. data/lib/ohai/plugins/aix/kernel.rb +1 -1
  13. data/lib/ohai/plugins/aix/network.rb +3 -3
  14. data/lib/ohai/plugins/aix/virtualization.rb +4 -0
  15. data/lib/ohai/plugins/azure.rb +1 -0
  16. data/lib/ohai/plugins/cloud.rb +7 -4
  17. data/lib/ohai/plugins/cpu.rb +6 -6
  18. data/lib/ohai/plugins/darwin/network.rb +9 -4
  19. data/lib/ohai/plugins/digital_ocean.rb +2 -0
  20. data/lib/ohai/plugins/dmi.rb +1 -0
  21. data/lib/ohai/plugins/dragonflybsd/memory.rb +1 -1
  22. data/lib/ohai/plugins/dragonflybsd/network.rb +1 -0
  23. data/lib/ohai/plugins/ec2.rb +1 -0
  24. data/lib/ohai/plugins/eucalyptus.rb +1 -0
  25. data/lib/ohai/plugins/filesystem.rb +12 -2
  26. data/lib/ohai/plugins/freebsd/memory.rb +1 -1
  27. data/lib/ohai/plugins/freebsd/network.rb +1 -0
  28. data/lib/ohai/plugins/haskell.rb +4 -4
  29. data/lib/ohai/plugins/hostname.rb +2 -1
  30. data/lib/ohai/plugins/java.rb +1 -0
  31. data/lib/ohai/plugins/kernel.rb +10 -5
  32. data/lib/ohai/plugins/linode.rb +1 -1
  33. data/lib/ohai/plugins/linux/lspci.rb +3 -2
  34. data/lib/ohai/plugins/linux/network.rb +18 -7
  35. data/lib/ohai/plugins/linux/platform.rb +4 -8
  36. data/lib/ohai/plugins/netbsd/memory.rb +1 -1
  37. data/lib/ohai/plugins/netbsd/network.rb +1 -0
  38. data/lib/ohai/plugins/network.rb +2 -0
  39. data/lib/ohai/plugins/openbsd/memory.rb +1 -1
  40. data/lib/ohai/plugins/openbsd/network.rb +1 -0
  41. data/lib/ohai/plugins/openstack.rb +8 -14
  42. data/lib/ohai/plugins/packages.rb +29 -1
  43. data/lib/ohai/plugins/rackspace.rb +1 -0
  44. data/lib/ohai/plugins/scaleway.rb +1 -0
  45. data/lib/ohai/plugins/shard.rb +1 -1
  46. data/lib/ohai/plugins/solaris2/network.rb +3 -1
  47. data/lib/ohai/plugins/virtualbox.rb +5 -3
  48. data/lib/ohai/plugins/windows/network.rb +6 -0
  49. data/lib/ohai/provides_map.rb +26 -3
  50. data/lib/ohai/runner.rb +18 -5
  51. data/lib/ohai/system.rb +8 -0
  52. data/lib/ohai/util/win32.rb +4 -4
  53. data/lib/ohai/version.rb +1 -1
  54. data/spec/data/plugins/rpmquery.output +2 -0
  55. data/spec/functional/application_spec.rb +1 -1
  56. data/spec/functional/loader_spec.rb +1 -1
  57. data/spec/unit/dsl/plugin_spec.rb +15 -15
  58. data/spec/unit/plugin_config_spec.rb +3 -3
  59. data/spec/unit/plugins/docker_spec.rb +11 -11
  60. data/spec/unit/plugins/ec2_spec.rb +4 -2
  61. data/spec/unit/plugins/erlang_spec.rb +2 -2
  62. data/spec/unit/plugins/hostname_spec.rb +14 -10
  63. data/spec/unit/plugins/linux/filesystem_spec.rb +1 -0
  64. data/spec/unit/plugins/linux/lspci_spec.rb +2 -1
  65. data/spec/unit/plugins/linux/platform_spec.rb +5 -0
  66. data/spec/unit/plugins/network_spec.rb +3 -2
  67. data/spec/unit/plugins/openstack_spec.rb +31 -30
  68. data/spec/unit/plugins/packages_spec.rb +20 -0
  69. data/spec/unit/plugins/ruby_spec.rb +1 -1
  70. data/spec/unit/plugins/scsi_spec.rb +2 -1
  71. data/spec/unit/plugins/shard_spec.rb +1 -1
  72. data/spec/unit/plugins/windows/filesystem_spec.rb +2 -2
  73. data/spec/unit/plugins/windows/kernel_spec.rb +2 -2
  74. data/spec/unit/runner_spec.rb +2 -2
  75. data/spec/unit/system_spec.rb +3 -3
  76. metadata +2 -2
@@ -28,18 +28,18 @@ module Ohai
28
28
  ffi_lib "advapi32"
29
29
 
30
30
  attach_function :lookup_account_sid,
31
- :LookupAccountSidA, [ :pointer, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer ], :long
31
+ :LookupAccountSidA, %i{pointer pointer pointer pointer pointer pointer pointer}, :long
32
32
 
33
33
  attach_function :convert_string_sid_to_sid,
34
- :ConvertStringSidToSidA, [ :pointer, :pointer ], :long
34
+ :ConvertStringSidToSidA, %i{pointer pointer}, :long
35
35
 
36
36
  ffi_lib "kernel32"
37
37
 
38
38
  attach_function :local_free,
39
- :LocalFree, [ :pointer ], :long
39
+ :LocalFree, [ :pointer ], :long
40
40
 
41
41
  attach_function :get_last_error,
42
- :GetLastError, [], :long
42
+ :GetLastError, [], :long
43
43
  end
44
44
  end
45
45
  end
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Ohai
20
20
  OHAI_ROOT = File.expand_path(File.dirname(__FILE__))
21
- VERSION = "15.1.5".freeze
21
+ VERSION = "15.2.5".freeze
22
22
  end
@@ -3,3 +3,5 @@ tzdata 0 2016d 1.el7 1463486618 noarch
3
3
  nss-softokn-freebl 0 3.16.2.3 14.2.el7_2 1463486619 x86_64
4
4
  glibc 0 2.17 106.el7_2.6 1463486666 x86_64
5
5
  libstdc++ 0 4.8.5 4.el7 1463486669 x86_64
6
+ kernel 0 3.10.0 862.2.3.el7 1526310781 x86_64
7
+ kernel 0 3.10.0 862.el7 1521745632 x86_64
@@ -81,7 +81,7 @@ RSpec.describe "Ohai::Application" do
81
81
 
82
82
  it "loads the workstation configuration file" do
83
83
  app.configure_ohai
84
- expect(Ohai.config[:disabled_plugins]).to eq([ :Foo, :Baz ])
84
+ expect(Ohai.config[:disabled_plugins]).to eq(%i{Foo Baz})
85
85
  end
86
86
  end
87
87
 
@@ -45,7 +45,7 @@ RSpec.describe "Ohai::Loader" do
45
45
  it "loads all the plugins" do
46
46
  loader.load_all
47
47
  loaded_plugins = loader.instance_variable_get(:@v7_plugin_classes)
48
- loaded_plugins_names = loaded_plugins.map { |plugin| plugin.name }
48
+ loaded_plugins_names = loaded_plugins.map(&:name)
49
49
  expect(loaded_plugins_names).to eq(["Ohai::NamedPlugin::Foo"])
50
50
  end
51
51
  end
@@ -220,7 +220,7 @@ shared_examples "Ohai::DSL::Plugin" do
220
220
  it "returns nil" do
221
221
  expect(
222
222
  plugin.get_attribute("the_monarch", "henchmen",
223
- "corky_knightrider")
223
+ "corky_knightrider")
224
224
  ).to be nil
225
225
  end
226
226
  end
@@ -229,9 +229,9 @@ shared_examples "Ohai::DSL::Plugin" do
229
229
  it "raises a TypeError" do
230
230
  expect do
231
231
  plugin.get_attribute("the_monarch", "arch_rival",
232
- "dr_venture", "since")
232
+ "dr_venture", "since")
233
233
  end.to raise_error(TypeError,
234
- "Expected Hash but got String.")
234
+ "Expected Hash but got String.")
235
235
  end
236
236
  end
237
237
  end
@@ -254,7 +254,7 @@ shared_examples "Ohai::DSL::Plugin" do
254
254
  it "returns nil" do
255
255
  expect(
256
256
  plugin.get_attribute(:the_monarch, :henchmen,
257
- :corky_knightrider)
257
+ :corky_knightrider)
258
258
  ).to be nil
259
259
  end
260
260
  end
@@ -263,9 +263,9 @@ shared_examples "Ohai::DSL::Plugin" do
263
263
  it "raises a TypeError" do
264
264
  expect do
265
265
  plugin.get_attribute(:the_monarch, :arch_rival,
266
- :dr_venture, :since)
266
+ :dr_venture, :since)
267
267
  end.to raise_error(TypeError,
268
- "Expected Hash but got String.")
268
+ "Expected Hash but got String.")
269
269
  end
270
270
  end
271
271
  end
@@ -327,7 +327,7 @@ shared_examples "Ohai::DSL::Plugin" do
327
327
  it "returns false" do
328
328
  expect(
329
329
  plugin.attribute?("the_monarch", "henchmen",
330
- "corky_knightrider")
330
+ "corky_knightrider")
331
331
  ).to be false
332
332
  end
333
333
  end
@@ -336,9 +336,9 @@ shared_examples "Ohai::DSL::Plugin" do
336
336
  it "raises a TypeError" do
337
337
  expect do
338
338
  plugin.attribute?("the_monarch", "arch_rival",
339
- "dr_venture", "since")
339
+ "dr_venture", "since")
340
340
  end.to raise_error(TypeError,
341
- "Expected Hash but got String.")
341
+ "Expected Hash but got String.")
342
342
  end
343
343
  end
344
344
  end
@@ -360,7 +360,7 @@ shared_examples "Ohai::DSL::Plugin" do
360
360
  it "returns false" do
361
361
  expect(
362
362
  plugin.attribute?(:the_monarch, :henchmen,
363
- :corky_knightrider)
363
+ :corky_knightrider)
364
364
  ).to be false
365
365
  end
366
366
  end
@@ -369,9 +369,9 @@ shared_examples "Ohai::DSL::Plugin" do
369
369
  it "raises a TypeError" do
370
370
  expect do
371
371
  plugin.attribute?(:the_monarch, :arch_rival,
372
- :dr_venture, :since)
372
+ :dr_venture, :since)
373
373
  end.to raise_error(TypeError,
374
- "Expected Hash but got String.")
374
+ "Expected Hash but got String.")
375
375
  end
376
376
  end
377
377
  end
@@ -494,7 +494,7 @@ describe Ohai::DSL::Plugin::VersionVII do
494
494
 
495
495
  it "saves a list of platforms" do
496
496
  plugin = Ohai.plugin(:Test) { collect_data(:freebsd, :netbsd, :openbsd) {} }
497
- [:freebsd, :netbsd, :openbsd].each do |platform|
497
+ %i{freebsd netbsd openbsd}.each do |platform|
498
498
  expect(plugin.data_collector).to have_key(platform)
499
499
  end
500
500
  end
@@ -505,7 +505,7 @@ describe Ohai::DSL::Plugin::VersionVII do
505
505
  collect_data(:windows) {}
506
506
  collect_data(:darwin) {}
507
507
  end
508
- [:darwin, :default, :windows].each do |platform|
508
+ %i{darwin default windows}.each do |platform|
509
509
  expect(plugin.data_collector).to have_key(platform)
510
510
  end
511
511
  end
@@ -513,7 +513,7 @@ describe Ohai::DSL::Plugin::VersionVII do
513
513
  it "saves platforms across multiple plugins" do
514
514
  plugin = Ohai.plugin(:Test) { collect_data {} }
515
515
  plugin = Ohai.plugin(:Test) { collect_data(:aix, :sigar) {} }
516
- [:aix, :default, :sigar].each do |platform|
516
+ %i{aix default sigar}.each do |platform|
517
517
  expect(plugin.data_collector).to have_key(platform)
518
518
  end
519
519
  end
@@ -54,7 +54,7 @@ describe "Ohai::PluginConfig" do
54
54
  let(:value) do
55
55
  {
56
56
  bar0: true,
57
- bar1: [ :baz0, :baz1, :baz2 ],
57
+ bar1: %i{baz0 baz1 baz2},
58
58
  bar2: { qux0: true, qux1: false },
59
59
  }
60
60
  end
@@ -68,7 +68,7 @@ describe "Ohai::PluginConfig" do
68
68
  let(:value) do
69
69
  {
70
70
  :bar0 => true,
71
- "bar1" => [ :baz0, :baz1, :baz2 ],
71
+ "bar1" => %i{baz0 baz1 baz2},
72
72
  :bar2 => { qux0: true, qux1: false },
73
73
  }
74
74
  end
@@ -82,7 +82,7 @@ describe "Ohai::PluginConfig" do
82
82
  let(:value) do
83
83
  {
84
84
  bar0: true,
85
- bar1: [ :baz0, :baz1, :baz2 ],
85
+ bar1: %i{baz0 baz1 baz2},
86
86
  bar2: { :qux0 => true, "qux1" => false },
87
87
  }
88
88
  end
@@ -47,17 +47,17 @@ macvlan
47
47
  null
48
48
  overlay},
49
49
  "Authorization" => nil,
50
- "Log" => [
51
- "awslogs",
52
- "fluentd",
53
- "gcplogs",
54
- "gelf",
55
- "journald",
56
- "json-file",
57
- "logentries",
58
- "splunk",
59
- "syslog",
60
- ],
50
+ "Log" => %w{
51
+ awslogs
52
+ fluentd
53
+ gcplogs
54
+ gelf
55
+ journald
56
+ json-file
57
+ logentries
58
+ splunk
59
+ syslog
60
+ },
61
61
  },
62
62
  "networking" => {
63
63
  "ipv4_forwarding" => true,
@@ -400,7 +400,8 @@ describe Ohai::System, "plugin ec2" do
400
400
  "skunumber" => nil,
401
401
  "uuid" => "5A352AEC-CD91-E85F-BBFC-CC891D0BF9D6",
402
402
  "vendor" => "Xen",
403
- "version" => "4.2.amazon" })
403
+ "version" => "4.2.amazon" }
404
+ )
404
405
  end
405
406
  end
406
407
 
@@ -416,7 +417,8 @@ describe Ohai::System, "plugin ec2" do
416
417
  "skunumber" => nil,
417
418
  "uuid" => "5A352AEC-CD91-E85F-BBFC-CC891D0BF9D6",
418
419
  "vendor" => "Xen",
419
- "version" => "1.2.3" })
420
+ "version" => "1.2.3" }
421
+ )
420
422
  end
421
423
  end
422
424
 
@@ -27,9 +27,9 @@ describe Ohai::System, "plugin erlang" do
27
27
  erl_v_output = "Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 7.3\n"
28
28
  erl_systeminfo_output = "19.1,8.1,2.11"
29
29
  allow(plugin).to receive(:shell_out).with("erl +V")
30
- .and_return(mock_shell_out(0, "", erl_v_output))
30
+ .and_return(mock_shell_out(0, "", erl_v_output))
31
31
  allow(plugin).to receive(:shell_out).with("erl -eval '{ok, Ver} = file:read_file(filename:join([code:root_dir(), \"releases\", erlang:system_info(otp_release), \"OTP_VERSION\"])), Vsn = binary:bin_to_list(Ver, {0, byte_size(Ver) - 1}), io:format(\"~s,~s,~s\", [Vsn, erlang:system_info(version), erlang:system_info(nif_version)]), halt().' -noshell")
32
- .and_return(mock_shell_out(0, erl_systeminfo_output, ""))
32
+ .and_return(mock_shell_out(0, erl_systeminfo_output, ""))
33
33
  end
34
34
 
35
35
  it "sets languages[:erlang][:options]" do
@@ -64,9 +64,11 @@ describe Ohai::System, "hostname plugin" do
64
64
  before(:each) do
65
65
  allow(@plugin).to receive(:collect_os).and_return(:linux)
66
66
  allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(
67
- mock_shell_out(0, "katie", ""))
67
+ mock_shell_out(0, "katie", "")
68
+ )
68
69
  allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(
69
- mock_shell_out(0, "", ""), mock_shell_out(0, "katie.local", ""))
70
+ mock_shell_out(0, "", ""), mock_shell_out(0, "katie.local", "")
71
+ )
70
72
  end
71
73
 
72
74
  it "should be called twice" do
@@ -79,9 +81,11 @@ describe Ohai::System, "hostname plugin" do
79
81
  before(:each) do
80
82
  allow(@plugin).to receive(:collect_os).and_return(:linux)
81
83
  allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(
82
- mock_shell_out(0, "katie", ""))
84
+ mock_shell_out(0, "katie", "")
85
+ )
83
86
  allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(
84
- mock_shell_out(0, "katie.local", ""))
87
+ mock_shell_out(0, "katie.local", "")
88
+ )
85
89
  end
86
90
 
87
91
  it "should be not be called twice" do
@@ -109,7 +113,7 @@ describe Ohai::System, "hostname plugin for windows", :windows_only do
109
113
  "address1",
110
114
  "address2",
111
115
  "address3",
112
- "address4"
116
+ "address4",
113
117
  ]
114
118
  end
115
119
 
@@ -118,7 +122,7 @@ describe Ohai::System, "hostname plugin for windows", :windows_only do
118
122
  "local",
119
123
  [],
120
124
  23,
121
- "address"
125
+ "address",
122
126
  ]
123
127
  end
124
128
 
@@ -127,7 +131,7 @@ describe Ohai::System, "hostname plugin for windows", :windows_only do
127
131
  "local.dx.internal.cloudapp.net",
128
132
  [],
129
133
  23,
130
- "address"
134
+ "address",
131
135
  ]
132
136
  end
133
137
 
@@ -136,12 +140,12 @@ describe Ohai::System, "hostname plugin for windows", :windows_only do
136
140
  allow(WmiLite::Wmi).to receive(:new).and_return(success)
137
141
  allow(success).to receive(:first_of).with("Win32_ComputerSystem").and_return(host)
138
142
  allow(Socket).to receive(:gethostname).and_return("local")
139
- allow(Socket).to receive(:gethostbyname).with(anything()).and_return(info)
143
+ allow(Socket).to receive(:gethostbyname).with(anything).and_return(info)
140
144
  end
141
145
 
142
146
  context "when hostname is not set for the machine" do
143
147
  it "should return short machine name" do
144
- allow(Socket).to receive(:gethostbyaddr).with(anything()).and_return(local_hostent)
148
+ allow(Socket).to receive(:gethostbyaddr).with(anything).and_return(local_hostent)
145
149
  @plugin.run
146
150
  expect(@plugin[:fqdn]).to eq("local")
147
151
  end
@@ -149,7 +153,7 @@ describe Ohai::System, "hostname plugin for windows", :windows_only do
149
153
 
150
154
  context "when hostname is set for the machine" do
151
155
  it "should return the fqdn of the machine" do
152
- allow(Socket).to receive(:gethostbyaddr).with(anything()).and_return(fqdn_hostent)
156
+ allow(Socket).to receive(:gethostbyaddr).with(anything).and_return(fqdn_hostent)
153
157
  @plugin.run
154
158
  expect(@plugin[:fqdn]).to eq("local.dx.internal.cloudapp.net")
155
159
  end
@@ -410,6 +410,7 @@ describe Ohai::System, "Linux filesystem plugin" do
410
410
  allow(@double_file).to receive(:read_nonblock) do
411
411
  @counter += 1
412
412
  raise EOFError if @counter == 2
413
+
413
414
  @mounts
414
415
  end
415
416
  allow(@double_file).to receive(:close)
@@ -87,7 +87,8 @@ describe Ohai::System, "Linux lspci plugin" do
87
87
  NUMANode: 0
88
88
  LSPCI
89
89
  allow(plugin).to receive(:shell_out).with("lspci -vnnmk").and_return(
90
- mock_shell_out(0, @stdout, ""))
90
+ mock_shell_out(0, @stdout, "")
91
+ )
91
92
  end
92
93
 
93
94
  describe "when gathering data from lspci" do
@@ -101,6 +101,11 @@ describe Ohai::System, "Linux plugin platform" do
101
101
  expect(plugin.platform_id_remap("sles_sap")).to eq("suse")
102
102
  end
103
103
 
104
+ # https://github.com/chef/os_release/blob/master/archarm
105
+ it "returns arch for archarm" do
106
+ expect(plugin.platform_id_remap("archarm")).to eq("arch")
107
+ end
108
+
104
109
  # https://github.com/chef/os_release/blob/master/sles_15_0
105
110
  it "returns suse for sles os-release id" do
106
111
  expect(plugin.platform_id_remap("sles")).to eq("suse")
@@ -421,8 +421,8 @@ describe Ohai::System, "Network Plugin" do
421
421
  end
422
422
 
423
423
  it "warns about this conflict" do
424
- expect(@plugin.logger).to receive(:trace).with(/\[inet\] no ipaddress\/mask on eth1/).once
425
- expect(@plugin.logger).to receive(:trace).with(/\[inet6\] no ipaddress\/mask on eth1/).once
424
+ expect(@plugin.logger).to receive(:trace).with(%r{\[inet\] no ipaddress/mask on eth1}).once
425
+ expect(@plugin.logger).to receive(:trace).with(%r{\[inet6\] no ipaddress/mask on eth1}).once
426
426
  allow(@plugin.logger).to receive(:trace)
427
427
  @plugin.run
428
428
  end
@@ -822,6 +822,7 @@ describe Ohai::System, "Network Plugin" do
822
822
  @plugin["network"]["default_interface"] = nil
823
823
  @plugin["network"]["interfaces"].each do |i, iv|
824
824
  next if i == "lo"
825
+
825
826
  iv["addresses"].delete_if { |k, kv| kv["family"] == "inet" }
826
827
  end
827
828
  end
@@ -25,51 +25,32 @@ describe Ohai::System, "plugin openstack" do
25
25
 
26
26
  before(:each) do
27
27
  allow(plugin).to receive(:hint?).with("openstack").and_return(false)
28
- plugin[:dmi] = nil
28
+ plugin[:virtualization] = { system: {} }
29
29
  end
30
30
 
31
- context "when there is no relevant hint or dmi data" do
31
+ context "when there is no relevant hint or virtualization data" do
32
32
  it "does not set any openstack data" do
33
33
  plugin.run
34
34
  expect(plugin[:openstack]).to be_nil
35
35
  end
36
36
  end
37
37
 
38
- context "when DMI data is Openstack" do
38
+ context "when virtualization data is Openstack" do
39
39
  context "and the metadata service is not available" do
40
40
  before do
41
41
  allow(plugin).to receive(:can_socket_connect?)
42
42
  .with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80, default_timeout)
43
43
  .and_return(false)
44
- plugin[:dmi] = dmi_data
44
+ plugin[:virtualization] = { system: { guest: "openstack" } }
45
45
  plugin.run
46
46
  end
47
47
 
48
- context "with normal openstack metadata" do
49
- let(:dmi_data) do
50
- { system: { all_records: [ { Manufacturer: "OpenStack Foundation" } ] } }
51
- end
52
-
53
- it "sets openstack attribute" do
54
- expect(plugin[:openstack][:provider]).to eq("openstack")
55
- end
56
-
57
- it "doesn't set metadata attributes" do
58
- expect(plugin[:openstack][:instance_id]).to be_nil
59
- end
48
+ it "sets openstack attribute" do
49
+ expect(plugin[:openstack][:provider]).to eq("openstack")
60
50
  end
61
- context "with Red Hat openstack metadata" do
62
- let(:dmi_data) do
63
- { system: { manufacturer: "Red Hat", product_name: "OpenStack Compute" } }
64
- end
65
51
 
66
- it "sets openstack attribute" do
67
- expect(plugin[:openstack][:provider]).to eq("openstack")
68
- end
69
-
70
- it "doesn't set metadata attributes" do
71
- expect(plugin[:openstack][:instance_id]).to be_nil
72
- end
52
+ it "doesn't set metadata attributes" do
53
+ expect(plugin[:openstack][:instance_id]).to be_nil
73
54
  end
74
55
  end
75
56
  end
@@ -80,7 +61,7 @@ describe Ohai::System, "plugin openstack" do
80
61
  allow(plugin).to receive(:can_socket_connect?)
81
62
  .with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80, default_timeout)
82
63
  .and_return(false)
83
- plugin[:dmi] = { system: { all_records: [ { Manufacturer: "OpenStack Foundation" } ] } }
64
+ plugin[:virtualization] = { system: { guest: "openstack" } }
84
65
  plugin.run
85
66
  expect(plugin[:openstack][:provider]).to eq("dreamhost")
86
67
  end
@@ -114,8 +95,8 @@ describe Ohai::System, "plugin openstack" do
114
95
 
115
96
  it "overwrite timout by setting" do
116
97
  allow(plugin).to receive(:can_socket_connect?)
117
- .with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80, override_timout)
118
- .and_return(false)
98
+ .with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80, override_timout)
99
+ .and_return(false)
119
100
  allow(plugin).to receive(:hint?).with("openstack").and_return(true)
120
101
  plugin.run
121
102
  end
@@ -302,4 +283,24 @@ describe Ohai::System, "plugin openstack" do
302
283
  end
303
284
  end
304
285
  end
286
+
287
+ context "when openstack virtualization is present" do
288
+ context "and the metadata service is not available" do
289
+ before do
290
+ allow(plugin).to receive(:can_socket_connect?)
291
+ .with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80, default_timeout)
292
+ .and_return(false)
293
+ plugin[:virtualization] = { system: { guest: "openstack" } }
294
+ plugin.run
295
+ end
296
+
297
+ it "sets openstack provider attribute since virtualization is present" do
298
+ expect(plugin[:openstack][:provider]).to eq("openstack")
299
+ end
300
+
301
+ it "doesn't set metadata attributes" do
302
+ expect(plugin[:openstack][:instance_id]).to be_nil
303
+ end
304
+ end
305
+ end
305
306
  end