ohai 8.26.1 → 13.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +3 -4
- data/Rakefile +14 -0
- data/lib/ohai/application.rb +1 -0
- data/lib/ohai/config.rb +2 -88
- data/lib/ohai/dsl/plugin.rb +0 -4
- data/lib/ohai/exception.rb +0 -1
- data/lib/ohai/loader.rb +11 -2
- data/lib/ohai/log.rb +3 -1
- data/lib/ohai/mixin/command.rb +1 -318
- data/lib/ohai/mixin/do_metadata.rb +47 -0
- data/lib/ohai/mixin/ec2_metadata.rb +2 -29
- data/lib/ohai/mixin/gce_metadata.rb +0 -37
- data/lib/ohai/mixin/http_helper.rb +56 -0
- data/lib/ohai/mixin/network_constants.rb +0 -5
- data/lib/ohai/plugins/cloud.rb +144 -157
- data/lib/ohai/plugins/darwin/filesystem.rb +68 -22
- data/lib/ohai/plugins/digital_ocean.rb +24 -42
- data/lib/ohai/plugins/dmi.rb +81 -77
- data/lib/ohai/plugins/ec2.rb +33 -60
- data/lib/ohai/plugins/gce.rb +3 -1
- data/lib/ohai/plugins/hostname.rb +1 -16
- data/lib/ohai/plugins/linux/filesystem.rb +130 -81
- data/lib/ohai/plugins/linux/mdadm.rb +3 -45
- data/lib/ohai/plugins/linux/network.rb +1 -26
- data/lib/ohai/plugins/linux/platform.rb +4 -2
- data/lib/ohai/plugins/linux/virtualization.rb +1 -5
- data/lib/ohai/plugins/scala.rb +1 -13
- data/lib/ohai/plugins/solaris2/network.rb +1 -2
- data/lib/ohai/plugins/uptime.rb +0 -9
- data/lib/ohai/plugins/windows/cpu.rb +2 -1
- data/lib/ohai/plugins/windows/network.rb +1 -1
- data/lib/ohai/runner.rb +0 -5
- data/lib/ohai/system.rb +38 -8
- data/lib/ohai/version.rb +2 -2
- data/ohai.gemspec +1 -1
- data/spec/functional/application_spec.rb +0 -40
- data/spec/functional/plugins/powershell_spec.rb +1 -1
- data/spec/functional/plugins/root_group_spec.rb +1 -1
- data/spec/functional/plugins/windows/uptime_spec.rb +1 -1
- data/spec/ohai_spec.rb +1 -1
- data/spec/support/integration_helper.rb +17 -0
- data/spec/support/platform_helpers.rb +17 -0
- data/spec/unit/application_spec.rb +0 -1
- data/spec/unit/config_spec.rb +0 -111
- data/spec/unit/dsl/plugin_spec.rb +1 -1
- data/spec/unit/hints_spec.rb +1 -1
- data/spec/unit/loader_spec.rb +26 -1
- data/spec/unit/mixin/command_spec.rb +1 -69
- data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
- data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
- data/spec/unit/plugin_config_spec.rb +0 -1
- data/spec/unit/plugins/abort_spec.rb +1 -1
- data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
- data/spec/unit/plugins/aix/filesystem_spec.rb +2 -1
- data/spec/unit/plugins/aix/hostname_spec.rb +1 -1
- data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
- data/spec/unit/plugins/aix/memory_spec.rb +1 -1
- data/spec/unit/plugins/aix/network_spec.rb +1 -1
- data/spec/unit/plugins/aix/os_spec.rb +1 -1
- data/spec/unit/plugins/aix/platform_spec.rb +1 -1
- data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
- data/spec/unit/plugins/aix/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/azure_spec.rb +1 -1
- data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
- data/spec/unit/plugins/bsd/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/c_spec.rb +1 -1
- data/spec/unit/plugins/chef_spec.rb +1 -2
- data/spec/unit/plugins/cloud_spec.rb +210 -50
- data/spec/unit/plugins/darwin/cpu_spec.rb +1 -1
- data/spec/unit/plugins/darwin/filesystem_spec.rb +62 -13
- data/spec/unit/plugins/darwin/hardware_spec.rb +2 -2
- data/spec/unit/plugins/darwin/hostname_spec.rb +1 -1
- data/spec/unit/plugins/darwin/kernel_spec.rb +1 -1
- data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
- data/spec/unit/plugins/darwin/network_spec.rb +1 -1
- data/spec/unit/plugins/darwin/platform_spec.rb +1 -1
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +2 -9
- data/spec/unit/plugins/darwin/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/digital_ocean_spec.rb +39 -110
- data/spec/unit/plugins/dmi_spec.rb +1 -1
- data/spec/unit/plugins/ec2_spec.rb +10 -62
- data/spec/unit/plugins/elixir_spec.rb +1 -1
- data/spec/unit/plugins/erlang_spec.rb +1 -1
- data/spec/unit/plugins/eucalyptus_spec.rb +1 -1
- data/spec/unit/plugins/fail_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/cpu_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/os_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/gce_spec.rb +1 -1
- data/spec/unit/plugins/go_spec.rb +1 -1
- data/spec/unit/plugins/groovy_spec.rb +1 -1
- data/spec/unit/plugins/haskell_spec.rb +1 -1
- data/spec/unit/plugins/hostname_spec.rb +16 -41
- data/spec/unit/plugins/init_package_spec.rb +1 -1
- data/spec/unit/plugins/ip_scopes_spec.rb +18 -6
- data/spec/unit/plugins/java_spec.rb +1 -1
- data/spec/unit/plugins/joyent_spec.rb +17 -1
- data/spec/unit/plugins/kernel_spec.rb +1 -1
- data/spec/unit/plugins/linode_spec.rb +1 -1
- data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
- data/spec/unit/plugins/linux/cpu_spec.rb +1 -2
- data/spec/unit/plugins/linux/filesystem_spec.rb +207 -201
- data/spec/unit/plugins/linux/fips_spec.rb +1 -1
- data/spec/unit/plugins/linux/hostname_spec.rb +1 -1
- data/spec/unit/plugins/linux/hostnamectl_spec.rb +1 -1
- data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
- data/spec/unit/plugins/linux/lsb_spec.rb +1 -1
- data/spec/unit/plugins/linux/machineid_spec.rb +1 -1
- data/spec/unit/plugins/linux/mdadm_spec.rb +2 -68
- data/spec/unit/plugins/linux/memory_spec.rb +1 -1
- data/spec/unit/plugins/linux/network_spec.rb +3 -44
- data/spec/unit/plugins/linux/platform_spec.rb +4 -4
- data/spec/unit/plugins/linux/sessions_spec.rb +1 -1
- data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
- data/spec/unit/plugins/linux/virtualization_spec.rb +1 -28
- data/spec/unit/plugins/lua_spec.rb +1 -1
- data/spec/unit/plugins/mono_spec.rb +1 -1
- data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -1
- data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/network_spec.rb +1 -1
- data/spec/unit/plugins/nodejs_spec.rb +1 -1
- data/spec/unit/plugins/ohai_spec.rb +1 -1
- data/spec/unit/plugins/ohai_time_spec.rb +1 -1
- data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -1
- data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -1
- data/spec/unit/plugins/openbsd/platform_spec.rb +1 -1
- data/spec/unit/plugins/openstack_spec.rb +2 -3
- data/spec/unit/plugins/os_spec.rb +1 -1
- data/spec/unit/plugins/packages_spec.rb +1 -1
- data/spec/unit/plugins/passwd_spec.rb +17 -1
- data/spec/unit/plugins/perl_spec.rb +1 -1
- data/spec/unit/plugins/php_spec.rb +1 -1
- data/spec/unit/plugins/platform_spec.rb +1 -1
- data/spec/unit/plugins/powershell_spec.rb +1 -1
- data/spec/unit/plugins/python_spec.rb +1 -1
- data/spec/unit/plugins/rackspace_spec.rb +1 -2
- data/spec/unit/plugins/root_group_spec.rb +2 -2
- data/spec/unit/plugins/ruby_spec.rb +1 -1
- data/spec/unit/plugins/rust_spec.rb +1 -1
- data/spec/unit/plugins/scala_spec.rb +3 -37
- data/spec/unit/plugins/shard_spec.rb +1 -1
- data/spec/unit/plugins/shells_spec.rb +1 -1
- data/spec/unit/plugins/softlayer_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/cpu_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/dmi_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/memory_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/network_spec.rb +7 -4
- data/spec/unit/plugins/solaris2/platform_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/zpools_spec.rb +1 -1
- data/spec/unit/plugins/ssh_host_keys_spec.rb +1 -1
- data/spec/unit/plugins/sysconf_spec.rb +1 -1
- data/spec/unit/plugins/timezone_spec.rb +1 -1
- data/spec/unit/plugins/virtualbox_spec.rb +1 -1
- data/spec/unit/plugins/vmware_spec.rb +2 -1
- data/spec/unit/plugins/windows/cpu_spec.rb +9 -2
- data/spec/unit/plugins/windows/fips_spec.rb +1 -1
- data/spec/unit/plugins/windows/memory_spec.rb +1 -1
- data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
- data/spec/unit/plugins/windows/virtualization_spec.rb +1 -1
- data/spec/unit/provides_map_spec.rb +1 -1
- data/spec/unit/runner_spec.rb +1 -1
- data/spec/unit/system_spec.rb +68 -76
- data/spec/unit/util/file_helper_spec.rb +1 -1
- data/spec/unit/util/ip_helper_spec.rb +1 -1
- metadata +6 -20
- data/lib/ohai/plugins/cloud_v2.rb +0 -315
- data/lib/ohai/plugins/darwin/filesystem2.rb +0 -107
- data/lib/ohai/plugins/linux/filesystem2.rb +0 -223
- data/lib/ohai/plugins/linux/lspci.rb +0 -76
- data/lib/ohai/plugins/network_listeners.rb +0 -60
- data/lib/ohai/plugins/sigar/cpu.rb +0 -44
- data/lib/ohai/plugins/sigar/filesystem.rb +0 -50
- data/lib/ohai/plugins/sigar/memory.rb +0 -39
- data/lib/ohai/plugins/sigar/network.rb +0 -168
- data/lib/ohai/plugins/sigar/network_route.rb +0 -64
- data/lib/ohai/plugins/sigar/platform.rb +0 -30
- data/spec/unit/plugins/cloud_v2_spec.rb +0 -389
- data/spec/unit/plugins/darwin/filesystem2_spec.rb +0 -139
- data/spec/unit/plugins/linux/filesystem2_spec.rb +0 -437
- data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
- data/spec/unit/plugins/sigar/network_route_spec.rb +0 -148
data/spec/unit/hints_spec.rb
CHANGED
data/spec/unit/loader_spec.rb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
|
20
|
+
require_relative "../spec_helper.rb"
|
21
21
|
|
22
22
|
describe Ohai::Loader do
|
23
23
|
extend IntegrationSupport
|
@@ -95,6 +95,31 @@ EOF
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
+
when_plugins_directory "is an additional plugin path" do
|
99
|
+
with_plugin("cookbook_a/alpha.rb", <<EOF)
|
100
|
+
Ohai.plugin(:Alpha) do
|
101
|
+
provides "alpha"
|
102
|
+
end
|
103
|
+
EOF
|
104
|
+
|
105
|
+
with_plugin("cookbook_b/beta.rb", <<EOF)
|
106
|
+
Ohai.plugin(:Beta) do
|
107
|
+
provides "beta"
|
108
|
+
end
|
109
|
+
EOF
|
110
|
+
|
111
|
+
describe "#load_additional" do
|
112
|
+
it "adds the plugins to the map" do
|
113
|
+
loader.load_additional(@plugins_directory)
|
114
|
+
expect(provides_map.map.keys).to include("alpha")
|
115
|
+
end
|
116
|
+
|
117
|
+
it "returns a set of plugins" do
|
118
|
+
expect(loader.load_additional(@plugins_directory)).to include(Ohai::NamedPlugin::Alpha)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
98
123
|
when_plugins_directory "contains invalid plugins" do
|
99
124
|
with_plugin("extra_s.rb", <<EOF)
|
100
125
|
Ohai.plugins(:ExtraS) do
|
@@ -17,75 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
describe Ohai::Mixin::Command, "popen4" do
|
23
|
-
break if RUBY_PLATFORM =~ /(win|w)32$/
|
24
|
-
|
25
|
-
it "should default all commands to be run in the POSIX standard C locale" do
|
26
|
-
Ohai::Mixin::Command.popen4("echo $LC_ALL") do |pid, stdin, stdout, stderr|
|
27
|
-
stdin.close
|
28
|
-
expect(stdout.read.strip).to eq("C")
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should respect locale when specified explicitly" do
|
33
|
-
Ohai::Mixin::Command.popen4("echo $LC_ALL", :environment => { "LC_ALL" => "es" }) do |pid, stdin, stdout, stderr|
|
34
|
-
stdin.close
|
35
|
-
expect(stdout.read.strip).to eq("es")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
if defined?(::Encoding) && "".respond_to?(:force_encoding) #i.e., ruby 1.9
|
40
|
-
context "when external commands return UTF-8 strings and we are running under LANG=C encoding" do
|
41
|
-
before do
|
42
|
-
@saved_default_external = Encoding.default_external
|
43
|
-
@saved_default_internal = Encoding.default_internal
|
44
|
-
Encoding.default_external = Encoding::US_ASCII
|
45
|
-
Encoding.default_internal = Encoding::US_ASCII
|
46
|
-
end
|
47
|
-
|
48
|
-
after do
|
49
|
-
Encoding.default_external = @saved_default_external
|
50
|
-
Encoding.default_internal = @saved_default_internal
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should force encode the string to UTF-8" do
|
54
|
-
extend Ohai::Mixin::Command
|
55
|
-
snowy = run_command(:command => ("echo '" + ("☃" * 8096) + "'"))[1]
|
56
|
-
expect(snowy.encoding).to eq(Encoding::UTF_8)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should force encode the string to UTF-8" do
|
61
|
-
extend Ohai::Mixin::Command
|
62
|
-
snowy = run_command(:command => ("echo '" + ("☃" * 8096) + "'"))[1]
|
63
|
-
expect(snowy.encoding).to eq(Encoding::UTF_8)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
it "reaps zombie processes after exec fails [OHAI-455]" do
|
68
|
-
# NOTE: depending on ulimit settings, GC, etc., before the OHAI-455 patch,
|
69
|
-
# ohai could also exhaust the available file descriptors when creating this
|
70
|
-
# many zombie processes. A regression _could_ cause Errno::EMFILE but this
|
71
|
-
# probably won't be consistent on different environments.
|
72
|
-
created_procs = 0
|
73
|
-
100.times do
|
74
|
-
begin
|
75
|
-
Ohai::Mixin::Command.popen4("/bin/this-is-not-a-real-command") { |p, i, o, e| nil }
|
76
|
-
rescue Ohai::Exceptions::Exec
|
77
|
-
created_procs += 1
|
78
|
-
end
|
79
|
-
end
|
80
|
-
expect(created_procs).to eq(100)
|
81
|
-
reaped_procs = 0
|
82
|
-
begin
|
83
|
-
loop { Process.wait(-1); reaped_procs += 1 }
|
84
|
-
rescue Errno::ECHILD
|
85
|
-
end
|
86
|
-
expect(reaped_procs).to eq(0)
|
87
|
-
end
|
88
|
-
end
|
20
|
+
require_relative "../../spec_helper.rb"
|
89
21
|
|
90
22
|
describe Ohai::Mixin::Command, "shell_out" do
|
91
23
|
let(:cmd) { "sparkle-dream --version" }
|
@@ -17,7 +17,7 @@
|
|
17
17
|
# See the License for the specific language governing permissions and
|
18
18
|
# limitations under the License.
|
19
19
|
|
20
|
-
|
20
|
+
require_relative "../../spec_helper.rb"
|
21
21
|
require "ohai/mixin/softlayer_metadata"
|
22
22
|
|
23
23
|
describe ::Ohai::Mixin::SoftlayerMetadata do
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
-
|
19
|
+
require_relative "../../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "AIX cpu plugin" do
|
22
22
|
before(:each) do
|
@@ -15,7 +15,8 @@
|
|
15
15
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
|
-
|
18
|
+
|
19
|
+
require_relative "../../../spec_helper.rb"
|
19
20
|
|
20
21
|
describe Ohai::System, "AIX filesystem plugin" do
|
21
22
|
before(:each) do
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
-
|
19
|
+
require_relative "../../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "AIX hostname plugin" do
|
22
22
|
before(:each) do
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
-
|
19
|
+
require_relative "../../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "AIX kernel plugin" do
|
22
22
|
before(:each) do
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
-
|
19
|
+
require_relative "../../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "AIX network plugin" do
|
22
22
|
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
|
-
|
18
|
+
require_relative "../../../spec_helper.rb"
|
19
19
|
|
20
20
|
describe Ohai::System, "AIX os plugin" do
|
21
21
|
before(:each) do
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
-
|
19
|
+
require_relative "../../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "Aix plugin platform" do
|
22
22
|
before(:each) do
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
|
-
|
19
|
+
require_relative "../../../spec_helper.rb"
|
20
20
|
|
21
21
|
describe Ohai::System, "Aix plugin uptime" do
|
22
22
|
|
@@ -17,7 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
|
20
|
+
require_relative "../../../spec_helper.rb"
|
21
21
|
|
22
22
|
describe Ohai::System, "BSD filesystem plugin" do
|
23
23
|
let(:plugin) { get_plugin("bsd/filesystem") }
|
data/spec/unit/plugins/c_spec.rb
CHANGED
@@ -15,7 +15,62 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
|
18
|
+
require_relative "../../spec_helper.rb"
|
19
|
+
require "ipaddr"
|
20
|
+
|
21
|
+
describe "CloudAttrs object" do
|
22
|
+
before(:each) do
|
23
|
+
@plugin = get_plugin("cloud")
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:cloud_node) do
|
27
|
+
{ "public_ipv4_addrs" => ["1.2.3.1"],
|
28
|
+
"local_ipv4_addrs" => ["1.2.4.1"],
|
29
|
+
"public_ipv6_addrs" => ["3ffe:505:2::1"],
|
30
|
+
"local_ipv6_addrs" => ["3ffe:506:2::1"],
|
31
|
+
"public_ipv4" => "1.2.3.1",
|
32
|
+
"local_ipv4" => "1.2.4.1",
|
33
|
+
"public_ipv6" => "3ffe:505:2::1",
|
34
|
+
"local_ipv6" => "3ffe:506:2::1",
|
35
|
+
"public_hostname" => "myhost.somewhere.com",
|
36
|
+
"local_hostname" => "my-localhost",
|
37
|
+
"provider" => "my_awesome_cloud",
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
it "populates cloud mash" do
|
42
|
+
@cloud_attr_obj = ::CloudAttrs.new()
|
43
|
+
@cloud_attr_obj.add_ipv4_addr("1.2.3.1", :public)
|
44
|
+
@cloud_attr_obj.add_ipv4_addr("1.2.4.1", :private)
|
45
|
+
@cloud_attr_obj.add_ipv6_addr("3ffe:505:2::1", :public)
|
46
|
+
@cloud_attr_obj.add_ipv6_addr("3ffe:506:2::1", :private)
|
47
|
+
@cloud_attr_obj.public_hostname = "myhost.somewhere.com"
|
48
|
+
@cloud_attr_obj.local_hostname = "my-localhost"
|
49
|
+
@cloud_attr_obj.provider = "my_awesome_cloud"
|
50
|
+
expect(@cloud_attr_obj.cloud_mash).to eq(cloud_node)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "throws exception with a bad ipv4 address" do
|
54
|
+
@cloud_attr_obj = ::CloudAttrs.new()
|
55
|
+
expect { @cloud_attr_obj.add_ipv6_addr("somebogusstring", :public) }.to raise_error(RuntimeError)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "throws exception with a bad ipv6 address" do
|
59
|
+
@cloud_attr_obj = ::CloudAttrs.new()
|
60
|
+
expect { @cloud_attr_obj.add_ipv6_addr("FEED:B0B:DEAD:BEEF", :public) }.to raise_error(RuntimeError)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "throws exception with ipv6 address passed to ipv4" do
|
64
|
+
@cloud_attr_obj = ::CloudAttrs.new()
|
65
|
+
expect { @cloud_attr_obj.add_ipv4_addr("3ffe:506:2::1", :public) }.to raise_error(RuntimeError)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "throws exception with ipv4 address passed to ipv6" do
|
69
|
+
@cloud_attr_obj = ::CloudAttrs.new()
|
70
|
+
expect { @cloud_attr_obj.add_ipv6_addr("1.2.3.4", :public) }.to raise_error(RuntimeError)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
19
74
|
|
20
75
|
describe Ohai::System, "plugin cloud" do
|
21
76
|
before(:each) do
|
@@ -29,27 +84,40 @@ describe Ohai::System, "plugin cloud" do
|
|
29
84
|
@plugin[:eucalyptus] = nil
|
30
85
|
@plugin[:linode] = nil
|
31
86
|
@plugin[:azure] = nil
|
87
|
+
@plugin[:gce] = nil
|
32
88
|
@plugin[:digital_ocean] = nil
|
33
89
|
@plugin.run
|
34
90
|
expect(@plugin[:cloud]).to be_nil
|
91
|
+
expect(@plugin[:cloud_v2]).to be_nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "with a cloud mash" do
|
96
|
+
before do
|
97
|
+
@plugin[:ec2] = Mash.new
|
98
|
+
end
|
99
|
+
|
100
|
+
it "populates cloud public ip" do
|
101
|
+
@plugin.run
|
102
|
+
expect(@plugin[:cloud]).to eq(@plugin[:cloud_v2])
|
35
103
|
end
|
36
104
|
end
|
37
105
|
|
38
106
|
describe "with EC2 mash" do
|
39
107
|
before do
|
40
|
-
@plugin[:ec2] = Mash.new
|
108
|
+
@plugin[:ec2] = Mash.new
|
41
109
|
end
|
42
110
|
|
43
111
|
it "populates cloud public ip" do
|
44
112
|
@plugin[:ec2]["public_ipv4"] = "174.129.150.8"
|
45
113
|
@plugin.run
|
46
|
-
expect(@plugin[:cloud][:
|
114
|
+
expect(@plugin[:cloud][:public_ipv4_addrs][0]).to eq(@plugin[:ec2]["public_ipv4"])
|
47
115
|
end
|
48
116
|
|
49
117
|
it "populates cloud private ip" do
|
50
118
|
@plugin[:ec2]["local_ipv4"] = "10.252.42.149"
|
51
119
|
@plugin.run
|
52
|
-
expect(@plugin[:cloud][:
|
120
|
+
expect(@plugin[:cloud][:local_ipv4_addrs][0]).to eq(@plugin[:ec2]["local_ipv4"])
|
53
121
|
end
|
54
122
|
|
55
123
|
it "populates cloud provider" do
|
@@ -58,9 +126,69 @@ describe Ohai::System, "plugin cloud" do
|
|
58
126
|
end
|
59
127
|
end
|
60
128
|
|
129
|
+
describe "with GCE mash" do
|
130
|
+
describe "with a public IP" do
|
131
|
+
before do
|
132
|
+
@plugin[:gce] = Mash.new
|
133
|
+
@plugin[:gce]["instance"] = Mash.new
|
134
|
+
@plugin[:gce]["instance"]["networkInterfaces"] = [
|
135
|
+
{
|
136
|
+
"accessConfigs" => [ { "externalIp" => "8.35.198.173", "type" => "ONE_TO_ONE_NAT" } ],
|
137
|
+
"ip" => "10.240.0.102",
|
138
|
+
"network" => "projects/foo/networks/default",
|
139
|
+
},
|
140
|
+
]
|
141
|
+
end
|
142
|
+
|
143
|
+
it "populates cloud public ip" do
|
144
|
+
@plugin.run
|
145
|
+
expect(@plugin[:cloud][:public_ipv4_addrs][0]).to eq("8.35.198.173")
|
146
|
+
end
|
147
|
+
|
148
|
+
it "populates cloud private ip" do
|
149
|
+
@plugin.run
|
150
|
+
expect(@plugin[:cloud][:local_ipv4_addrs][0]).to eq("10.240.0.102")
|
151
|
+
end
|
152
|
+
|
153
|
+
it "populates cloud provider" do
|
154
|
+
@plugin.run
|
155
|
+
expect(@plugin[:cloud][:provider]).to eq("gce")
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "with no public IP" do
|
160
|
+
before do
|
161
|
+
@plugin[:gce] = Mash.new
|
162
|
+
@plugin[:gce]["instance"] = Mash.new
|
163
|
+
@plugin[:gce]["instance"]["networkInterfaces"] = [
|
164
|
+
{
|
165
|
+
"accessConfigs" => [ { "externalIp" => "", "type" => "ONE_TO_ONE_NAT" } ],
|
166
|
+
"ip" => "10.240.0.102",
|
167
|
+
"network" => "projects/foo/networks/default",
|
168
|
+
},
|
169
|
+
]
|
170
|
+
end
|
171
|
+
|
172
|
+
it "does not populate cloud public ip" do
|
173
|
+
@plugin.run
|
174
|
+
expect(@plugin[:cloud][:public_ipv4_addrs]).to be_nil
|
175
|
+
end
|
176
|
+
|
177
|
+
it "populates cloud private ip" do
|
178
|
+
@plugin.run
|
179
|
+
expect(@plugin[:cloud][:local_ipv4_addrs][0]).to eq("10.240.0.102")
|
180
|
+
end
|
181
|
+
|
182
|
+
it "populates cloud provider" do
|
183
|
+
@plugin.run
|
184
|
+
expect(@plugin[:cloud][:provider]).to eq("gce")
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
61
189
|
describe "with rackspace" do
|
62
190
|
before do
|
63
|
-
@plugin[:rackspace] = Mash.new
|
191
|
+
@plugin[:rackspace] = Mash.new
|
64
192
|
end
|
65
193
|
|
66
194
|
it "populates cloud public ip" do
|
@@ -90,13 +218,13 @@ describe Ohai::System, "plugin cloud" do
|
|
90
218
|
it "populates first cloud public ip" do
|
91
219
|
@plugin[:rackspace][:public_ipv4] = "174.129.150.8"
|
92
220
|
@plugin.run
|
93
|
-
expect(@plugin[:cloud][:
|
221
|
+
expect(@plugin[:cloud][:public_ipv4_addrs].first).to eq(@plugin[:rackspace][:public_ipv4])
|
94
222
|
end
|
95
223
|
|
96
224
|
it "populates first cloud public ip" do
|
97
225
|
@plugin[:rackspace][:local_ipv4] = "174.129.150.8"
|
98
226
|
@plugin.run
|
99
|
-
expect(@plugin[:cloud][:
|
227
|
+
expect(@plugin[:cloud][:local_ipv4_addrs].first).to eq(@plugin[:rackspace][:local_ipv4])
|
100
228
|
end
|
101
229
|
|
102
230
|
it "populates cloud provider" do
|
@@ -107,25 +235,25 @@ describe Ohai::System, "plugin cloud" do
|
|
107
235
|
|
108
236
|
describe "with linode mash" do
|
109
237
|
before do
|
110
|
-
@plugin[:linode] = Mash.new
|
238
|
+
@plugin[:linode] = Mash.new
|
111
239
|
end
|
112
240
|
|
113
241
|
it "populates cloud public ip" do
|
114
242
|
@plugin[:linode]["public_ip"] = "174.129.150.8"
|
115
243
|
@plugin.run
|
116
|
-
expect(@plugin[:cloud][:
|
244
|
+
expect(@plugin[:cloud][:public_ipv4_addrs][0]).to eq(@plugin[:linode][:public_ip])
|
117
245
|
end
|
118
246
|
|
119
247
|
it "populates cloud private ip" do
|
120
248
|
@plugin[:linode]["private_ip"] = "10.252.42.149"
|
121
249
|
@plugin.run
|
122
|
-
expect(@plugin[:cloud][:
|
250
|
+
expect(@plugin[:cloud][:local_ipv4_addrs][0]).to eq(@plugin[:linode][:private_ip])
|
123
251
|
end
|
124
252
|
|
125
253
|
it "populates first cloud public ip" do
|
126
254
|
@plugin[:linode]["public_ip"] = "174.129.150.8"
|
127
255
|
@plugin.run
|
128
|
-
expect(@plugin[:cloud][:
|
256
|
+
expect(@plugin[:cloud][:public_ipv4_addrs].first).to eq(@plugin[:linode][:public_ip])
|
129
257
|
end
|
130
258
|
|
131
259
|
it "populates cloud provider" do
|
@@ -136,19 +264,19 @@ describe Ohai::System, "plugin cloud" do
|
|
136
264
|
|
137
265
|
describe "with eucalyptus mash" do
|
138
266
|
before do
|
139
|
-
@plugin[:eucalyptus] = Mash.new
|
267
|
+
@plugin[:eucalyptus] = Mash.new
|
140
268
|
end
|
141
269
|
|
142
270
|
it "populates cloud public ip" do
|
143
271
|
@plugin[:eucalyptus]["public_ipv4"] = "174.129.150.8"
|
144
272
|
@plugin.run
|
145
|
-
expect(@plugin[:cloud][:
|
273
|
+
expect(@plugin[:cloud][:public_ipv4_addrs][0]).to eq(@plugin[:eucalyptus]["public_ipv4"])
|
146
274
|
end
|
147
275
|
|
148
276
|
it "populates cloud private ip" do
|
149
277
|
@plugin[:eucalyptus]["local_ipv4"] = "10.252.42.149"
|
150
278
|
@plugin.run
|
151
|
-
expect(@plugin[:cloud][:
|
279
|
+
expect(@plugin[:cloud][:local_ipv4_addrs][0]).to eq(@plugin[:eucalyptus]["local_ipv4"])
|
152
280
|
end
|
153
281
|
|
154
282
|
it "populates cloud provider" do
|
@@ -159,39 +287,31 @@ describe Ohai::System, "plugin cloud" do
|
|
159
287
|
|
160
288
|
describe "with Azure mash" do
|
161
289
|
before do
|
162
|
-
@plugin[:azure] = Mash.new
|
163
|
-
end
|
164
|
-
|
165
|
-
it "populates cloud private ip" do
|
166
|
-
@plugin[:azure]["private_ip"] = "10.0.0.1"
|
167
|
-
@plugin.run
|
168
|
-
expect(@plugin[:cloud][:private_ips][0]).to eq(@plugin[:azure]["private_ip"])
|
290
|
+
@plugin[:azure] = Mash.new
|
169
291
|
end
|
170
292
|
|
171
293
|
it "populates cloud public ip" do
|
172
294
|
@plugin[:azure]["public_ip"] = "174.129.150.8"
|
173
295
|
@plugin.run
|
174
|
-
expect(@plugin[:cloud][:
|
175
|
-
expect(@plugin[:cloud][:public_ipv4]).to eq(@plugin[:azure]["public_ip"])
|
296
|
+
expect(@plugin[:cloud][:public_ipv4_addrs][0]).to eq(@plugin[:azure]["public_ip"])
|
176
297
|
end
|
177
298
|
|
178
|
-
it "populates cloud vm_name" do
|
299
|
+
it "doesn't populates cloud vm_name" do
|
179
300
|
@plugin[:azure]["vm_name"] = "linux-vm"
|
180
301
|
@plugin.run
|
181
|
-
expect(@plugin[:cloud][:vm_name]).
|
302
|
+
expect(@plugin[:cloud][:vm_name]).not_to eq(@plugin[:azure]["vm_name"])
|
182
303
|
end
|
183
304
|
|
184
|
-
it "populates cloud
|
305
|
+
it "populates cloud public_hostname" do
|
185
306
|
@plugin[:azure]["public_fqdn"] = "linux-vm-svc.cloudapp.net"
|
186
307
|
@plugin.run
|
187
|
-
expect(@plugin[:cloud][:public_fqdn]).to eq(@plugin[:azure]["public_fqdn"])
|
188
308
|
expect(@plugin[:cloud][:public_hostname]).to eq(@plugin[:azure]["public_fqdn"])
|
189
309
|
end
|
190
310
|
|
191
|
-
it "
|
311
|
+
it "doesn't populate cloud public_ssh_port" do
|
192
312
|
@plugin[:azure]["public_ssh_port"] = "22"
|
193
313
|
@plugin.run
|
194
|
-
expect(@plugin[:cloud][:public_ssh_port]).to
|
314
|
+
expect(@plugin[:cloud][:public_ssh_port]).to be_nil
|
195
315
|
end
|
196
316
|
|
197
317
|
it "should not populate cloud public_ssh_port when winrm is used" do
|
@@ -203,7 +323,7 @@ describe Ohai::System, "plugin cloud" do
|
|
203
323
|
it "populates cloud public_winrm_port" do
|
204
324
|
@plugin[:azure]["public_winrm_port"] = "5985"
|
205
325
|
@plugin.run
|
206
|
-
expect(@plugin[:cloud][:public_winrm_port]).to
|
326
|
+
expect(@plugin[:cloud][:public_winrm_port]).to be_nil
|
207
327
|
end
|
208
328
|
|
209
329
|
it "populates cloud provider" do
|
@@ -215,54 +335,94 @@ describe Ohai::System, "plugin cloud" do
|
|
215
335
|
describe "with digital_ocean mash" do
|
216
336
|
before do
|
217
337
|
@plugin[:digital_ocean] = Mash.new
|
218
|
-
@plugin[:digital_ocean][:
|
219
|
-
@plugin[:digital_ocean][:
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
338
|
+
@plugin[:digital_ocean][:interfaces] = Mash.new
|
339
|
+
@plugin[:digital_ocean][:interfaces] = {
|
340
|
+
"private" =>
|
341
|
+
[
|
342
|
+
{
|
343
|
+
"ipv4" =>
|
344
|
+
{
|
345
|
+
"ip_address" => "10.135.32.4",
|
346
|
+
"netmask" => "255.255.0.0",
|
347
|
+
"gateway" => "10.135.0.1",
|
348
|
+
},
|
349
|
+
"mac" => "36:9e:23:65:c1:fe",
|
350
|
+
"type" => "private",
|
351
|
+
},
|
352
|
+
],
|
353
|
+
"public" =>
|
354
|
+
[
|
355
|
+
{
|
356
|
+
"ipv4" =>
|
357
|
+
{
|
358
|
+
"ip_address" => "207.154.221.42",
|
359
|
+
"netmask" => "255.255.240.0",
|
360
|
+
"gateway" => "207.154.208.1",
|
361
|
+
},
|
362
|
+
"ipv6" =>
|
363
|
+
{
|
364
|
+
"ip_address" => "2A03:B0C0:0003:00D0:0000:0000:3B15:B001",
|
365
|
+
"cidr" => 64,
|
366
|
+
"gateway" => "2A03:B0C0:0003:00D0:0000:0000:0000:0001",
|
367
|
+
},
|
368
|
+
"anchor_ipv4" =>
|
369
|
+
{
|
370
|
+
"ip_address" => "10.19.0.5",
|
371
|
+
"netmask" => "255.255.0.0",
|
372
|
+
"gateway" => "10.19.0.1",
|
373
|
+
},
|
374
|
+
"mac" => "9a:80:15:02:7a:c1",
|
375
|
+
"type" => "public",
|
376
|
+
},
|
377
|
+
],
|
378
|
+
}
|
224
379
|
end
|
225
380
|
|
226
381
|
before(:each) do
|
227
382
|
@plugin.run
|
228
383
|
end
|
229
384
|
|
230
|
-
it "populates cloud public hostname" do
|
231
|
-
expect(@plugin[:cloud][:public_hostname]).to eq("public.example.com")
|
232
|
-
end
|
233
|
-
|
234
385
|
it "populates cloud local hostname" do
|
235
386
|
expect(@plugin[:cloud][:local_hostname]).to be_nil
|
236
387
|
end
|
237
388
|
|
238
|
-
it "populates cloud
|
239
|
-
expect(@plugin[:cloud][:
|
240
|
-
|
389
|
+
it "populates cloud public_ipv4_addrs" do
|
390
|
+
expect(@plugin[:cloud][:public_ipv4_addrs]).to eq(["207.154.221.42"])
|
391
|
+
|
241
392
|
end
|
242
393
|
|
243
|
-
it "populates cloud
|
244
|
-
expect(@plugin[:cloud][:
|
245
|
-
|
394
|
+
it "populates cloud local_ipv4_addrs" do
|
395
|
+
expect(@plugin[:cloud][:local_ipv4_addrs]).to eq(["10.135.32.4"])
|
396
|
+
|
246
397
|
end
|
247
398
|
|
248
399
|
it "populates cloud public_ipv4" do
|
249
|
-
expect(@plugin[:cloud][:public_ipv4]).to eq(
|
400
|
+
expect(@plugin[:cloud][:public_ipv4]).to eq("207.154.221.42")
|
250
401
|
end
|
251
402
|
|
252
403
|
it "populates cloud local_ipv4" do
|
253
|
-
expect(@plugin[:cloud][:local_ipv4]).to eq(
|
404
|
+
expect(@plugin[:cloud][:local_ipv4]).to eq("10.135.32.4")
|
405
|
+
end
|
406
|
+
|
407
|
+
it "populates cloud public_ipv6_addrs" do
|
408
|
+
expect(@plugin[:cloud][:public_ipv6_addrs]).to eq(["2a03:b0c0:3:d0::3b15:b001"])
|
409
|
+
end
|
410
|
+
|
411
|
+
it "populates cloud local_ipv6_addrs" do
|
412
|
+
expect(@plugin[:cloud][:local_ipv6_addrs]).to be_nil
|
254
413
|
end
|
255
414
|
|
256
415
|
it "populates cloud public_ipv6" do
|
257
|
-
expect(@plugin[:cloud][:public_ipv6]).to eq(
|
416
|
+
expect(@plugin[:cloud][:public_ipv6]).to eq("2a03:b0c0:3:d0::3b15:b001")
|
258
417
|
end
|
259
418
|
|
260
419
|
it "populates cloud local_ipv6" do
|
261
|
-
expect(@plugin[:cloud][:local_ipv6]).to
|
420
|
+
expect(@plugin[:cloud][:local_ipv6]).to be_nil
|
262
421
|
end
|
263
422
|
|
264
423
|
it "populates cloud provider" do
|
265
424
|
expect(@plugin[:cloud][:provider]).to eq("digital_ocean")
|
266
425
|
end
|
267
426
|
end
|
427
|
+
|
268
428
|
end
|