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,75 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Tim Smith (tsmith@chef.io)
|
3
|
-
# Copyright:: Copyright (c) 2018 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
|
-
require "ohai/mixin/dmi_decode"
|
21
|
-
|
22
|
-
describe Ohai::Mixin::DmiDecode, "guest_from_dmi_data" do
|
23
|
-
let(:mixin) { Object.new.extend(Ohai::Mixin::DmiDecode) }
|
24
|
-
|
25
|
-
# for the full DMI data used in these tests see https://github.com/chef/dmidecode_collection
|
26
|
-
# the fields here are manufacturer, product, and version as passed to #guest_from_dmi_data
|
27
|
-
{
|
28
|
-
xen: ["Xen", "HVM domU", "4.2.amazon"],
|
29
|
-
vmware: ["VMware, Inc.", "VMware Virtual Platform", "None"],
|
30
|
-
hyperv: ["Microsoft", "Virtual Machine", "7.0"],
|
31
|
-
amazonec2: ["Amazon EC2", "c5n.large", "Not Specified"],
|
32
|
-
veertu: ["Veertu", "Veertu", "Not Specified"],
|
33
|
-
parallels: ["Parallels Software International Inc.", "Parallels Virtual Platform", "None"],
|
34
|
-
vbox: ["Oracle Corporation", "VirtualBox", "1.2"],
|
35
|
-
openstack: ["OpenStack Foundation", "", "15.1.5"],
|
36
|
-
kvm: ["Red Hat", "KVM", "RHEL 7.0.0 PC (i440FX + PIIX, 1996"],
|
37
|
-
bhyve: ["", "BHYVE", "1.0"],
|
38
|
-
}.each_pair do |hypervisor, values|
|
39
|
-
describe "when passed #{hypervisor} dmi data" do
|
40
|
-
it "returns '#{hypervisor}'" do
|
41
|
-
expect(mixin.guest_from_dmi_data(values[0], values[1], values[2])).to eq("#{hypervisor}")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "when passed Redhat's Openstack varient dmi data" do
|
47
|
-
it "returns 'openstack'" do
|
48
|
-
expect(mixin.guest_from_dmi_data("Red Hat Inc.", "OpenStack Nova", "2014.1.2-1.el6")).to eq("openstack")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe "When running on RHEV Hypervisor" do
|
53
|
-
it "returns 'kvm'" do
|
54
|
-
expect(mixin.guest_from_dmi_data("Red Hat", "RHEV Hypervisor", "6.7-20150911.0.el6ev")).to eq("kvm")
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "When the manufactuer is 'QEMU'" do
|
59
|
-
it "return kvm" do
|
60
|
-
expect(mixin.guest_from_dmi_data("QEMU", "", "")).to eq("kvm")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "returns nil if manufactuer is 'Microsoft', but product is not 'Virtual Machine'" do
|
65
|
-
it "returns nil" do
|
66
|
-
expect(mixin.guest_from_dmi_data("Microsot", "Zune", "2018")).to be_nil
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "When running on an unkown system" do
|
71
|
-
it "returns nil" do
|
72
|
-
expect(mixin.guest_from_dmi_data("TimCorp", "SuperServer", "2018")).to be_nil
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Bryan McLellan <btm@loftninjas.org>
|
3
|
-
# Copyright:: Copyright (c) 2013-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 CONDIT"Net::HTTP Response"NS 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
|
-
require "ohai/mixin/ec2_metadata"
|
21
|
-
|
22
|
-
describe Ohai::Mixin::Ec2Metadata do
|
23
|
-
let(:mixin) do
|
24
|
-
metadata_object = Object.new.extend(Ohai::Mixin::Ec2Metadata)
|
25
|
-
http_client = double("Net::HTTP client")
|
26
|
-
allow(http_client).to receive(:get).and_return(response)
|
27
|
-
allow(metadata_object).to receive(:http_client).and_return(http_client)
|
28
|
-
metadata_object
|
29
|
-
end
|
30
|
-
|
31
|
-
before do
|
32
|
-
logger = instance_double("Mixlib::Log::Child", trace: nil, debug: nil, warn: nil)
|
33
|
-
allow(mixin).to receive(:logger).and_return(logger)
|
34
|
-
end
|
35
|
-
|
36
|
-
context "#best_api_version" do
|
37
|
-
context "with a sorted list of metadata versions" do
|
38
|
-
let(:response) { double("Net::HTTP Response", body: "1.0\n2011-05-01\n2012-01-12\nUnsupported", code: "200") }
|
39
|
-
|
40
|
-
it "returns the most recent version" do
|
41
|
-
expect(mixin.best_api_version).to eq("2012-01-12")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "with an unsorted list of metadata versions" do
|
46
|
-
let(:response) { double("Net::HTTP Response", body: "1.0\n2009-04-04\n2007-03-01\n2011-05-01\n2008-09-01\nUnsupported", code: "200") }
|
47
|
-
|
48
|
-
it "returns the most recent version (using string sort)" do
|
49
|
-
expect(mixin.best_api_version).to eq("2011-05-01")
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context "when no supported versions are found" do
|
54
|
-
let(:response) { double("Net::HTTP Response", body: "2020-01-01\nUnsupported", code: "200") }
|
55
|
-
|
56
|
-
it "raises an error" do
|
57
|
-
expect { mixin.best_api_version }.to raise_error(RuntimeError)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# Presume 'latest' when we get a 404 for Eucalyptus back-compat
|
62
|
-
context "when the response code is 404" do
|
63
|
-
let(:response) { double("Net::HTTP Response", code: "404") }
|
64
|
-
|
65
|
-
it "returns 'latest' as the version" do
|
66
|
-
expect(mixin.best_api_version).to eq("latest")
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "when the response code is unexpected" do
|
71
|
-
let(:response) { double("Net::HTTP Response", body: "1.0\n2011-05-01\n2012-01-12\nUnsupported", code: "418") }
|
72
|
-
|
73
|
-
it "raises an error" do
|
74
|
-
expect { mixin.best_api_version }.to raise_error(RuntimeError)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context "#metadata_get" do
|
80
|
-
context "when the response code is unexpected" do
|
81
|
-
let(:response) { double("Net::HTTP Response", body: "", code: "418") }
|
82
|
-
|
83
|
-
it "raises an error" do
|
84
|
-
expect { mixin.metadata_get("", "2012-01-12") }.to raise_error(RuntimeError)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Alexey Karpik <alexey.karpik@rightscale.com>
|
3
|
-
# Author:: Peter Schroeter <peter.schroeter@rightscale.com>
|
4
|
-
# Author:: Stas Turlo <stanislav.turlo@rightscale.com>
|
5
|
-
# Copyright:: Copyright (c) 2010-2014 RightScale Inc
|
6
|
-
# License:: Apache License, Version 2.0
|
7
|
-
#
|
8
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
-
# See the License for the specific language governing permissions and
|
18
|
-
# limitations under the License.
|
19
|
-
|
20
|
-
require "spec_helper"
|
21
|
-
require "ohai/mixin/softlayer_metadata"
|
22
|
-
|
23
|
-
describe ::Ohai::Mixin::SoftlayerMetadata do
|
24
|
-
|
25
|
-
let(:mixin) do
|
26
|
-
mixin = Object.new.extend(::Ohai::Mixin::SoftlayerMetadata)
|
27
|
-
mixin
|
28
|
-
end
|
29
|
-
|
30
|
-
before do
|
31
|
-
logger = instance_double("Mixlib::Log::Child", trace: nil, debug: nil, warn: nil)
|
32
|
-
allow(mixin).to receive(:logger).and_return(logger)
|
33
|
-
end
|
34
|
-
|
35
|
-
def make_request(item)
|
36
|
-
"/rest/v3.1/SoftLayer_Resource_Metadata/#{item}"
|
37
|
-
end
|
38
|
-
|
39
|
-
def make_res(body)
|
40
|
-
double("response", { body: body, code: "200" })
|
41
|
-
end
|
42
|
-
|
43
|
-
context "fetch_metadata" do
|
44
|
-
it "raises error if softlayer api query results with error" do
|
45
|
-
http_mock = double("http", { :ssl_version= => true, :use_ssl= => true, :ca_file= => true })
|
46
|
-
allow(http_mock).to receive(:get).and_raise(StandardError.new("API return fake error"))
|
47
|
-
allow(::Net::HTTP).to receive(:new).with("api.service.softlayer.com", 443).and_return(http_mock)
|
48
|
-
|
49
|
-
expect(mixin.logger).to receive(:error).at_least(:once)
|
50
|
-
expect { mixin.fetch_metadata }.to raise_error(StandardError)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "query api service" do
|
54
|
-
http_mock = double("http", { :ssl_version= => true, :use_ssl= => true, :ca_file= => true })
|
55
|
-
allow(::Net::HTTP).to receive(:new).with("api.service.softlayer.com", 443).and_return(http_mock)
|
56
|
-
|
57
|
-
expect(http_mock).to receive(:get).with(make_request("getFullyQualifiedDomainName.txt")).and_return(make_res("abc.host.org")).once
|
58
|
-
expect(http_mock).to receive(:get).with(make_request("getPrimaryBackendIpAddress.txt")).and_return(make_res("10.0.1.10")).once
|
59
|
-
expect(http_mock).to receive(:get).with(make_request("getPrimaryIpAddress.txt")).and_return(make_res("8.8.8.8")).once
|
60
|
-
expect(http_mock).to receive(:get).with(make_request("getId.txt")).and_return(make_res("1111")).once
|
61
|
-
expect(http_mock).to receive(:get).with(make_request("getDatacenter.txt")).and_return(make_res("dal05")).once
|
62
|
-
|
63
|
-
metadata = mixin.fetch_metadata
|
64
|
-
expect(metadata).not_to be_nil
|
65
|
-
expect(metadata["public_fqdn"]).to eq("abc.host.org")
|
66
|
-
expect(metadata["local_ipv4"]).to eq("10.0.1.10")
|
67
|
-
expect(metadata["instance_id"]).to eq("1111")
|
68
|
-
expect(metadata["region"]).to eq("dal05")
|
69
|
-
expect(metadata["public_ipv4"]).to eq("8.8.8.8")
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,117 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
|
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
|
-
require "ohai/plugin_config"
|
20
|
-
|
21
|
-
describe "Ohai::PluginConfig" do
|
22
|
-
|
23
|
-
describe "#[]=" do
|
24
|
-
|
25
|
-
let(:plugin_config) { Ohai::PluginConfig.new }
|
26
|
-
|
27
|
-
shared_examples_for "success" do
|
28
|
-
|
29
|
-
it "sets the value" do
|
30
|
-
plugin_config[key] = value
|
31
|
-
expect(plugin_config).to have_key(key)
|
32
|
-
expect(plugin_config[key]).to eq(value)
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
shared_examples_for "failure" do
|
38
|
-
|
39
|
-
it "raises an error" do
|
40
|
-
expect { plugin_config[key] = value }
|
41
|
-
.to raise_error(Ohai::Exceptions::PluginConfigError, /Expected Symbol/)
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "when the key is a Symbol" do
|
47
|
-
|
48
|
-
let(:key) { :foo }
|
49
|
-
|
50
|
-
describe "when the value is a Hash" do
|
51
|
-
|
52
|
-
describe "when all Hash keys are symbols" do
|
53
|
-
|
54
|
-
let(:value) do
|
55
|
-
{
|
56
|
-
bar0: true,
|
57
|
-
bar1: %i{baz0 baz1 baz2},
|
58
|
-
bar2: { qux0: true, qux1: false },
|
59
|
-
}
|
60
|
-
end
|
61
|
-
|
62
|
-
include_examples "success"
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "when some top-level Hash key is not a symbol" do
|
67
|
-
|
68
|
-
let(:value) do
|
69
|
-
{
|
70
|
-
:bar0 => true,
|
71
|
-
"bar1" => %i{baz0 baz1 baz2},
|
72
|
-
:bar2 => { qux0: true, qux1: false },
|
73
|
-
}
|
74
|
-
end
|
75
|
-
|
76
|
-
include_examples "failure"
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "when some nested Hash key is not a symbol" do
|
81
|
-
|
82
|
-
let(:value) do
|
83
|
-
{
|
84
|
-
bar0: true,
|
85
|
-
bar1: %i{baz0 baz1 baz2},
|
86
|
-
bar2: { :qux0 => true, "qux1" => false },
|
87
|
-
}
|
88
|
-
end
|
89
|
-
|
90
|
-
include_examples "failure"
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
describe "when the value is not a Hash" do
|
97
|
-
|
98
|
-
let(:value) { true }
|
99
|
-
|
100
|
-
include_examples "success"
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "when the key is not a Symbol" do
|
107
|
-
|
108
|
-
let(:key) { "foo" }
|
109
|
-
let(:value) { false }
|
110
|
-
|
111
|
-
include_examples "failure"
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Salim Alam (salam@chef.io)
|
3
|
-
# Copyright:: Copyright (c) 2015 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
|
-
tmp = ENV["TMPDIR"] || ENV["TMP"] || ENV["TEMP"] || "/tmp"
|
22
|
-
|
23
|
-
abortstr = <<~EOF
|
24
|
-
Ohai.plugin(:Abort) do
|
25
|
-
provides "abort_test"
|
26
|
-
collect_data do
|
27
|
-
abort
|
28
|
-
end
|
29
|
-
end
|
30
|
-
EOF
|
31
|
-
|
32
|
-
describe "a plug-in that aborts execution" do
|
33
|
-
before(:all) do
|
34
|
-
|
35
|
-
Dir.mkdir("#{tmp}/plugins")
|
36
|
-
rescue Errno::EEXIST
|
37
|
-
# ignore
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
before do
|
42
|
-
fail_file = File.open("#{tmp}/plugins/abort.rb", "w+")
|
43
|
-
fail_file.write(abortstr)
|
44
|
-
fail_file.close
|
45
|
-
end
|
46
|
-
|
47
|
-
after do
|
48
|
-
File.delete("#{tmp}/plugins/abort.rb")
|
49
|
-
end
|
50
|
-
|
51
|
-
after(:all) do
|
52
|
-
|
53
|
-
Dir.delete("#{tmp}/plugins")
|
54
|
-
rescue
|
55
|
-
# ignore
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
before do
|
60
|
-
@ohai = Ohai::System.new
|
61
|
-
@loader = Ohai::Loader.new(@ohai)
|
62
|
-
@runner = Ohai::Runner.new(@ohai)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "raises SystemExit" do
|
66
|
-
@plugin = @loader.load_plugin("#{tmp}/plugins/abort.rb")
|
67
|
-
expect { @runner.run_plugin(@plugin) }.to raise_error(SystemExit)
|
68
|
-
end
|
69
|
-
end
|
@@ -1,127 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
|
3
|
-
# Author:: Isa Farnik (<isa@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
|
19
|
-
require "spec_helper"
|
20
|
-
|
21
|
-
describe Ohai::System, "AIX cpu plugin" do
|
22
|
-
before do
|
23
|
-
@lsdev_cc_processor = <<~LSDEV_CC_PROCESSOR
|
24
|
-
proc0 Available 00-00 Processor
|
25
|
-
proc4 Defined 00-04 Processor
|
26
|
-
LSDEV_CC_PROCESSOR
|
27
|
-
|
28
|
-
@lsattr_el_proc0 = <<~LSATTR_EL
|
29
|
-
frequency 1654344000 Processor Speed False
|
30
|
-
smt_enabled true Processor SMT enabled False
|
31
|
-
smt_threads 2 Processor SMT threads False
|
32
|
-
state enable Processor state False
|
33
|
-
type PowerPC_POWER5 Processor type False
|
34
|
-
LSATTR_EL
|
35
|
-
|
36
|
-
@pmcycles_m = <<~PMCYCLES_M
|
37
|
-
CPU 0 runs at 1654 MHz
|
38
|
-
CPU 1 runs at 1654 MHz
|
39
|
-
CPU 2 runs at 1654 MHz
|
40
|
-
CPU 3 runs at 1654 MHz
|
41
|
-
PMCYCLES_M
|
42
|
-
|
43
|
-
@plugin = get_plugin("cpu")
|
44
|
-
allow(@plugin).to receive(:collect_os).and_return(:aix)
|
45
|
-
|
46
|
-
allow(@plugin).to receive(:shell_out).with("lsdev -Cc processor").and_return(mock_shell_out(0, @lsdev_cc_processor, nil))
|
47
|
-
allow(@plugin).to receive(:shell_out).with("lsattr -El proc0").and_return(mock_shell_out(0, @lsattr_el_proc0, nil))
|
48
|
-
allow(@plugin).to receive(:shell_out).with("pmcycles -m").and_return(mock_shell_out(0, @pmcycles_m, nil))
|
49
|
-
end
|
50
|
-
|
51
|
-
context "when run on an LPAR" do
|
52
|
-
before do
|
53
|
-
allow(@plugin).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "0", nil))
|
54
|
-
@plugin.run
|
55
|
-
end
|
56
|
-
|
57
|
-
it "sets the vendor id to IBM" do
|
58
|
-
expect(@plugin[:cpu]["0"][:vendor_id]).to eq("IBM")
|
59
|
-
end
|
60
|
-
|
61
|
-
it "sets the available attribute" do
|
62
|
-
expect(@plugin[:cpu][:available]).to eq(1)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "sets the total number of processors" do
|
66
|
-
expect(@plugin[:cpu][:total]).to eq(4)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "sets the real number of processors" do
|
70
|
-
expect(@plugin[:cpu][:real]).to eq(2)
|
71
|
-
end
|
72
|
-
|
73
|
-
it "sets the number of cores" do
|
74
|
-
# from http://www-01.ibm.com/software/passportadvantage/pvu_terminology_for_customers.html
|
75
|
-
# on AIX number of cores and processors are considered same
|
76
|
-
expect(@plugin[:cpu][:cores]).to eq(@plugin[:cpu][:real])
|
77
|
-
end
|
78
|
-
|
79
|
-
it "detects the model" do
|
80
|
-
expect(@plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5")
|
81
|
-
end
|
82
|
-
|
83
|
-
it "detects the mhz" do
|
84
|
-
expect(@plugin[:cpu]["0"][:mhz]).to eq(1654)
|
85
|
-
end
|
86
|
-
|
87
|
-
it "detects the status of the device" do
|
88
|
-
expect(@plugin[:cpu]["0"][:status]).to eq("Available")
|
89
|
-
end
|
90
|
-
|
91
|
-
it "detects the location of the device" do
|
92
|
-
expect(@plugin[:cpu]["0"][:location]).to eq("00-00")
|
93
|
-
end
|
94
|
-
|
95
|
-
context "lsattr -El device_name" do
|
96
|
-
it "detects all the attributes of the device" do
|
97
|
-
expect(@plugin[:cpu]["0"][:mhz]).to eq(1654)
|
98
|
-
expect(@plugin[:cpu]["0"][:smt_enabled]).to eq("true")
|
99
|
-
expect(@plugin[:cpu]["0"][:smt_threads]).to eq("2")
|
100
|
-
expect(@plugin[:cpu]["0"][:state]).to eq("enable")
|
101
|
-
expect(@plugin[:cpu]["0"][:model_name]).to eq("PowerPC_POWER5")
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
context "when run on a WPAR" do
|
107
|
-
before do
|
108
|
-
allow(@plugin).to receive(:shell_out).with("uname -W").and_return(mock_shell_out(0, "120", nil))
|
109
|
-
@plugin.run
|
110
|
-
end
|
111
|
-
|
112
|
-
it "sets the total number of processors" do
|
113
|
-
expect(@plugin[:cpu][:total]).to eq(4)
|
114
|
-
end
|
115
|
-
|
116
|
-
it "doesn't set the real number of CPUs" do
|
117
|
-
expect(@plugin[:cpu][:real]).to be_nil
|
118
|
-
end
|
119
|
-
|
120
|
-
it "doesn't set mhz of a processor it can't see" do
|
121
|
-
# I'm so sorry
|
122
|
-
expect do
|
123
|
-
expect(@plugin[:cpu]["0"][:mhz]).to eq(1654)
|
124
|
-
end.to raise_error(NoMethodError)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|