ohai 8.14.0 → 8.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/ohai +0 -0
- data/lib/ohai/hints.rb +16 -14
- data/lib/ohai/plugins/c.rb +1 -1
- data/lib/ohai/plugins/elixir.rb +15 -9
- data/lib/ohai/plugins/erlang.rb +32 -14
- data/lib/ohai/plugins/linux/fips.rb +38 -0
- data/lib/ohai/plugins/mono.rb +22 -13
- data/lib/ohai/plugins/scala.rb +21 -14
- data/lib/ohai/plugins/windows/fips.rb +50 -0
- data/lib/ohai/version.rb +1 -1
- data/spec/unit/plugins/azure_spec.rb +43 -51
- data/spec/unit/plugins/c_spec.rb +4 -4
- data/spec/unit/plugins/digital_ocean_spec.rb +51 -88
- data/spec/unit/plugins/ec2_spec.rb +5 -35
- data/spec/unit/plugins/elixir_spec.rb +25 -15
- data/spec/unit/plugins/erlang_spec.rb +29 -23
- data/spec/unit/plugins/eucalyptus_spec.rb +21 -42
- data/spec/unit/plugins/gce_spec.rb +16 -22
- data/spec/unit/plugins/linode_spec.rb +27 -50
- data/spec/unit/plugins/linux/fips_spec.rb +59 -0
- data/spec/unit/plugins/mono_spec.rb +27 -12
- data/spec/unit/plugins/rackspace_spec.rb +14 -44
- data/spec/unit/plugins/scala_spec.rb +24 -15
- data/spec/unit/plugins/softlayer_spec.rb +1 -1
- data/spec/unit/plugins/windows/fips_spec.rb +86 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7df39abb86c4a5e8f6936d8f0707ae4ff7de75ed
|
4
|
+
data.tar.gz: 16f9c140d9b23470add7d01886bfd6221b58300f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f2e803ef3895622aafedf24da387c4b95afebd0bd09b7442eee279ad2b6a974145c1c3cbc1ff8eee8465a37366afdbfad5e85cb88048271c4b03004fd7598ca
|
7
|
+
data.tar.gz: 12ae394e37c107d5cc10a162928aabc9dba06685d578b7cd188141a8ad91f2dbb66deb966501965880eec9d10e7bc49e7239bf6ecf64d88aa7fba21ba6fc263d
|
data/bin/ohai
CHANGED
File without changes
|
data/lib/ohai/hints.rb
CHANGED
@@ -22,28 +22,30 @@ require "ffi_yajl"
|
|
22
22
|
module Ohai
|
23
23
|
module Hints
|
24
24
|
def self.refresh_hints
|
25
|
-
@hints =
|
25
|
+
@hints = {}
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.parse_hint_file(filename)
|
29
|
+
json_parser = FFI_Yajl::Parser.new
|
30
|
+
hash = json_parser.parse(File.read(filename))
|
31
|
+
hash || {} # hint
|
32
|
+
# should exist because the file did, even if it didn't
|
33
|
+
# contain anything
|
34
|
+
rescue FFI_Yajl::ParseError => e
|
35
|
+
Ohai::Log.error("Could not parse hint file at #{filename}: #{e.message}")
|
26
36
|
end
|
27
37
|
|
28
38
|
def self.hint?(name)
|
29
|
-
@hints ||=
|
39
|
+
@hints ||= {}
|
30
40
|
return @hints[name] if @hints[name]
|
31
|
-
|
32
41
|
Ohai.config[:hints_path].each do |path|
|
33
42
|
filename = File.join(path, "#{name}.json")
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
hash = json_parser.parse(File.read(filename))
|
38
|
-
@hints[name] = hash || Hash.new # hint
|
39
|
-
# should exist because the file did, even if it didn't
|
40
|
-
# contain anything
|
41
|
-
rescue FFI_Yajl::ParseError => e
|
42
|
-
Ohai::Log.error("Could not parse hint file at #{filename}: #{e.message}")
|
43
|
-
end
|
44
|
-
end
|
43
|
+
next unless File.exist?(filename)
|
44
|
+
Ohai::Log.debug("Found hint #{name}.json at #{filename}")
|
45
|
+
@hints[name] = parse_hint_file(filename)
|
45
46
|
end
|
46
47
|
|
48
|
+
Ohai::Log.debug("Did not find hint #{name}.json in the hint path(s): #{Ohai.config[:hints_path].join(', ')} ") unless @hints.key?(name)
|
47
49
|
@hints[name]
|
48
50
|
end
|
49
51
|
end
|
data/lib/ohai/plugins/c.rb
CHANGED
data/lib/ohai/plugins/elixir.rb
CHANGED
@@ -15,18 +15,24 @@
|
|
15
15
|
|
16
16
|
Ohai.plugin(:Elixir) do
|
17
17
|
provides "languages/elixir"
|
18
|
-
|
19
18
|
depends "languages"
|
20
19
|
|
21
20
|
collect_data do
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
begin
|
22
|
+
so = shell_out("elixir -v")
|
23
|
+
# Sample output:
|
24
|
+
# Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
|
25
|
+
#
|
26
|
+
# Elixir 1.2.4
|
27
|
+
if so.exitstatus == 0
|
28
|
+
elixir = Mash.new
|
29
|
+
if so.stdout =~ /^Elixir (\S*)/
|
30
|
+
elixir[:version] = $1
|
31
|
+
languages[:elixir] = elixir
|
32
|
+
end
|
33
|
+
end
|
34
|
+
rescue Ohai::Exceptions::Exec
|
35
|
+
Ohai::Log.debug('Elixir plugin: Could not shell_out "elixir -v". Skipping plugin')
|
30
36
|
end
|
31
37
|
end
|
32
38
|
end
|
data/lib/ohai/plugins/erlang.rb
CHANGED
@@ -18,26 +18,44 @@
|
|
18
18
|
|
19
19
|
Ohai.plugin(:Erlang) do
|
20
20
|
provides "languages/erlang"
|
21
|
-
|
22
21
|
depends "languages"
|
23
22
|
|
24
23
|
collect_data do
|
25
|
-
output = nil
|
26
|
-
|
27
24
|
erlang = Mash.new
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
25
|
+
|
26
|
+
begin
|
27
|
+
so = shell_out("erl -eval 'erlang:display(erlang:system_info(otp_release)), erlang:display(erlang:system_info(version)), erlang:display(erlang:system_info(nif_version)), halt().' -noshell")
|
28
|
+
# Sample output:
|
29
|
+
# "18"
|
30
|
+
# "7.3"
|
31
|
+
# "2.10"
|
32
|
+
if so.exitstatus == 0
|
33
|
+
output = so.stdout.split(/\r\n/).map! { |x| x.delete('\\"') }
|
34
|
+
erlang[:version] = output[0]
|
35
|
+
erlang[:erts_version] = output[1]
|
36
|
+
erlang[:nif_version] = output[2]
|
37
|
+
end
|
38
|
+
rescue Ohai::Exceptions::Exec
|
39
|
+
Ohai::Log.debug('Erlang plugin: Could not shell_out "erl -eval \'erlang:display(erlang:system_info(otp_release)), erlang:display(erlang:system_info(version)), erlang:display(erlang:system_info(nif_version)), halt().\' -noshell". Skipping data')
|
40
|
+
end
|
41
|
+
|
42
|
+
begin
|
43
|
+
so = shell_out("erl +V")
|
44
|
+
# Sample output:
|
45
|
+
# Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 7.3
|
46
|
+
if so.exitstatus == 0
|
47
|
+
output = so.stderr.split
|
48
|
+
if output.length >= 6
|
49
|
+
options = output[1]
|
50
|
+
options.gsub!(/(\(|\))/, "")
|
51
|
+
erlang[:options] = options.split(",")
|
52
|
+
erlang[:emulator] = output[2].gsub!(/(\(|\))/, "")
|
39
53
|
end
|
40
54
|
end
|
55
|
+
rescue Ohai::Exceptions::Exec
|
56
|
+
Ohai::Log.debug('Erlang plugin: Could not shell_out "erl +V". Skipping data')
|
41
57
|
end
|
58
|
+
|
59
|
+
languages[:erlang] = erlang unless erlang.empty?
|
42
60
|
end
|
43
61
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Wrock (<matt@mattwrock.com>)
|
3
|
+
# Copyright:: Copyright (c) 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
|
+
# After long discussion in IRC the "powers that be" have come to a concensus
|
20
|
+
# that there is no other Windows platforms exist that were not based on the
|
21
|
+
# Windows_NT kernel, so we herby decree that "windows" will refer to all
|
22
|
+
# platforms built upon the Windows_NT kernel and have access to win32 or win64
|
23
|
+
# subsystems.
|
24
|
+
|
25
|
+
Ohai.plugin(:Fips) do
|
26
|
+
provides "fips"
|
27
|
+
|
28
|
+
collect_data(:linux) do
|
29
|
+
fips Mash.new
|
30
|
+
|
31
|
+
begin
|
32
|
+
enabled = File.read("/proc/sys/crypto/fips_enabled").chomp
|
33
|
+
fips["kernel"] = { "enabled" => enabled == "0" ? false : true }
|
34
|
+
rescue Errno::ENOENT
|
35
|
+
fips["kernel"] = { "enabled" => false }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/ohai/plugins/mono.rb
CHANGED
@@ -18,24 +18,33 @@
|
|
18
18
|
|
19
19
|
Ohai.plugin(:Mono) do
|
20
20
|
provides "languages/mono"
|
21
|
-
|
22
21
|
depends "languages"
|
23
22
|
|
24
23
|
collect_data do
|
25
|
-
output = nil
|
26
|
-
|
27
|
-
mono = Mash.new
|
28
24
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
25
|
+
begin
|
26
|
+
# Mono JIT compiler version 4.2.3 (Stable 4.2.3.4/832de4b Wed Mar 30 13:57:48 PDT 2016)
|
27
|
+
# Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
|
28
|
+
# TLS: normal
|
29
|
+
# SIGSEGV: altstack
|
30
|
+
# Notification: kqueue
|
31
|
+
# Architecture: amd64
|
32
|
+
# Disabled: none
|
33
|
+
# Misc: softdebug
|
34
|
+
# LLVM: supported, not enabled.
|
35
|
+
# GC: sgen
|
36
|
+
so = shell_out("mono -V")
|
37
|
+
if so.exitstatus == 0
|
38
|
+
mono = Mash.new
|
39
|
+
output = so.stdout.split
|
40
|
+
mono[:version] = output[4] unless output[4].nil?
|
41
|
+
if output.length >= 12
|
42
|
+
mono[:builddate] = "%s %s %s %s %s %s" % [output[7], output[8], output[9], output[10], output[11], output[12].delete!(")")]
|
43
|
+
end
|
44
|
+
languages[:mono] = mono unless mono.empty?
|
37
45
|
end
|
38
|
-
|
46
|
+
rescue Ohai::Exceptions::Exec
|
47
|
+
Ohai::Log.debug('Mono plugin: Could not shell_out "mono -V". Skipping plugin')
|
39
48
|
end
|
40
49
|
end
|
41
50
|
end
|
data/lib/ohai/plugins/scala.rb
CHANGED
@@ -20,24 +20,31 @@ Ohai.plugin(:Scala) do
|
|
20
20
|
depends "languages"
|
21
21
|
|
22
22
|
collect_data(:default) do
|
23
|
-
# Check for scala
|
24
|
-
output = nil
|
25
|
-
|
26
23
|
scala = Mash.new
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
|
25
|
+
# Check for scala
|
26
|
+
begin
|
27
|
+
# Scala code runner version 2.11.8 -- Copyright 2002-2016, LAMP/EPFL
|
28
|
+
so = shell_out("scala -version")
|
29
|
+
if so.exitstatus == 0
|
30
|
+
scala[:version] = so.stderr.split[4]
|
31
|
+
end
|
32
|
+
rescue Ohai::Exceptions::Exec
|
33
|
+
# ignore shell_out failures
|
32
34
|
end
|
33
35
|
|
34
36
|
# Check for sbt
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
begin
|
38
|
+
# sbt launcher version 0.13.7
|
39
|
+
so = shell_out("sbt --version")
|
40
|
+
if so.exitstatus == 0
|
41
|
+
scala[:sbt] = Mash.new
|
42
|
+
scala[:sbt][:version] = so.stdout.split[3]
|
43
|
+
end
|
44
|
+
rescue Ohai::Exceptions::Exec
|
45
|
+
# ignore shell_out failures
|
41
46
|
end
|
47
|
+
|
48
|
+
languages[:scala] = scala unless scala.empty?
|
42
49
|
end
|
43
50
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Wrock (<matt@mattwrock.com>)
|
3
|
+
# Copyright:: Copyright (c) 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
|
+
# After long discussion in IRC the "powers that be" have come to a concensus
|
20
|
+
# that there is no other Windows platforms exist that were not based on the
|
21
|
+
# Windows_NT kernel, so we herby decree that "windows" will refer to all
|
22
|
+
# platforms built upon the Windows_NT kernel and have access to win32 or win64
|
23
|
+
# subsystems.
|
24
|
+
|
25
|
+
Ohai.plugin(:Fips) do
|
26
|
+
provides "fips"
|
27
|
+
|
28
|
+
collect_data(:windows) do
|
29
|
+
require "win32/registry"
|
30
|
+
fips Mash.new
|
31
|
+
|
32
|
+
# from http://msdn.microsoft.com/en-us/library/windows/desktop/aa384129(v=vs.85).aspx
|
33
|
+
if ::RbConfig::CONFIG["target_cpu"] == "i386"
|
34
|
+
reg_type = Win32::Registry::KEY_READ | 0x100
|
35
|
+
elsif ::RbConfig::CONFIG["target_cpu"] == "x86_64"
|
36
|
+
reg_type = Win32::Registry::KEY_READ | 0x200
|
37
|
+
else
|
38
|
+
reg_type = Win32::Registry::KEY_READ
|
39
|
+
end
|
40
|
+
|
41
|
+
begin
|
42
|
+
Win32::Registry::HKEY_LOCAL_MACHINE.open('System\CurrentControlSet\Control\Lsa\FIPSAlgorithmPolicy', reg_type) do |policy|
|
43
|
+
enabled = policy["Enabled"]
|
44
|
+
fips["kernel"] = { "enabled" => enabled == 0 ? false : true }
|
45
|
+
end
|
46
|
+
rescue Win32::Registry::Error
|
47
|
+
fips["kernel"] = { "enabled" => false }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/ohai/version.rb
CHANGED
@@ -20,34 +20,50 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
|
|
20
20
|
require "open-uri"
|
21
21
|
|
22
22
|
describe Ohai::System, "plugin azure" do
|
23
|
-
|
24
|
-
|
23
|
+
let(:plugin) { get_plugin("azure") }
|
24
|
+
let(:hint) {
|
25
|
+
{
|
26
|
+
"public_ip" => "137.135.46.202",
|
27
|
+
"vm_name" => "test-vm",
|
28
|
+
"public_fqdn" => "service.cloudapp.net",
|
29
|
+
"public_ssh_port" => "22",
|
30
|
+
"public_winrm_port" => "5985",
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
shared_examples_for "!azure" do
|
35
|
+
it "does not set the azure attribute" do
|
36
|
+
plugin.run
|
37
|
+
expect(plugin[:azure]).to be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
shared_examples_for "azure" do
|
42
|
+
it "sets the azure attribute" do
|
43
|
+
plugin.run
|
44
|
+
expect(plugin[:azure]).to be_truthy
|
45
|
+
end
|
25
46
|
end
|
26
47
|
|
27
48
|
describe "with azure hint file" do
|
28
49
|
before(:each) do
|
29
|
-
allow(
|
30
|
-
allow(File).to receive(:read).with("/etc/chef/ohai/hints/azure.json").and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}')
|
31
|
-
allow(File).to receive(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(true)
|
32
|
-
allow(File).to receive(:read).with('C:\chef\ohai\hints/azure.json').and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}')
|
33
|
-
@plugin.run
|
50
|
+
allow(plugin).to receive(:hint?).with("azure").and_return(hint)
|
34
51
|
end
|
35
52
|
|
36
|
-
it "
|
37
|
-
|
38
|
-
expect(
|
39
|
-
expect(
|
40
|
-
expect(
|
41
|
-
expect(
|
42
|
-
expect(
|
53
|
+
it "sets the azure cloud attributes" do
|
54
|
+
plugin.run
|
55
|
+
expect(plugin[:azure]["public_ip"]).to eq("137.135.46.202")
|
56
|
+
expect(plugin[:azure]["vm_name"]).to eq("test-vm")
|
57
|
+
expect(plugin[:azure]["public_fqdn"]).to eq("service.cloudapp.net")
|
58
|
+
expect(plugin[:azure]["public_ssh_port"]).to eq("22")
|
59
|
+
expect(plugin[:azure]["public_winrm_port"]).to eq("5985")
|
43
60
|
end
|
44
61
|
|
45
62
|
end
|
46
63
|
|
47
64
|
describe "without azure hint file or agent or dhcp options" do
|
48
65
|
before(:each) do
|
49
|
-
allow(
|
50
|
-
allow(File).to receive(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false)
|
66
|
+
allow(plugin).to receive(:hint?).with("azure").and_return(false)
|
51
67
|
allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false)
|
52
68
|
allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(false)
|
53
69
|
allow(File).to receive(:exist?).with("/var/lib/dhcp/dhclient.eth0.leases").and_return(true)
|
@@ -73,66 +89,46 @@ describe Ohai::System, "plugin azure" do
|
|
73
89
|
and_yield(" expire 2 2016/03/01 16:40:56;").
|
74
90
|
and_yield("}")
|
75
91
|
allow(File).to receive(:open).with("/var/lib/dhcp/dhclient.eth0.leases").and_return(@double_file)
|
76
|
-
@plugin.run
|
77
92
|
end
|
78
93
|
|
79
|
-
|
80
|
-
expect(@plugin[:azure]).to be_nil
|
81
|
-
end
|
94
|
+
it_behaves_like "!azure"
|
82
95
|
end
|
83
96
|
|
84
|
-
describe "with rackspace hint file no agent and no dhcp lease" do
|
97
|
+
describe "with rackspace hint file, no agent, and no dhcp lease" do
|
85
98
|
before(:each) do
|
86
|
-
allow(
|
87
|
-
allow(
|
88
|
-
allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
|
89
|
-
allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return("")
|
99
|
+
allow(plugin).to receive(:hint?).with("rackspace").and_return(true)
|
100
|
+
allow(plugin).to receive(:hint?).with("azure").and_return(false)
|
90
101
|
allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false)
|
91
|
-
allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/azure.json").and_return(false)
|
92
|
-
allow(File).to receive(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false)
|
93
102
|
allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(false)
|
94
103
|
allow(File).to receive(:exist?).with("/var/lib/dhcp/dhclient.eth0.leases").and_return(false)
|
95
|
-
@plugin.run
|
96
104
|
end
|
97
105
|
|
98
|
-
|
99
|
-
expect(@plugin[:azure]).to be_nil
|
100
|
-
end
|
106
|
+
it_behaves_like "!azure"
|
101
107
|
end
|
102
108
|
|
103
109
|
describe "without azure hint file but with agent on linux" do
|
104
110
|
before(:each) do
|
105
|
-
allow(
|
106
|
-
allow(File).to receive(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false)
|
111
|
+
allow(plugin).to receive(:hint?).with("azure").and_return(false)
|
107
112
|
allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(true)
|
108
113
|
allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(false)
|
109
|
-
@plugin.run
|
110
114
|
end
|
111
115
|
|
112
|
-
|
113
|
-
expect(@plugin[:azure]).to be_empty
|
114
|
-
end
|
116
|
+
it_behaves_like "azure"
|
115
117
|
end
|
116
118
|
|
117
119
|
describe "without azure hint file but with agent on windows" do
|
118
120
|
before(:each) do
|
119
|
-
allow(
|
120
|
-
allow(File).to receive(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false)
|
121
|
+
allow(plugin).to receive(:hint?).with("azure").and_return(false)
|
121
122
|
allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false)
|
122
123
|
allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(true)
|
123
|
-
@plugin.run
|
124
124
|
end
|
125
125
|
|
126
|
-
|
127
|
-
puts "The dir exists?:" + "#{Dir.exist?('C:\WindowsAzure')}"
|
128
|
-
expect(@plugin[:azure]).to be_empty
|
129
|
-
end
|
126
|
+
it_behaves_like "azure"
|
130
127
|
end
|
131
128
|
|
132
129
|
describe "without azure hint or agent but with dhcp option" do
|
133
130
|
before(:each) do
|
134
|
-
allow(
|
135
|
-
allow(File).to receive(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false)
|
131
|
+
allow(plugin).to receive(:hint?).with("azure").and_return(false)
|
136
132
|
allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false)
|
137
133
|
allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(false)
|
138
134
|
allow(File).to receive(:exist?).with("/var/lib/dhcp/dhclient.eth0.leases").and_return(true)
|
@@ -158,13 +154,9 @@ describe Ohai::System, "plugin azure" do
|
|
158
154
|
and_yield(" expire 5 2152/03/10 09:03:39;").
|
159
155
|
and_yield("}")
|
160
156
|
allow(File).to receive(:open).with("/var/lib/dhcp/dhclient.eth0.leases").and_return(@double_file)
|
161
|
-
@plugin.run
|
162
157
|
end
|
163
158
|
|
164
|
-
|
165
|
-
puts "The dir exists?:" + "#{Dir.exist?('C:\WindowsAzure')}"
|
166
|
-
expect(@plugin[:azure]).to be_empty
|
167
|
-
end
|
159
|
+
it_behaves_like "azure"
|
168
160
|
end
|
169
161
|
|
170
162
|
end
|