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,65 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
# Copyright:: 2019 Chef Software, Inc.
|
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 etc", :unix_only do
|
21
|
-
let(:plugin) { get_plugin("passwd") }
|
22
|
-
|
23
|
-
PasswdEntry = Struct.new(:name, :uid, :gid, :dir, :shell, :gecos)
|
24
|
-
GroupEntry = Struct.new(:name, :gid, :mem)
|
25
|
-
|
26
|
-
it "includes a list of all users" do
|
27
|
-
expect(Etc).to receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, "/root", "/bin/zsh", "BOFH"))
|
28
|
-
.and_yield(PasswdEntry.new("www", 800, 800, "/var/www", "/bin/false", "Serving the web since 1970"))
|
29
|
-
plugin.run
|
30
|
-
expect(plugin[:etc][:passwd]["root"]).to eq(Mash.new(shell: "/bin/zsh", gecos: "BOFH", gid: 1, uid: 1, dir: "/root"))
|
31
|
-
expect(plugin[:etc][:passwd]["www"]).to eq(Mash.new(shell: "/bin/false", gecos: "Serving the web since 1970", gid: 800, uid: 800, dir: "/var/www"))
|
32
|
-
end
|
33
|
-
|
34
|
-
it "ignores duplicate users" do
|
35
|
-
expect(Etc).to receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, "/root", "/bin/zsh", "BOFH"))
|
36
|
-
.and_yield(PasswdEntry.new("root", 1, 1, "/", "/bin/false", "I do not belong"))
|
37
|
-
plugin.run
|
38
|
-
expect(plugin[:etc][:passwd]["root"]).to eq(Mash.new(shell: "/bin/zsh", gecos: "BOFH", gid: 1, uid: 1, dir: "/root"))
|
39
|
-
end
|
40
|
-
|
41
|
-
it "sets the current user" do
|
42
|
-
expect(Process).to receive(:euid).and_return("31337")
|
43
|
-
expect(Etc).to receive(:getpwuid).and_return(PasswdEntry.new("chef", 31337, 31337, "/home/chef", "/bin/ksh", "Julia Child"))
|
44
|
-
plugin.run
|
45
|
-
expect(plugin[:current_user]).to eq("chef")
|
46
|
-
end
|
47
|
-
|
48
|
-
it "sets the available groups" do
|
49
|
-
expect(Etc).to receive(:group).and_yield(GroupEntry.new("admin", 100, %w{root chef})).and_yield(GroupEntry.new("www", 800, %w{www deploy}))
|
50
|
-
plugin.run
|
51
|
-
expect(plugin[:etc][:group]["admin"]).to eq(Mash.new(gid: 100, members: %w{root chef}))
|
52
|
-
expect(plugin[:etc][:group]["www"]).to eq(Mash.new(gid: 800, members: %w{www deploy}))
|
53
|
-
end
|
54
|
-
|
55
|
-
if "".respond_to?(:force_encoding)
|
56
|
-
it "sets the encoding of strings to the default external encoding" do
|
57
|
-
fields = ["root", 1, 1, "/root", "/bin/zsh", "BOFH"]
|
58
|
-
fields.each { |f| f.force_encoding(Encoding::ASCII_8BIT) if f.respond_to?(:force_encoding) }
|
59
|
-
allow(Etc).to receive(:passwd).and_yield(PasswdEntry.new(*fields))
|
60
|
-
plugin.run
|
61
|
-
root = plugin[:etc][:passwd]["root"]
|
62
|
-
expect(root["gecos"].encoding).to eq(Encoding.default_external)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Joshua Timberman(<joshua@chef.io>)
|
3
|
-
# Author:: Theodore Nordsieck (<theo@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2009-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
|
-
|
20
|
-
require "spec_helper"
|
21
|
-
|
22
|
-
describe Ohai::System, "plugin perl" do
|
23
|
-
let(:plugin) { get_plugin("perl") }
|
24
|
-
|
25
|
-
before do
|
26
|
-
plugin[:languages] = Mash.new
|
27
|
-
@stdout = "version='5.8.8';#{$/}archname='darwin-thread-multi-2level';"
|
28
|
-
allow(plugin).to receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
|
29
|
-
end
|
30
|
-
|
31
|
-
it "runs perl -V:version -V:archname" do
|
32
|
-
expect(plugin).to receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, "", ""))
|
33
|
-
plugin.run
|
34
|
-
end
|
35
|
-
|
36
|
-
it "sets languages[:perl][:version]" do
|
37
|
-
plugin.run
|
38
|
-
expect(plugin.languages[:perl][:version]).to eql("5.8.8")
|
39
|
-
end
|
40
|
-
|
41
|
-
it "sets languages[:perl][:archname]" do
|
42
|
-
plugin.run
|
43
|
-
expect(plugin.languages[:perl][:archname]).to eql("darwin-thread-multi-2level")
|
44
|
-
end
|
45
|
-
|
46
|
-
it "sets languages[:perl] if perl command succeeds" do
|
47
|
-
plugin.run
|
48
|
-
expect(plugin.languages).to have_key(:perl)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "does not set languages[:perl] if perl command fails" do
|
52
|
-
allow(plugin).to receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(1, "", ""))
|
53
|
-
plugin.run
|
54
|
-
expect(plugin.languages).not_to have_key(:perl)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "does not set languages[:perl] if perl command doesn't exist" do
|
58
|
-
allow(plugin).to receive(:shell_out).and_raise(Ohai::Exceptions::Exec)
|
59
|
-
plugin.run
|
60
|
-
expect(plugin.languages).not_to have_key(:perl)
|
61
|
-
end
|
62
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Doug MacEachern <dougm@vmware.com>
|
3
|
-
# Author:: Theodore Nordsieck (<theo@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2009 VMware, Inc.
|
5
|
-
# Copyright:: Copyright (c) 2013-2016 Chef Software, 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
|
-
|
21
|
-
require "spec_helper"
|
22
|
-
|
23
|
-
describe Ohai::System, "plugin php" do
|
24
|
-
let(:plugin) { get_plugin("php") }
|
25
|
-
|
26
|
-
before do
|
27
|
-
plugin[:languages] = Mash.new
|
28
|
-
@stdout = <<~OUT
|
29
|
-
PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)
|
30
|
-
Copyright (c) 1997-2006 The PHP Group
|
31
|
-
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
|
32
|
-
OUT
|
33
|
-
allow(plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
|
34
|
-
end
|
35
|
-
|
36
|
-
it "gets the php version by running php -V" do
|
37
|
-
expect(plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, @stdout, ""))
|
38
|
-
plugin.run
|
39
|
-
end
|
40
|
-
|
41
|
-
it "sets languages[:php][:version] on PHP 5.X" do
|
42
|
-
plugin.run
|
43
|
-
expect(plugin.languages[:php][:version]).to eql("5.1.6")
|
44
|
-
end
|
45
|
-
|
46
|
-
it "sets languages[:php][:version] on PHP 7.0" do
|
47
|
-
stdout = <<~OUT
|
48
|
-
PHP 7.0.4-7ubuntu2.1 (cli) ( NTS )
|
49
|
-
Copyright (c) 1997-2016 The PHP Group
|
50
|
-
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
|
51
|
-
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
|
52
|
-
OUT
|
53
|
-
allow(plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, stdout, ""))
|
54
|
-
plugin.run
|
55
|
-
expect(plugin.languages[:php][:version]).to eql("7.0.4-7ubuntu2.1")
|
56
|
-
end
|
57
|
-
|
58
|
-
it "does not set the languages[:php] tree up if php command fails" do
|
59
|
-
allow(plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(1, "", ""))
|
60
|
-
plugin.run
|
61
|
-
expect(plugin.languages).not_to have_key(:php)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "parses builddate even if PHP is Suhosin patched" do
|
65
|
-
stdout = <<~OUT
|
66
|
-
PHP 5.3.27 with Suhosin-Patch (cli) (built: Aug 30 2013 04:30:30)
|
67
|
-
Copyright (c) 1997-2013 The PHP Group
|
68
|
-
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
|
69
|
-
OUT
|
70
|
-
allow(plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, stdout, ""))
|
71
|
-
plugin.run
|
72
|
-
expect(plugin.languages[:php][:builddate]).to eql("Aug 30 2013 04:30:30")
|
73
|
-
end
|
74
|
-
|
75
|
-
it "does not set zend_optcache_version if not compiled with opcache" do
|
76
|
-
stdout = <<~OUT
|
77
|
-
PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)
|
78
|
-
Copyright (c) 1997-2006 The PHP Group
|
79
|
-
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
|
80
|
-
OUT
|
81
|
-
allow(plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, stdout, ""))
|
82
|
-
plugin.run
|
83
|
-
expect(plugin.languages[:php]).not_to have_key(:zend_opcache_version)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "sets zend_optcache_version if compiled with opcache" do
|
87
|
-
stdout = <<~OUT
|
88
|
-
PHP 5.5.9-1ubuntu4.5 (cli) (built: Oct 29 2014 11:59:10)
|
89
|
-
Copyright (c) 1997-2014 The PHP Group
|
90
|
-
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
|
91
|
-
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
|
92
|
-
OUT
|
93
|
-
allow(plugin).to receive(:shell_out).with("php -v").and_return(mock_shell_out(0, stdout, ""))
|
94
|
-
plugin.run
|
95
|
-
expect(plugin.languages[:php][:zend_opcache_version]).to eql("7.0.3")
|
96
|
-
end
|
97
|
-
end
|
@@ -1,65 +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
|
-
describe Ohai::System, "plugin platform" do
|
22
|
-
before do
|
23
|
-
@plugin = get_plugin("platform")
|
24
|
-
allow(@plugin).to receive(:collect_os).and_return(:default)
|
25
|
-
@plugin[:os] = "monkey"
|
26
|
-
@plugin[:os_version] = "poop"
|
27
|
-
end
|
28
|
-
|
29
|
-
it "sets the platform and platform family to the os if it was not set earlier" do
|
30
|
-
@plugin.run
|
31
|
-
expect(@plugin[:platform]).to eql("monkey")
|
32
|
-
expect(@plugin[:platform_family]).to eql("monkey")
|
33
|
-
end
|
34
|
-
|
35
|
-
it "does not set the platform to the os if it was set earlier" do
|
36
|
-
@plugin[:platform] = "lars"
|
37
|
-
@plugin.run
|
38
|
-
expect(@plugin[:platform]).to eql("lars")
|
39
|
-
end
|
40
|
-
|
41
|
-
it "sets the platform_family to the platform if platform was set earlier but not platform_family" do
|
42
|
-
@plugin[:platform] = "lars"
|
43
|
-
@plugin[:platform_family] = "jack"
|
44
|
-
@plugin.run
|
45
|
-
expect(@plugin[:platform_family]).to eql("jack")
|
46
|
-
end
|
47
|
-
|
48
|
-
it "does not set the platform_family if the platform_family was set earlier." do
|
49
|
-
@plugin[:platform] = "lars"
|
50
|
-
@plugin.run
|
51
|
-
expect(@plugin[:platform]).to eql("lars")
|
52
|
-
expect(@plugin[:platform_family]).to eql("lars")
|
53
|
-
end
|
54
|
-
|
55
|
-
it "sets the platform_version to the os_version if it was not set earlier" do
|
56
|
-
@plugin.run
|
57
|
-
expect(@plugin[:os_version]).to eql("poop")
|
58
|
-
end
|
59
|
-
|
60
|
-
it "does not set the platform to the os if it was set earlier" do
|
61
|
-
@plugin[:platform_version] = "ulrich"
|
62
|
-
@plugin.run
|
63
|
-
expect(@plugin[:platform_version]).to eql("ulrich")
|
64
|
-
end
|
65
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Copyright (c) 2014 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
|
-
|
20
|
-
describe Ohai::System, "plugin powershell" do
|
21
|
-
let(:plugin) { get_plugin("powershell") }
|
22
|
-
|
23
|
-
before do
|
24
|
-
stub_const("::RbConfig::CONFIG", { "host_os" => "windows" })
|
25
|
-
end
|
26
|
-
|
27
|
-
before do
|
28
|
-
plugin[:languages] = Mash.new
|
29
|
-
end
|
30
|
-
|
31
|
-
it "sets languages[:powershell][:version] for v4" do
|
32
|
-
|
33
|
-
v4_output = <<~END
|
34
|
-
|
35
|
-
Name Value
|
36
|
-
---- -----
|
37
|
-
PSVersion 4.0
|
38
|
-
WSManStackVersion 3.0
|
39
|
-
SerializationVersion 1.1.0.1
|
40
|
-
CLRVersion 4.0.30319.34014
|
41
|
-
BuildVersion 6.3.9600.16394
|
42
|
-
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
|
43
|
-
PSRemotingProtocolVersion 2.2
|
44
|
-
|
45
|
-
END
|
46
|
-
compat_version_array = ["1.0", "2.0", "3.0", "4.0"]
|
47
|
-
|
48
|
-
allow(plugin).to receive(:shell_out).with(anything).and_return(mock_shell_out(0, v4_output, ""))
|
49
|
-
allow(plugin).to receive(:parse_compatible_versions).and_return(compat_version_array)
|
50
|
-
plugin.run
|
51
|
-
expect(plugin.languages[:powershell][:version]).to eql("4.0")
|
52
|
-
expect(plugin.languages[:powershell][:ws_man_stack_version]).to eql("3.0")
|
53
|
-
expect(plugin.languages[:powershell][:serialization_version]).to eql("1.1.0.1")
|
54
|
-
expect(plugin.languages[:powershell][:clr_version]).to eql("4.0.30319.34014")
|
55
|
-
expect(plugin.languages[:powershell][:build_version]).to eql("6.3.9600.16394")
|
56
|
-
expect(plugin.languages[:powershell][:compatible_versions]).to eql(["1.0", "2.0", "3.0", "4.0"])
|
57
|
-
expect(plugin.languages[:powershell][:remoting_protocol_version]).to eql("2.2")
|
58
|
-
end
|
59
|
-
|
60
|
-
it "does not set the languages[:powershell] tree up if powershell command fails" do
|
61
|
-
error_output = <<~END
|
62
|
-
'powershell.exe' is not recognized as an internal or external command,
|
63
|
-
operable program or batch file.
|
64
|
-
END
|
65
|
-
|
66
|
-
allow(plugin).to receive(:shell_out).with(anything).and_return(mock_shell_out(1, error_output, ""))
|
67
|
-
plugin.run
|
68
|
-
expect(plugin.languages).not_to have_key(:powershell)
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Author:: Theodore Nordsieck (<theo@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2008-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
|
-
|
20
|
-
require "spec_helper"
|
21
|
-
|
22
|
-
describe Ohai::System, "plugin python" do
|
23
|
-
let(:stdout) { "2.5.2 (r252:60911, Jan 4 2009, 17:40:26)\n[GCC 4.3.2]\n" }
|
24
|
-
|
25
|
-
let(:retval) { 0 }
|
26
|
-
|
27
|
-
let(:plugin) do
|
28
|
-
plugin = get_plugin("python")
|
29
|
-
plugin[:languages] = Mash.new
|
30
|
-
expect(plugin).to receive(:shell_out).with("python -c \"import sys; print (sys.version)\"").and_return(mock_shell_out(retval, stdout, ""))
|
31
|
-
plugin
|
32
|
-
end
|
33
|
-
|
34
|
-
it "gets the python version from printing sys.version and sys.platform" do
|
35
|
-
plugin.run
|
36
|
-
end
|
37
|
-
|
38
|
-
it "sets languages[:python][:version]" do
|
39
|
-
plugin.run
|
40
|
-
expect(plugin.languages[:python][:version]).to eql("2.5.2")
|
41
|
-
end
|
42
|
-
|
43
|
-
context "when the python command fails" do
|
44
|
-
let(:retval) { 1 }
|
45
|
-
|
46
|
-
it "does not set the languages[:python] tree up" do
|
47
|
-
plugin.run
|
48
|
-
expect(plugin.languages).not_to have_key(:python)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,350 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Cary Penniman (<cary@rightscale.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 "resolv"
|
19
|
-
require "spec_helper"
|
20
|
-
|
21
|
-
describe Ohai::System, "plugin rackspace" do
|
22
|
-
let(:plugin) { get_plugin("rackspace") }
|
23
|
-
|
24
|
-
before do
|
25
|
-
allow(Resolv).to receive(:getname).and_return("1.2.3.4")
|
26
|
-
|
27
|
-
plugin[:hostname] = "katie"
|
28
|
-
|
29
|
-
plugin[:network] = {
|
30
|
-
interfaces: {
|
31
|
-
eth0: {
|
32
|
-
"addresses" => {
|
33
|
-
"1.2.3.4" => {
|
34
|
-
"broadcast" => "67.23.20.255",
|
35
|
-
"netmask" => "255.255.255.0",
|
36
|
-
"family" => "inet",
|
37
|
-
},
|
38
|
-
"2a00:1a48:7805:111:e875:efaf:ff08:75" => {
|
39
|
-
"family" => "inet6",
|
40
|
-
"prefixlen" => "64",
|
41
|
-
"scope" => "Global",
|
42
|
-
},
|
43
|
-
"fe80::4240:95ff:fe47:6eed" => {
|
44
|
-
"scope" => "Link",
|
45
|
-
"prefixlen" => "64",
|
46
|
-
"family" => "inet6",
|
47
|
-
},
|
48
|
-
"40:40:95:47:6E:ED" => {
|
49
|
-
"family" => "lladdr",
|
50
|
-
},
|
51
|
-
},
|
52
|
-
},
|
53
|
-
},
|
54
|
-
}
|
55
|
-
|
56
|
-
plugin[:network][:interfaces][:eth1] = {
|
57
|
-
addresses: {
|
58
|
-
"fe80::4240:f5ff:feab:2836" => {
|
59
|
-
"scope" => "Link",
|
60
|
-
"prefixlen" => "64",
|
61
|
-
"family" => "inet6",
|
62
|
-
},
|
63
|
-
"5.6.7.8" => {
|
64
|
-
"broadcast" => "10.176.191.255",
|
65
|
-
"netmask" => "255.255.224.0",
|
66
|
-
"family" => "inet",
|
67
|
-
},
|
68
|
-
"40:40:F5:AB:28:36" => {
|
69
|
-
"family" => "lladdr",
|
70
|
-
},
|
71
|
-
},
|
72
|
-
}
|
73
|
-
|
74
|
-
# In olden days we could detect rackspace by a -rscloud suffix on the kernel
|
75
|
-
# This is here to make #has_rackspace_kernel? fail until we remove that check
|
76
|
-
plugin[:kernel] = { release: "1.2.13-not-rackspace" }
|
77
|
-
|
78
|
-
# We need a generic stub here for the later stubs with arguments to work
|
79
|
-
# Because, magic.
|
80
|
-
allow(plugin).to receive(:shell_out).and_return(mock_shell_out(1, "", ""))
|
81
|
-
end
|
82
|
-
|
83
|
-
shared_examples_for "!rackspace" do
|
84
|
-
it "does not create rackspace attribute" do
|
85
|
-
plugin.run
|
86
|
-
expect(plugin[:rackspace]).to be_nil
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
shared_examples_for "rackspace" do
|
91
|
-
it "has rackspace attribute" do
|
92
|
-
plugin.run
|
93
|
-
expect(plugin[:rackspace]).not_to be_nil
|
94
|
-
end
|
95
|
-
|
96
|
-
it "has expected rackspace ip/hostname attributes" do
|
97
|
-
plugin.run
|
98
|
-
expect(plugin[:rackspace][:public_ip]).not_to be_nil
|
99
|
-
expect(plugin[:rackspace][:private_ip]).not_to be_nil
|
100
|
-
expect(plugin[:rackspace][:public_ipv4]).not_to be_nil
|
101
|
-
expect(plugin[:rackspace][:local_ipv4]).not_to be_nil
|
102
|
-
expect(plugin[:rackspace][:public_ipv6]).not_to be_nil
|
103
|
-
expect(plugin[:rackspace][:local_ipv6]).to be_nil
|
104
|
-
expect(plugin[:rackspace][:local_hostname]).not_to be_nil
|
105
|
-
expect(plugin[:rackspace][:public_hostname]).not_to be_nil
|
106
|
-
end
|
107
|
-
|
108
|
-
it "resolves hostname if reverse dns is set" do
|
109
|
-
allow(Resolv).to receive(:getname).and_return("1234.resolved.com")
|
110
|
-
plugin.run
|
111
|
-
expect(plugin[:rackspace][:public_hostname]).to eq("1234.resolved.com")
|
112
|
-
end
|
113
|
-
|
114
|
-
[Resolv::ResolvError, Resolv::ResolvTimeout].each do |exception|
|
115
|
-
it "returns ip address when reverse dns returns exception: #{exception}" do
|
116
|
-
allow(Resolv).to receive(:getname).and_raise(exception)
|
117
|
-
plugin.run
|
118
|
-
expect(plugin[:rackspace][:public_hostname]).to eq("1.2.3.4")
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
it "has correct values for all attributes" do
|
123
|
-
plugin.run
|
124
|
-
expect(plugin[:rackspace][:public_ip]).to eq("1.2.3.4")
|
125
|
-
expect(plugin[:rackspace][:private_ip]).to eq("5.6.7.8")
|
126
|
-
expect(plugin[:rackspace][:public_ipv4]).to eq("1.2.3.4")
|
127
|
-
expect(plugin[:rackspace][:local_ipv4]).to eq("5.6.7.8")
|
128
|
-
expect(plugin[:rackspace][:public_ipv6]).to eq("2a00:1a48:7805:111:e875:efaf:ff08:75")
|
129
|
-
expect(plugin[:rackspace][:local_hostname]).to eq("katie")
|
130
|
-
expect(plugin[:rackspace][:public_hostname]).to eq("1.2.3.4")
|
131
|
-
end
|
132
|
-
|
133
|
-
it "captures region information" do
|
134
|
-
provider_data = <<~OUT
|
135
|
-
provider = "Rackspace"
|
136
|
-
service_type = "cloudServers"
|
137
|
-
server_id = "21301000"
|
138
|
-
created_at = "2012-12-06T22:08:16Z"
|
139
|
-
region = "dfw"
|
140
|
-
OUT
|
141
|
-
allow(plugin).to receive(:shell_out).with("xenstore-ls vm-data/provider_data").and_return(mock_shell_out(0, provider_data, ""))
|
142
|
-
plugin.run
|
143
|
-
expect(plugin[:rackspace][:region]).to eq("dfw")
|
144
|
-
end
|
145
|
-
|
146
|
-
it "logs a debug message when region info cannot be collected" do
|
147
|
-
expect(plugin)
|
148
|
-
.to receive(:shell_out)
|
149
|
-
.with("xenstore-ls vm-data/provider_data")
|
150
|
-
.and_raise(Ohai::Exceptions::Exec)
|
151
|
-
|
152
|
-
expect(plugin.logger)
|
153
|
-
.to receive(:trace)
|
154
|
-
.with("Plugin Rackspace: Unable to find xenstore-ls, cannot capture " \
|
155
|
-
"region information for Rackspace cloud")
|
156
|
-
|
157
|
-
plugin.run
|
158
|
-
|
159
|
-
expect(plugin[:rackspace]).not_to have_key(:region)
|
160
|
-
end
|
161
|
-
|
162
|
-
it "captures instance ID information" do
|
163
|
-
provider_data = "instance-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
164
|
-
allow(plugin).to receive(:shell_out).with("xenstore-read name").and_return(mock_shell_out(0, provider_data, ""))
|
165
|
-
plugin.run
|
166
|
-
expect(plugin[:rackspace][:instance_id]).to eq("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
|
167
|
-
end
|
168
|
-
|
169
|
-
it "logs error if instance id cannot be found" do
|
170
|
-
expect(plugin)
|
171
|
-
.to receive(:shell_out)
|
172
|
-
.with("xenstore-read name")
|
173
|
-
.and_raise(Ohai::Exceptions::Exec)
|
174
|
-
|
175
|
-
expect(plugin.logger)
|
176
|
-
.to receive(:trace)
|
177
|
-
.with("Plugin Rackspace: Unable to find xenstore-read, cannot capture " \
|
178
|
-
"instance ID information for Rackspace cloud")
|
179
|
-
|
180
|
-
plugin.run
|
181
|
-
|
182
|
-
expect(plugin[:rackspace]).not_to have_key(:instance_id)
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
describe "with rackspace hint file" do
|
187
|
-
before do
|
188
|
-
allow(Resolv).to receive(:getname).and_raise(Resolv::ResolvError)
|
189
|
-
allow(File).to receive(:exist?).with("/etc/resolv.conf").and_return(true)
|
190
|
-
allow(File).to receive(:read).with("/etc/resolv.conf").and_return("")
|
191
|
-
allow(plugin).to receive(:hint?).with("rackspace").and_return(true)
|
192
|
-
end
|
193
|
-
|
194
|
-
it_behaves_like "rackspace"
|
195
|
-
|
196
|
-
describe "with no public interfaces (empty eth0)" do
|
197
|
-
before do
|
198
|
-
# unset public (eth0) addresses
|
199
|
-
plugin[:network][:interfaces][:eth0]["addresses"] = {}
|
200
|
-
end
|
201
|
-
|
202
|
-
it "has correct rackspace attributes" do
|
203
|
-
plugin.run
|
204
|
-
# expliticly nil
|
205
|
-
expect(plugin[:rackspace][:public_ip]).to be_nil
|
206
|
-
expect(plugin[:rackspace][:public_ipv4]).to be_nil
|
207
|
-
expect(plugin[:rackspace][:public_ipv6]).to be_nil
|
208
|
-
expect(plugin[:rackspace][:public_hostname]).to be_nil
|
209
|
-
# per normal
|
210
|
-
expect(plugin[:rackspace][:local_ipv6]).to be_nil
|
211
|
-
expect(plugin[:rackspace][:private_ip]).to eq("5.6.7.8")
|
212
|
-
expect(plugin[:rackspace][:local_ipv4]).to eq("5.6.7.8")
|
213
|
-
expect(plugin[:rackspace][:local_hostname]).to eq("katie")
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
describe "without hint file" do
|
219
|
-
before do
|
220
|
-
allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
|
221
|
-
end
|
222
|
-
|
223
|
-
it_behaves_like "!rackspace"
|
224
|
-
|
225
|
-
end
|
226
|
-
|
227
|
-
describe "with Rackspace windows manufacturer data" do
|
228
|
-
before do
|
229
|
-
allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
|
230
|
-
allow(plugin).to receive(:has_rackspace_manufacturer?).and_return(true)
|
231
|
-
end
|
232
|
-
|
233
|
-
it "has rackspace attribute" do
|
234
|
-
plugin.run
|
235
|
-
expect(plugin[:rackspace]).not_to be_nil
|
236
|
-
end
|
237
|
-
|
238
|
-
end
|
239
|
-
|
240
|
-
describe "xenstore provider returns rackspace" do
|
241
|
-
before do
|
242
|
-
stdout = "Rackspace\n"
|
243
|
-
allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
|
244
|
-
allow(plugin).to receive(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
|
245
|
-
end
|
246
|
-
|
247
|
-
it_behaves_like "rackspace"
|
248
|
-
|
249
|
-
end
|
250
|
-
|
251
|
-
describe "xenstore provider does not return rackspace" do
|
252
|
-
before do
|
253
|
-
allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
|
254
|
-
stdout = "cumulonimbus\n"
|
255
|
-
allow(plugin).to receive(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
|
256
|
-
end
|
257
|
-
|
258
|
-
it_behaves_like "!rackspace"
|
259
|
-
|
260
|
-
end
|
261
|
-
|
262
|
-
describe "xenstore provider does not exist" do
|
263
|
-
before do
|
264
|
-
allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
|
265
|
-
allow(plugin)
|
266
|
-
.to receive(:shell_out)
|
267
|
-
.with("xenstore-read vm-data/provider_data/provider")
|
268
|
-
.and_raise(Ohai::Exceptions::Exec)
|
269
|
-
end
|
270
|
-
|
271
|
-
it_behaves_like "!rackspace"
|
272
|
-
|
273
|
-
end
|
274
|
-
|
275
|
-
describe "when private networks shell out fails" do
|
276
|
-
it "logs an error and does not collect private_networks" do
|
277
|
-
allow(plugin).to receive(:hint?).with("rackspace").and_return(true)
|
278
|
-
|
279
|
-
expect(plugin)
|
280
|
-
.to receive(:shell_out)
|
281
|
-
.with("xenstore-ls vm-data/networking")
|
282
|
-
.and_raise(Ohai::Exceptions::Exec)
|
283
|
-
|
284
|
-
expect(plugin.logger)
|
285
|
-
.to receive(:trace)
|
286
|
-
.with("Plugin Rackspace: Unable to capture custom private networking " \
|
287
|
-
"information for Rackspace cloud")
|
288
|
-
|
289
|
-
plugin.run
|
290
|
-
|
291
|
-
expect(plugin[:rackspace]).not_to have_key(:private_networks)
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
describe "does not have private networks" do
|
296
|
-
before do
|
297
|
-
stdout = 'BC764E20422B = "{"label": "public"}"\n'
|
298
|
-
allow(plugin).to receive(:hint?).with("rackspace").and_return(true)
|
299
|
-
allow(plugin).to receive(:shell_out).with("xenstore-ls vm-data/networking").and_return(mock_shell_out(0, stdout, "" ))
|
300
|
-
stdout = '{"label": "public", "broadcast": "9.10.11.255", "ips": [{"ip": "9.10.11.12", "netmask": "255.255.255.0", "enabled": "1", "gateway": null}], "mac": "BC:76:4E:20:42:2B", "dns": ["69.20.0.164", "69.20.0.196"], "gateway": null}'
|
301
|
-
allow(plugin).to receive(:shell_out).with("xenstore-read vm-data/networking/BC764E20422B").and_return(mock_shell_out(0, stdout, "" ))
|
302
|
-
end
|
303
|
-
|
304
|
-
it "does not have private_networks object" do
|
305
|
-
plugin.run
|
306
|
-
expect(plugin[:rackspace][:private_networks]).to eq([])
|
307
|
-
end
|
308
|
-
end
|
309
|
-
|
310
|
-
describe "has private networks" do
|
311
|
-
before do
|
312
|
-
plugin[:network][:interfaces][:eth2] = {
|
313
|
-
addresses: {
|
314
|
-
"fe80::be76:4eff:fe20:422b" => {
|
315
|
-
"scope" => "Link",
|
316
|
-
"prefixlen" => "64",
|
317
|
-
"family" => "inet6",
|
318
|
-
},
|
319
|
-
"9.10.11.12" => {
|
320
|
-
"broadcast" => "9.10.11.255",
|
321
|
-
"netmask" => "255.255.255.0",
|
322
|
-
"family" => "inet",
|
323
|
-
},
|
324
|
-
"BC:76:4E:20:42:2B" => {
|
325
|
-
"family" => "lladdr",
|
326
|
-
},
|
327
|
-
},
|
328
|
-
}
|
329
|
-
stdout = 'BC764E20422B = "{"label": "private-network"}"\n'
|
330
|
-
allow(plugin).to receive(:shell_out).with("xenstore-ls vm-data/networking").and_return(mock_shell_out(0, stdout, "" ))
|
331
|
-
stdout = '{"label": "private-network", "broadcast": "9.10.11.255", "ips": [{"ip": "9.10.11.12", "netmask": "255.255.255.0", "enabled": "1", "gateway": null}], "mac": "BC:76:4E:20:42:2B", "dns": ["69.20.0.164", "69.20.0.196"], "gateway": null}'
|
332
|
-
allow(plugin).to receive(:shell_out).with("xenstore-read vm-data/networking/BC764E20422B").and_return(mock_shell_out(0, stdout, "" ))
|
333
|
-
allow(plugin).to receive(:hint?).with("rackspace").and_return(true)
|
334
|
-
end
|
335
|
-
|
336
|
-
it "has private_networks object" do
|
337
|
-
plugin.run
|
338
|
-
expect(plugin[:rackspace][:private_networks]).not_to be_nil
|
339
|
-
end
|
340
|
-
|
341
|
-
it "has correct values for all rackspace attributes" do
|
342
|
-
plugin.run
|
343
|
-
expect(plugin[:rackspace][:private_networks][0][:label]).to eq("private-network")
|
344
|
-
expect(plugin[:rackspace][:private_networks][0][:broadcast]).to eq("9.10.11.255")
|
345
|
-
expect(plugin[:rackspace][:private_networks][0][:mac]).to eq("BC:76:4E:20:42:2B")
|
346
|
-
end
|
347
|
-
|
348
|
-
end
|
349
|
-
|
350
|
-
end
|