ohai 15.3.1 → 15.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -6
- data/lib/ohai/mixin/{network_constants.rb → network_helper.rb} +8 -1
- data/lib/ohai/plugins/aix/network.rb +3 -8
- data/lib/ohai/plugins/darwin/network.rb +6 -4
- data/lib/ohai/plugins/filesystem.rb +166 -0
- data/lib/ohai/plugins/network.rb +5 -5
- data/lib/ohai/plugins/openstack.rb +2 -1
- data/lib/ohai/plugins/solaris2/network.rb +6 -4
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +1 -1
- metadata +3 -162
- data/Rakefile +0 -42
- data/lib/ohai/plugins/windows/filesystem.rb +0 -147
- data/spec/data/plugins/dpkg-query.output +0 -4
- data/spec/data/plugins/lslpp.output +0 -50
- data/spec/data/plugins/pacman.output +0 -51
- data/spec/data/plugins/pkg-query.output +0 -58
- data/spec/data/plugins/pkginfo.output +0 -50
- data/spec/data/plugins/pkglist.output +0 -24
- data/spec/data/plugins/rpmquery.output +0 -7
- data/spec/functional/application_spec.rb +0 -107
- data/spec/functional/loader_spec.rb +0 -53
- data/spec/functional/plugins/powershell_spec.rb +0 -88
- data/spec/functional/plugins/root_group_spec.rb +0 -41
- data/spec/functional/plugins/windows/uptime_spec.rb +0 -51
- data/spec/ohai_spec.rb +0 -27
- data/spec/rcov.opts +0 -2
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -124
- data/spec/support/integration_helper.rb +0 -61
- data/spec/support/platform_helpers.rb +0 -38
- data/spec/unit/application_spec.rb +0 -96
- data/spec/unit/config_spec.rb +0 -57
- data/spec/unit/dsl/plugin_spec.rb +0 -634
- data/spec/unit/hints_spec.rb +0 -65
- data/spec/unit/loader_spec.rb +0 -195
- data/spec/unit/mixin/azure_metadata_spec.rb +0 -72
- data/spec/unit/mixin/command_spec.rb +0 -151
- data/spec/unit/mixin/dmi_decode.rb +0 -75
- data/spec/unit/mixin/ec2_metadata_spec.rb +0 -88
- data/spec/unit/mixin/softlayer_metadata_spec.rb +0 -72
- data/spec/unit/plugin_config_spec.rb +0 -117
- data/spec/unit/plugins/abort_spec.rb +0 -69
- data/spec/unit/plugins/aix/cpu_spec.rb +0 -127
- data/spec/unit/plugins/aix/filesystem_spec.rb +0 -238
- data/spec/unit/plugins/aix/hostname_spec.rb +0 -33
- data/spec/unit/plugins/aix/kernel_spec.rb +0 -61
- data/spec/unit/plugins/aix/memory_spec.rb +0 -49
- data/spec/unit/plugins/aix/network_spec.rb +0 -313
- data/spec/unit/plugins/aix/platform_spec.rb +0 -44
- data/spec/unit/plugins/aix/uptime_spec.rb +0 -42
- data/spec/unit/plugins/aix/virtualization_spec.rb +0 -319
- data/spec/unit/plugins/azure_spec.rb +0 -243
- data/spec/unit/plugins/bsd/filesystem_spec.rb +0 -138
- data/spec/unit/plugins/bsd/virtualization_spec.rb +0 -145
- data/spec/unit/plugins/c_spec.rb +0 -341
- data/spec/unit/plugins/chef_spec.rb +0 -44
- data/spec/unit/plugins/cloud_spec.rb +0 -484
- data/spec/unit/plugins/darwin/cpu_spec.rb +0 -124
- data/spec/unit/plugins/darwin/filesystem_spec.rb +0 -140
- data/spec/unit/plugins/darwin/hardware_spec.rb +0 -105
- data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +0 -1110
- data/spec/unit/plugins/darwin/hostname_spec.rb +0 -43
- data/spec/unit/plugins/darwin/kernel_spec.rb +0 -65
- data/spec/unit/plugins/darwin/memory_spec.rb +0 -64
- data/spec/unit/plugins/darwin/network_spec.rb +0 -849
- data/spec/unit/plugins/darwin/platform_spec.rb +0 -71
- data/spec/unit/plugins/darwin/virtualization_spec.rb +0 -156
- data/spec/unit/plugins/digital_ocean_spec.rb +0 -106
- data/spec/unit/plugins/dmi_spec.rb +0 -156
- data/spec/unit/plugins/docker_spec.rb +0 -100
- data/spec/unit/plugins/ec2_spec.rb +0 -452
- data/spec/unit/plugins/elixir_spec.rb +0 -55
- data/spec/unit/plugins/erlang_spec.rb +0 -71
- data/spec/unit/plugins/eucalyptus_spec.rb +0 -109
- data/spec/unit/plugins/fail_spec.rb +0 -260
- data/spec/unit/plugins/freebsd/cpu_spec.rb +0 -129
- data/spec/unit/plugins/freebsd/hostname_spec.rb +0 -35
- data/spec/unit/plugins/freebsd/kernel_spec.rb +0 -36
- data/spec/unit/plugins/freebsd/platform_spec.rb +0 -38
- data/spec/unit/plugins/gce_spec.rb +0 -81
- data/spec/unit/plugins/go_spec.rb +0 -48
- data/spec/unit/plugins/groovy_spec.rb +0 -66
- data/spec/unit/plugins/haskell_spec.rb +0 -231
- data/spec/unit/plugins/hostname_spec.rb +0 -162
- data/spec/unit/plugins/init_package_spec.rb +0 -60
- data/spec/unit/plugins/java_spec.rb +0 -230
- data/spec/unit/plugins/joyent_spec.rb +0 -100
- data/spec/unit/plugins/kernel_spec.rb +0 -38
- data/spec/unit/plugins/linode_spec.rb +0 -135
- data/spec/unit/plugins/linux/block_device_spec.rb +0 -75
- data/spec/unit/plugins/linux/cpu_spec.rb +0 -441
- data/spec/unit/plugins/linux/filesystem_spec.rb +0 -550
- data/spec/unit/plugins/linux/fips_spec.rb +0 -60
- data/spec/unit/plugins/linux/hostname_spec.rb +0 -52
- data/spec/unit/plugins/linux/hostnamectl_spec.rb +0 -59
- data/spec/unit/plugins/linux/kernel_spec.rb +0 -71
- data/spec/unit/plugins/linux/lsb_spec.rb +0 -147
- data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
- data/spec/unit/plugins/linux/machineid_spec.rb +0 -46
- data/spec/unit/plugins/linux/mdadm_spec.rb +0 -170
- data/spec/unit/plugins/linux/memory_spec.rb +0 -256
- data/spec/unit/plugins/linux/network_spec.rb +0 -1392
- data/spec/unit/plugins/linux/platform_spec.rb +0 -812
- data/spec/unit/plugins/linux/sessions_spec.rb +0 -98
- data/spec/unit/plugins/linux/sysctl_spec.rb +0 -53
- data/spec/unit/plugins/linux/systemd_paths_spec.rb +0 -122
- data/spec/unit/plugins/linux/uptime_spec.rb +0 -48
- data/spec/unit/plugins/linux/virtualization_spec.rb +0 -650
- data/spec/unit/plugins/lua_spec.rb +0 -60
- data/spec/unit/plugins/mono_spec.rb +0 -67
- data/spec/unit/plugins/netbsd/hostname_spec.rb +0 -43
- data/spec/unit/plugins/netbsd/kernel_spec.rb +0 -35
- data/spec/unit/plugins/netbsd/platform_spec.rb +0 -38
- data/spec/unit/plugins/network_spec.rb +0 -1078
- data/spec/unit/plugins/nodejs_spec.rb +0 -55
- data/spec/unit/plugins/ohai_spec.rb +0 -32
- data/spec/unit/plugins/ohai_time_spec.rb +0 -44
- data/spec/unit/plugins/openbsd/hostname_spec.rb +0 -43
- data/spec/unit/plugins/openbsd/kernel_spec.rb +0 -36
- data/spec/unit/plugins/openbsd/platform_spec.rb +0 -33
- data/spec/unit/plugins/openstack_spec.rb +0 -311
- data/spec/unit/plugins/os_spec.rb +0 -115
- data/spec/unit/plugins/packages_spec.rb +0 -353
- data/spec/unit/plugins/passwd_spec.rb +0 -65
- data/spec/unit/plugins/perl_spec.rb +0 -62
- data/spec/unit/plugins/php_spec.rb +0 -97
- data/spec/unit/plugins/platform_spec.rb +0 -65
- data/spec/unit/plugins/powershell_spec.rb +0 -71
- data/spec/unit/plugins/python_spec.rb +0 -51
- data/spec/unit/plugins/rackspace_spec.rb +0 -350
- data/spec/unit/plugins/root_group_spec.rb +0 -90
- data/spec/unit/plugins/ruby_spec.rb +0 -60
- data/spec/unit/plugins/rust_spec.rb +0 -43
- data/spec/unit/plugins/scala_spec.rb +0 -58
- data/spec/unit/plugins/scaleway_spec.rb +0 -93
- data/spec/unit/plugins/scsi_spec.rb +0 -69
- data/spec/unit/plugins/shard_spec.rb +0 -121
- data/spec/unit/plugins/shells_spec.rb +0 -56
- data/spec/unit/plugins/softlayer_spec.rb +0 -60
- data/spec/unit/plugins/solaris2/cpu_spec.rb +0 -2926
- data/spec/unit/plugins/solaris2/dmi_spec.rb +0 -153
- data/spec/unit/plugins/solaris2/filesystem.rb +0 -407
- data/spec/unit/plugins/solaris2/hostname_spec.rb +0 -37
- data/spec/unit/plugins/solaris2/kernel_spec.rb +0 -183
- data/spec/unit/plugins/solaris2/memory_spec.rb +0 -43
- data/spec/unit/plugins/solaris2/network_spec.rb +0 -201
- data/spec/unit/plugins/solaris2/platform_spec.rb +0 -108
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +0 -97
- data/spec/unit/plugins/ssh_host_keys_spec.rb +0 -116
- data/spec/unit/plugins/sysconf_spec.rb +0 -680
- data/spec/unit/plugins/timezone_spec.rb +0 -30
- data/spec/unit/plugins/vbox_host_spec.rb +0 -14
- data/spec/unit/plugins/virtualbox_spec.rb +0 -375
- data/spec/unit/plugins/vmware_spec.rb +0 -81
- data/spec/unit/plugins/windows/cpu_spec.rb +0 -118
- data/spec/unit/plugins/windows/filesystem_spec.rb +0 -226
- data/spec/unit/plugins/windows/fips_spec.rb +0 -60
- data/spec/unit/plugins/windows/kernel_spec.rb +0 -79
- data/spec/unit/plugins/windows/memory_spec.rb +0 -52
- data/spec/unit/plugins/windows/network_spec.rb +0 -137
- data/spec/unit/plugins/windows/system_enclosure_spec.rb +0 -45
- data/spec/unit/plugins/windows/uptime_spec.rb +0 -38
- data/spec/unit/plugins/windows/virtualization_spec.rb +0 -63
- data/spec/unit/plugins/zpools_spec.rb +0 -244
- data/spec/unit/provides_map_spec.rb +0 -208
- data/spec/unit/runner_spec.rb +0 -422
- data/spec/unit/system_spec.rb +0 -416
- data/spec/unit/util/file_helper_spec.rb +0 -47
- data/spec/unit/util/ip_helper_spec.rb +0 -128
@@ -1,90 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Joseph Anthony Pasquale Holsten (<joseph@josephholsten.com>)
|
3
|
-
# Copyright:: Copyright (c) 2013 Joseph Anthony Pasquale Holsten
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "spec_helper"
|
20
|
-
|
21
|
-
describe Ohai::System, "root_group" do
|
22
|
-
before do
|
23
|
-
@plugin = get_plugin("root_group")
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "unix platform", :unix_only do
|
27
|
-
before do
|
28
|
-
# this is deeply intertwingled. unfortunately, the law of demeter
|
29
|
-
# apparently didn't apply to this api. we're just trying to fake
|
30
|
-
# Etc.getgrgid(Etc.getpwnam('root').gid).name
|
31
|
-
@pwnam = Object.new
|
32
|
-
allow(@pwnam).to receive(:gid).and_return(0)
|
33
|
-
allow(Etc).to receive(:getpwnam).with("root").and_return(@pwnam)
|
34
|
-
@grgid = Object.new
|
35
|
-
allow(Etc).to receive(:getgrgid).and_return(@grgid)
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "with wheel group" do
|
39
|
-
before do
|
40
|
-
allow(@grgid).to receive(:name).and_return("wheel")
|
41
|
-
end
|
42
|
-
|
43
|
-
it "has a root_group of wheel" do
|
44
|
-
@plugin.run
|
45
|
-
expect(@plugin[:root_group]).to eq("wheel")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "with root group" do
|
50
|
-
before do
|
51
|
-
allow(@grgid).to receive(:name).and_return("root")
|
52
|
-
end
|
53
|
-
|
54
|
-
it "has a root_group of root" do
|
55
|
-
@plugin.run
|
56
|
-
expect(@plugin[:root_group]).to eq("root")
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "platform aix with system group" do
|
61
|
-
before do
|
62
|
-
allow(@grgid).to receive(:name).and_return("system")
|
63
|
-
end
|
64
|
-
|
65
|
-
it "has a root_group of system" do
|
66
|
-
@plugin.run
|
67
|
-
expect(@plugin[:root_group]).to eq("system")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "windows platform" do
|
73
|
-
|
74
|
-
let(:wmi) { double("wmi", { query: "" }) }
|
75
|
-
|
76
|
-
before do
|
77
|
-
allow(WmiLite::Wmi).to receive(:new).and_return(wmi)
|
78
|
-
allow(@plugin).to receive(:collect_os).and_return(:windows)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "returns the group Administrators" do
|
82
|
-
expect(wmi)
|
83
|
-
.to receive(:query)
|
84
|
-
.with("select * from Win32_Group where sid like 'S-1-5-32-544' and LocalAccount=True")
|
85
|
-
.and_return("Administrators")
|
86
|
-
|
87
|
-
@plugin.run
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "spec_helper"
|
20
|
-
|
21
|
-
ruby_bin = File.join(::RbConfig::CONFIG["bindir"], ::RbConfig::CONFIG["ruby_install_name"])
|
22
|
-
|
23
|
-
describe Ohai::System, "plugin ruby" do
|
24
|
-
|
25
|
-
before(:all) do
|
26
|
-
@plugin = get_plugin("ruby")
|
27
|
-
@plugin[:languages] = Mash.new
|
28
|
-
@plugin.run
|
29
|
-
|
30
|
-
@ruby_ohai_data_pristine = @plugin[:languages][:ruby]
|
31
|
-
end
|
32
|
-
|
33
|
-
before do
|
34
|
-
@ruby_ohai_data = @ruby_ohai_data_pristine.dup
|
35
|
-
end
|
36
|
-
|
37
|
-
{
|
38
|
-
platform: RUBY_PLATFORM,
|
39
|
-
version: RUBY_VERSION,
|
40
|
-
release_date: RUBY_RELEASE_DATE,
|
41
|
-
target: ::RbConfig::CONFIG["target"],
|
42
|
-
target_cpu: ::RbConfig::CONFIG["target_cpu"],
|
43
|
-
target_vendor: ::RbConfig::CONFIG["target_vendor"],
|
44
|
-
target_os: ::RbConfig::CONFIG["target_os"],
|
45
|
-
host: ::RbConfig::CONFIG["host"],
|
46
|
-
host_cpu: ::RbConfig::CONFIG["host_cpu"],
|
47
|
-
host_os: ::RbConfig::CONFIG["host_os"],
|
48
|
-
host_vendor: ::RbConfig::CONFIG["host_vendor"],
|
49
|
-
gems_dir: `#{ruby_bin} #{::RbConfig::CONFIG["bindir"]}/gem env gemdir`.chomp,
|
50
|
-
gem_bin: [ ::Gem.default_exec_format % "gem", "gem" ].map do |bin|
|
51
|
-
"#{::RbConfig::CONFIG["bindir"]}/#{bin}"
|
52
|
-
end.find { |bin| ::File.exist? bin },
|
53
|
-
ruby_bin: ruby_bin,
|
54
|
-
}.each do |attribute, value|
|
55
|
-
it "has #{attribute} set to #{value.inspect}" do
|
56
|
-
expect(@ruby_ohai_data[attribute]).to eql(value)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# Author:: Christopher M Luciano (<cmlucian@us.ibm.com>)
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
#
|
16
|
-
|
17
|
-
require "spec_helper"
|
18
|
-
|
19
|
-
describe Ohai::System, "plugin rust" do
|
20
|
-
let(:stdout) { "rustc 1.0.0-nightly (29bd9a06e 2015-01-20 23:03:09 +0000)" }
|
21
|
-
let(:plugin) do
|
22
|
-
plugin = get_plugin("rust")
|
23
|
-
plugin[:languages] = Mash.new
|
24
|
-
allow(plugin).to receive(:shell_out).with("rustc --version").and_return(mock_shell_out(0, stdout, ""))
|
25
|
-
plugin
|
26
|
-
end
|
27
|
-
|
28
|
-
it "gets the rust version" do
|
29
|
-
expect(plugin).to receive(:shell_out).with("rustc --version").and_return(mock_shell_out(0, stdout, ""))
|
30
|
-
plugin.run
|
31
|
-
end
|
32
|
-
|
33
|
-
it "sets languages[:rust][:version]" do
|
34
|
-
plugin.run
|
35
|
-
expect(plugin.languages[:rust][:version]).to eql("1.0.0-nightly")
|
36
|
-
end
|
37
|
-
|
38
|
-
it "does not set the languages[:rust] if rust command fails" do
|
39
|
-
allow(plugin).to receive(:shell_out).with("rustc --version").and_return(mock_shell_out(1, stdout, ""))
|
40
|
-
plugin.run
|
41
|
-
expect(plugin.languages).not_to have_key(:rust)
|
42
|
-
end
|
43
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# Author:: Christopher M Luciano (<cmlucian@us.ibm.com>)
|
2
|
-
# © Copyright IBM Corporation 2015.
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
require "spec_helper"
|
19
|
-
|
20
|
-
describe Ohai::System, "plugin scala" do
|
21
|
-
|
22
|
-
let(:plugin) do
|
23
|
-
get_plugin("scala").tap do |plugin|
|
24
|
-
plugin[:languages] = Mash.new
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
let(:scala_out) { "Scala code runner version 2.11.6 -- Copyright 2002-2013, LAMP/EPFL" }
|
29
|
-
|
30
|
-
def setup_plugin
|
31
|
-
allow(plugin).to receive(:shell_out)
|
32
|
-
.with("scala -version")
|
33
|
-
.and_return(mock_shell_out(0, "", scala_out))
|
34
|
-
end
|
35
|
-
|
36
|
-
context "if scala is installed" do
|
37
|
-
before do
|
38
|
-
setup_plugin
|
39
|
-
plugin.run
|
40
|
-
end
|
41
|
-
|
42
|
-
it "sets languages[:scala][:version]" do
|
43
|
-
expect(plugin[:languages][:scala][:version]).to eql("2.11.6")
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context "if scala is not installed" do
|
48
|
-
before do
|
49
|
-
allow(plugin).to receive(:shell_out)
|
50
|
-
.and_raise( Ohai::Exceptions::Exec )
|
51
|
-
plugin.run
|
52
|
-
end
|
53
|
-
|
54
|
-
it "does NOT set the languages[:scala] if scala commands fails" do
|
55
|
-
expect(plugin[:languages]).not_to have_key(:scala)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Jonathan Amiez (<jonathan.amiez@gmail.com>)
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
require "spec_helper"
|
19
|
-
|
20
|
-
describe Ohai::System, "plugin scaleway" do
|
21
|
-
let(:plugin) { get_plugin("scaleway") }
|
22
|
-
|
23
|
-
before do
|
24
|
-
allow(plugin).to receive(:hint?).with("scaleway").and_return(false)
|
25
|
-
allow(File).to receive(:read).with("/proc/cmdline").and_return(false)
|
26
|
-
end
|
27
|
-
|
28
|
-
shared_examples_for "!scaleway" do
|
29
|
-
it "does not attempt to fetch the scaleway metadata" do
|
30
|
-
expect(plugin).not_to receive(:http_client)
|
31
|
-
expect(plugin[:scaleway]).to be_nil
|
32
|
-
plugin.run
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
shared_examples_for "scaleway" do
|
37
|
-
before do
|
38
|
-
@http_client = double("Net::HTTP client")
|
39
|
-
allow(plugin).to receive(:http_client).and_return(@http_client)
|
40
|
-
allow(IO).to receive(:select).and_return([[], [1], []])
|
41
|
-
t = double("connection")
|
42
|
-
allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS)
|
43
|
-
allow(Socket).to receive(:new).and_return(t)
|
44
|
-
allow(Socket).to receive(:pack_sockaddr_in).and_return(nil)
|
45
|
-
end
|
46
|
-
|
47
|
-
let(:body) do
|
48
|
-
'{"tags": [], "state_detail": "booted", "public_ip": {"dynamic": false, "id": "7564c721-a128-444e-9c95-0754a7616482", "address": "5.1.9.3"}, "ssh_public_keys": [{"key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEA5qK2s41yyrNpaXXiQtb/1ADaVHVZZp9rYEtG6Dz7trOPtxkxNsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/j2C+NAzo6TZCLTbJjBf89ieazqVqhY/dMNLDJINY2Ss2ytgyiJm9bp5bYcZz441czijBlmY/qmI0cFCVOJoDq6X9Lmn/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee+hmLFaTE3FeMr1hmeZT2ChH6ruHi8m6m18SfW0fl2fS8zG4yB+WE2IawdsoZmtgtY/Re3CpvhYP9S/JxpUedl+zzzzzzzzzzzzzzzzz5+YONBAt/PWMelXThfMukbwykto6IXmsX2qflBPsRVrWe0D7vt48loVScHDv5D05ZwqWY9rizFqCx3Y8xCLr6649ieonnnjHEsSOBREU507eXVJL6njHard+s+vuTC4bNH5LiP2INQS+9MaT37/l8WzIAL3U+hvcj95HS8KfATX+7XWa54bGJgeOnPle8ojwp1ssl7ddh2yFJozgk2CkUEyE4f1lmEX2YFJGoEoaW0QC2j0nNYiLs37yHG0h84AOgjoIAJo1rxpBAGGJOgFTkgnSdHjtDZsC9WjJYeu/QpxQ7Lf2Z+FCKoypfnZz/F10/z6nxnkZ3IKKM=", "fingerprint": "4096 4c:71:db:64:cd:24:da:4a:fa:5f:9e:70:af:ea:40:6e (no comment) (RSA)"}], "private_ip": "10.8.23.7", "timezone": "UTC", "id": "77fab916-e7ff-44c6-a025-ae08837b4c4f", "extra_networks": [], "name": "sample-hostname", "hostname": "sample-hostname", "bootscript": {"kernel": "http://169.254.42.24/kernel/x86_64-4.9.20-std-1/vmlinuz-4.9.20-std-1", "title": "x86_64 4.9.20 std #1 (longterm/latest)", "default": false, "dtb": "", "public": false, "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.12.7.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local", "architecture": "x86_64", "organization": "11111110-1112-4112-8112-111111111116", "id": "855f21ba-e7f9-421d-91b0-976a6ad59910"}, "location": {"platform_id": "21", "hypervisor_id": "518", "node_id": "4", "cluster_id": "82", "zone_id": "par1"}, "volumes": {"0": {"name": "x86_64-debian-stretch-2017-06-29_10:17", "modification_date": "2018-01-26T10:22:28.268074+00:00", "export_uri": "device://dev/vda", "volume_type": "l_ssd", "creation_date": "2018-01-26T10:22:28.268074+00:00", "organization": "90f39224-d0a2-4771-a2f0-1036a9402b97", "server": {"id": "77fab916-e7ff-44c6-a024-ae08837b4c4f", "name": "sample-hostname"}, "id": "3be53d4d-93d7-4430-a513-61cb4410624b", "size": 50000000000}}, "ipv6": null, "organization": "89f39224-d0a2-4771-a2f0-1036a9402b97", "commercial_type": "VC1S"}'
|
49
|
-
end
|
50
|
-
|
51
|
-
it "fetches and properly parse json metadata" do
|
52
|
-
expect(@http_client).to receive(:get)
|
53
|
-
.with("/conf?format=json")
|
54
|
-
.and_return(double("Net::HTTP Response", body: body, code: "200"))
|
55
|
-
plugin.run
|
56
|
-
|
57
|
-
expect(plugin[:scaleway]).not_to be_nil
|
58
|
-
expect(plugin[:scaleway]["id"]).to eq("77fab916-e7ff-44c6-a025-ae08837b4c4f")
|
59
|
-
expect(plugin[:scaleway]["hostname"]).to eq("sample-hostname")
|
60
|
-
end
|
61
|
-
|
62
|
-
it "completes the run despite unavailable metadata" do
|
63
|
-
expect(@http_client).to receive(:get)
|
64
|
-
.with("/conf?format=json")
|
65
|
-
.and_return(double("Net::HTTP Response", body: "", code: "404"))
|
66
|
-
plugin.run
|
67
|
-
|
68
|
-
expect(plugin[:scaleway]).not_to be_nil
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "without hint or cmdline" do
|
73
|
-
it_behaves_like "!scaleway"
|
74
|
-
end
|
75
|
-
|
76
|
-
describe "with scaleway hint file" do
|
77
|
-
before do
|
78
|
-
allow(plugin).to receive(:hint?).with("scaleway").and_return(true)
|
79
|
-
end
|
80
|
-
|
81
|
-
it_behaves_like "scaleway"
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
describe "with scaleway cmdline" do
|
86
|
-
before do
|
87
|
-
allow(File).to receive(:read).with("/proc/cmdline").and_return("initrd=initrd showopts console=ttyS0,115200 nousb vga=0 root=/dev/vda scaleway boot=local")
|
88
|
-
end
|
89
|
-
|
90
|
-
it_behaves_like "scaleway"
|
91
|
-
|
92
|
-
end
|
93
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Phil Dibowitz <phil@ipom.com>
|
3
|
-
# Copyright:: Copyright (c) 2018 Facebook, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "spec_helper"
|
20
|
-
|
21
|
-
describe Ohai::System, "lsscsi plugin" do
|
22
|
-
let(:plugin) { get_plugin("scsi") }
|
23
|
-
|
24
|
-
before do
|
25
|
-
allow(plugin).to receive(:collect_os).and_return(:linux)
|
26
|
-
@stdout = <<~LSSCSI
|
27
|
-
[5:0:0:0] disk ATA Hitachi HUA72205 A3EA /dev/sda
|
28
|
-
[6:2:0:0] disk LSI MR9286CV-8e 3.41 /dev/sdb
|
29
|
-
[6:2:1:0] disk LSI MR9286CV-8e 3.41 /dev/sdc
|
30
|
-
[6:2:2:0] disk LSI MR9286CV-8e 3.41 /dev/sdd
|
31
|
-
[6:2:3:0] disk LSI MR9286CV-8e 3.41 /dev/sde
|
32
|
-
[6:2:4:0] disk LSI MR9286CV-8e 3.41 /dev/sdf
|
33
|
-
LSSCSI
|
34
|
-
allow(plugin).to receive(:shell_out).with("lsscsi").and_return(
|
35
|
-
mock_shell_out(0, @stdout, "")
|
36
|
-
)
|
37
|
-
plugin.run
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "when gathering data from lsscsi" do
|
41
|
-
it "lists all devices" do
|
42
|
-
expect(plugin[:scsi].keys).to eq(
|
43
|
-
["5:0:0:0", "6:2:0:0", "6:2:1:0", "6:2:2:0", "6:2:3:0", "6:2:4:0"]
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
it "parses out type" do
|
48
|
-
expect(plugin[:scsi]["6:2:0:0"]["type"]).to eq("disk")
|
49
|
-
end
|
50
|
-
|
51
|
-
it "parses out transport" do
|
52
|
-
expect(plugin[:scsi]["5:0:0:0"]["transport"]).to eq("ATA")
|
53
|
-
expect(plugin[:scsi]["6:2:0:0"]["transport"]).to eq("LSI")
|
54
|
-
end
|
55
|
-
|
56
|
-
it "parses out device" do
|
57
|
-
expect(plugin[:scsi]["6:2:0:0"]["device"]).to eq("/dev/sdb")
|
58
|
-
end
|
59
|
-
|
60
|
-
it "parses out revision" do
|
61
|
-
expect(plugin[:scsi]["6:2:3:0"]["revision"]).to eq("3.41")
|
62
|
-
end
|
63
|
-
|
64
|
-
it "parses out name" do
|
65
|
-
expect(plugin[:scsi]["5:0:0:0"]["name"]).to eq("Hitachi HUA72205")
|
66
|
-
expect(plugin[:scsi]["6:2:4:0"]["name"]).to eq("MR9286CV-8e")
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Davide Cavalca <dcavalca@fb.com>
|
3
|
-
# Copyright:: Copyright (c) 2016 Facebook
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "digest/md5"
|
20
|
-
require "spec_helper"
|
21
|
-
|
22
|
-
describe Ohai::System, "shard plugin" do
|
23
|
-
subject do
|
24
|
-
plugin.run
|
25
|
-
plugin[:shard_seed]
|
26
|
-
end
|
27
|
-
|
28
|
-
let(:plugin) { get_plugin("shard") }
|
29
|
-
let(:fqdn) { "somehost004.someregion.somecompany.com" }
|
30
|
-
let(:uuid) { "48555CF4-5BB1-21D9-BC4C-E8B73DDE5801" }
|
31
|
-
let(:serial) { "234du3m4i498xdjr2" }
|
32
|
-
let(:machine_id) { "0a1f869f457a4c8080ab19faf80af9cc" }
|
33
|
-
let(:machinename) { "somehost004" }
|
34
|
-
let(:fips) { false }
|
35
|
-
let(:os) { "linux" }
|
36
|
-
|
37
|
-
before do
|
38
|
-
plugin["machinename"] = machinename
|
39
|
-
plugin["machine_id"] = machine_id
|
40
|
-
plugin["fqdn"] = fqdn
|
41
|
-
plugin["dmi"] = { "system" => {} }
|
42
|
-
plugin["dmi"]["system"]["uuid"] = uuid
|
43
|
-
plugin["dmi"]["system"]["serial_number"] = serial
|
44
|
-
plugin["fips"] = { "kernel" => { "enabled" => fips } }
|
45
|
-
allow(plugin).to receive(:collect_os).and_return(os)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "provides a shard with a default-safe set of sources" do
|
49
|
-
expect(subject).to eq(27767217)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "provides a shard with a configured source" do
|
53
|
-
Ohai.config[:plugin][:shard_seed][:sources] = [:fqdn]
|
54
|
-
expect(subject).to eq(203669792)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "fails on an unrecognized source" do
|
58
|
-
Ohai.config[:plugin][:shard_seed][:sources] = [:GreatGooglyMoogly]
|
59
|
-
expect { subject }.to raise_error(RuntimeError)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "provides a shard with a configured algorithm" do
|
63
|
-
Ohai.config[:plugin][:shard_seed][:digest_algorithm] = "sha256"
|
64
|
-
expect(Digest::MD5).not_to receive(:new)
|
65
|
-
expect(subject).to eq(117055036)
|
66
|
-
end
|
67
|
-
|
68
|
-
context "with Darwin OS" do
|
69
|
-
let(:os) { "darwin" }
|
70
|
-
|
71
|
-
before do
|
72
|
-
plugin.data.delete("fips") # FIPS is undefined on Macs, make sure this still work
|
73
|
-
plugin["hardware"] = { "serial_number" => serial, "platform_UUID" => uuid }
|
74
|
-
end
|
75
|
-
|
76
|
-
it "provides a shard with a default-safe set of sources" do
|
77
|
-
expect(subject).to eq(27767217)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "with Windows OS" do
|
82
|
-
let(:os) { "windows" }
|
83
|
-
|
84
|
-
before do
|
85
|
-
wmi = double("WmiLite::Wmi")
|
86
|
-
allow(WmiLite::Wmi).to receive(:new).and_return(wmi)
|
87
|
-
allow(wmi).to receive(:first_of).with("Win32_BIOS").and_return("SerialNumber" => serial)
|
88
|
-
allow(wmi).to receive(:first_of).with("Win32_ComputerSystemProduct").and_return("UUID" => uuid)
|
89
|
-
plugin["kernel"] = { "os_info" => { "serial_number" => serial + "0" } }
|
90
|
-
plugin.data.delete("dmi") # To make sure we aren't using the wrong data.
|
91
|
-
end
|
92
|
-
|
93
|
-
it "provides a shard with a default-safe set of sources" do
|
94
|
-
expect(subject).to eq(27767217)
|
95
|
-
end
|
96
|
-
|
97
|
-
it "allows os_serial source" do
|
98
|
-
Ohai.config[:plugin][:shard_seed][:sources] = %i{machinename os_serial uuid}
|
99
|
-
# Different from above.
|
100
|
-
expect(subject).to eq(178738102)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context "with a weird OS" do
|
105
|
-
let(:os) { "aix" }
|
106
|
-
|
107
|
-
it "provides a shard with a default-safe set of sources" do
|
108
|
-
# Note: this is different than the other defaults.
|
109
|
-
expect(subject).to eq(253499154)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context "with FIPS mode enabled" do
|
114
|
-
let(:fips) { true }
|
115
|
-
|
116
|
-
it "uses SHA2" do
|
117
|
-
expect(Digest::MD5).not_to receive(:hexdigest)
|
118
|
-
expect(subject).to eq(117055036)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|