ohai 14.1.3 → 14.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ohai/common/dmi.rb +9 -2
- data/lib/ohai/dsl/plugin.rb +6 -0
- data/lib/ohai/dsl/plugin/versionvii.rb +33 -0
- data/lib/ohai/hints.rb +8 -0
- data/lib/ohai/mash.rb +21 -32
- data/lib/ohai/mixin/dmi_decode.rb +2 -0
- data/lib/ohai/mixin/ec2_metadata.rb +7 -5
- data/lib/ohai/mixin/gce_metadata.rb +6 -0
- data/lib/ohai/mixin/http_helper.rb +7 -0
- data/lib/ohai/mixin/os.rb +3 -0
- data/lib/ohai/mixin/scaleway_metadata.rb +4 -0
- data/lib/ohai/mixin/seconds_to_human.rb +10 -5
- data/lib/ohai/mixin/softlayer_metadata.rb +10 -1
- data/lib/ohai/mixin/string.rb +1 -0
- data/lib/ohai/plugins/aix/filesystem.rb +1 -1
- data/lib/ohai/plugins/linux/lspci.rb +0 -1
- data/lib/ohai/plugins/openstack.rb +3 -0
- data/lib/ohai/plugins/solaris2/cpu.rb +1 -1
- data/lib/ohai/version.rb +1 -1
- data/spec/unit/plugins/aix/filesystem_spec.rb +10 -10
- data/spec/unit/plugins/openstack_spec.rb +24 -5
- data/spec/unit/system_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b945f38a205eba8ba878ca75cb0e060ce08659f75cc854fe9e430bd7ed133961
|
4
|
+
data.tar.gz: a709b76357dc0c705e4a57602be622773362890e0467ed7049985b6e83a71daa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba896baca29452e5bfe0dba1f296df3cab45bb9a22fdb68ca61617e597788f1d3ec6f8245bd8b15ab25e7cba733d1f35e90946088407885488a83ec8c45f9c24
|
7
|
+
data.tar.gz: b037ad1653096e4579e8b1ac0375d1e542fbcabee595414dabca26746bc2c75936199ef6da2ed471534934fbf24f701a788f4dae67444f62ab777fa64d9df6ae
|
data/lib/ohai/common/dmi.rb
CHANGED
@@ -76,7 +76,10 @@ module Ohai
|
|
76
76
|
# away some of the less useful IDs
|
77
77
|
ID_TO_CAPTURE = [ 0, 1, 2, 3, 4, 6, 11 ]
|
78
78
|
|
79
|
-
#
|
79
|
+
# the whitelisted DMI IDs. This is combination of the defaults + any additional
|
80
|
+
# IDs defined in the :additional_dmi_ids config
|
81
|
+
#
|
82
|
+
# @return [Array] the list of DMI IDs to capture
|
80
83
|
def whitelisted_ids
|
81
84
|
if Ohai.config[:additional_dmi_ids]
|
82
85
|
if [ Integer, Array ].include?(Ohai.config[:additional_dmi_ids].class)
|
@@ -88,7 +91,11 @@ module Ohai
|
|
88
91
|
ID_TO_CAPTURE
|
89
92
|
end
|
90
93
|
|
91
|
-
#
|
94
|
+
# the human readable description from a DMI ID
|
95
|
+
#
|
96
|
+
# @param id [String, Integer] the ID to lookup
|
97
|
+
#
|
98
|
+
# @return [String]
|
92
99
|
def id_lookup(id)
|
93
100
|
id = id.to_i
|
94
101
|
if (id >= 128) && (id <= 255)
|
data/lib/ohai/dsl/plugin.rb
CHANGED
@@ -28,10 +28,16 @@ module Ohai
|
|
28
28
|
|
29
29
|
# For plugin namespacing
|
30
30
|
module NamedPlugin
|
31
|
+
|
32
|
+
# Is the plugin a Symbol starting with a capital letter that has no underscores
|
33
|
+
#
|
34
|
+
# @param name [String] the plugin name
|
35
|
+
# @return [Boolean]
|
31
36
|
def self.valid_name?(name)
|
32
37
|
name.is_a?(Symbol) && name.to_s.match(/^[^A-Z]|_/).nil?
|
33
38
|
end
|
34
39
|
|
40
|
+
# @return [Boolean]
|
35
41
|
def self.strict_const_defined?(const)
|
36
42
|
const_defined?(const, false)
|
37
43
|
end
|
@@ -20,6 +20,8 @@
|
|
20
20
|
module Ohai
|
21
21
|
module DSL
|
22
22
|
class Plugin
|
23
|
+
# The class for the "Version 7" plugin format we introduced in Ohai 7. This is the 2nd
|
24
|
+
# generation of Ohai plugin and the previous generation (V6) was removed in Ohai 14
|
23
25
|
class VersionVII < Plugin
|
24
26
|
attr_reader :version
|
25
27
|
attr_reader :source
|
@@ -30,14 +32,23 @@ module Ohai
|
|
30
32
|
@version = :version7
|
31
33
|
end
|
32
34
|
|
35
|
+
# the plugin name we use through Ohai (Foo) vs. the class name (Ohai::NamedPlugin::Foo)
|
36
|
+
#
|
37
|
+
# @return [String]
|
33
38
|
def name
|
34
39
|
self.class.name.split("Ohai::NamedPlugin::")[1].to_sym
|
35
40
|
end
|
36
41
|
|
42
|
+
# return that we're a v7 plugin
|
43
|
+
#
|
44
|
+
# @return [Symbol]
|
37
45
|
def self.version
|
38
46
|
:version7
|
39
47
|
end
|
40
48
|
|
49
|
+
# the source of the plugin on disk. This is an array since a plugin may exist for multiple platforms and this would include each of those platform specific file paths
|
50
|
+
#
|
51
|
+
# @return [Array]
|
41
52
|
def self.sources
|
42
53
|
@source_list ||= []
|
43
54
|
end
|
@@ -50,30 +61,51 @@ module Ohai
|
|
50
61
|
@depends_attrs ||= []
|
51
62
|
end
|
52
63
|
|
64
|
+
# A block per platform for actually performing data collection constructed
|
65
|
+
# by the collect_data method
|
66
|
+
#
|
67
|
+
# @return [Mash]
|
53
68
|
def self.data_collector
|
54
69
|
@data_collector ||= Mash.new
|
55
70
|
end
|
56
71
|
|
72
|
+
# set the attributes provided by the plugin
|
73
|
+
#
|
74
|
+
# @param attrs [Array]
|
57
75
|
def self.provides(*attrs)
|
58
76
|
attrs.each do |attr|
|
59
77
|
provides_attrs << attr unless provides_attrs.include?(attr)
|
60
78
|
end
|
61
79
|
end
|
62
80
|
|
81
|
+
# set the attributes depended on by the plugin
|
82
|
+
#
|
83
|
+
# @param attrs [Array]
|
63
84
|
def self.depends(*attrs)
|
64
85
|
attrs.each do |attr|
|
65
86
|
depends_attrs << attr unless depends_attrs.include?(attr)
|
66
87
|
end
|
67
88
|
end
|
68
89
|
|
90
|
+
# set the plugin optional state
|
91
|
+
#
|
92
|
+
# @param opt [Boolean]
|
69
93
|
def self.optional(opt = true)
|
70
94
|
@optional = opt
|
71
95
|
end
|
72
96
|
|
97
|
+
# check if the plugin is optional
|
98
|
+
#
|
99
|
+
# @return [Boolean]
|
73
100
|
def self.optional?
|
74
101
|
!!@optional
|
75
102
|
end
|
76
103
|
|
104
|
+
# define data collection methodology per platform
|
105
|
+
#
|
106
|
+
# @param platform [Symbol] the platform to collect data for
|
107
|
+
# @param other_platforms [Array] additional platforms to collect data for
|
108
|
+
# @param block [block] the actual code to collect data for the specified platforms
|
77
109
|
def self.collect_data(platform = :default, *other_platforms, &block)
|
78
110
|
[platform, other_platforms].flatten.each do |plat|
|
79
111
|
if data_collector.has_key?(plat)
|
@@ -84,6 +116,7 @@ module Ohai
|
|
84
116
|
end
|
85
117
|
end
|
86
118
|
|
119
|
+
# @return [Array]
|
87
120
|
def dependencies
|
88
121
|
self.class.depends_attrs
|
89
122
|
end
|
data/lib/ohai/hints.rb
CHANGED
@@ -21,10 +21,14 @@ require "ffi_yajl"
|
|
21
21
|
|
22
22
|
module Ohai
|
23
23
|
module Hints
|
24
|
+
# clear out any known hints in the @hints variable
|
24
25
|
def self.refresh_hints
|
25
26
|
@hints = {}
|
26
27
|
end
|
27
28
|
|
29
|
+
# parse the JSON conents of a hint file. Return an empty hash if the file has
|
30
|
+
# no JSON content
|
31
|
+
# @param filename [String] the hint file path
|
28
32
|
def self.parse_hint_file(filename)
|
29
33
|
json_parser = FFI_Yajl::Parser.new
|
30
34
|
hash = json_parser.parse(File.read(filename))
|
@@ -35,6 +39,10 @@ module Ohai
|
|
35
39
|
Ohai::Log.error("Could not parse hint file at #{filename}: #{e.message}")
|
36
40
|
end
|
37
41
|
|
42
|
+
# retrieve hint contents given a hint name. Looks up in @hints variable first. Attempts
|
43
|
+
# to load from file in config's :hints_path if not already cached. Saves the contents
|
44
|
+
# to the hash if the file was successfully parsed
|
45
|
+
# @param name [String] the name of the hint (not the path)
|
38
46
|
def self.hint?(name)
|
39
47
|
@hints ||= {}
|
40
48
|
return @hints[name] if @hints[name]
|
data/lib/ohai/mash.rb
CHANGED
@@ -50,12 +50,9 @@
|
|
50
50
|
# params[:key] instead of params['key'].
|
51
51
|
class Mash < Hash
|
52
52
|
|
53
|
-
# @param constructor
|
54
|
-
#
|
55
|
-
#
|
56
|
-
# @details [Alternatives]
|
57
|
-
# If constructor is a Hash, a new mash will be created based on the keys of
|
58
|
-
# the hash and no default value will be set.
|
53
|
+
# @param constructor [Object] The default value for the mash.
|
54
|
+
# If constructor is a Hash, a new mash will be created based on the keys of the hash and
|
55
|
+
# no default value will be set.
|
59
56
|
def initialize(constructor = {})
|
60
57
|
if constructor.is_a?(Hash)
|
61
58
|
super()
|
@@ -65,11 +62,9 @@ class Mash < Hash
|
|
65
62
|
end
|
66
63
|
end
|
67
64
|
|
68
|
-
# @param key
|
69
|
-
#
|
70
|
-
#
|
71
|
-
# If key is a Symbol and it is a key in the mash, then the default value will
|
72
|
-
# be set to the value matching the key.
|
65
|
+
# @param key [Object] The default value for the mash.
|
66
|
+
# If key is a Symbol and it is a key in the mash, then the default value will be set to
|
67
|
+
# the value matching the key.
|
73
68
|
def default(key = nil)
|
74
69
|
if key.is_a?(Symbol) && include?(key = key.to_s)
|
75
70
|
self[key]
|
@@ -81,9 +76,8 @@ class Mash < Hash
|
|
81
76
|
alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
|
82
77
|
alias_method :regular_update, :update unless method_defined?(:regular_update)
|
83
78
|
|
84
|
-
# @param key
|
85
|
-
# @param value
|
86
|
-
# The value to set the key to.
|
79
|
+
# @param key [Object] The key to set.
|
80
|
+
# @param value [Object] The value to set the key to.
|
87
81
|
#
|
88
82
|
# @see Mash#convert_key
|
89
83
|
# @see Mash#convert_value
|
@@ -91,7 +85,7 @@ class Mash < Hash
|
|
91
85
|
regular_writer(convert_key(key), convert_value(value))
|
92
86
|
end
|
93
87
|
|
94
|
-
# @param other_hash
|
88
|
+
# @param other_hash [Hash]
|
95
89
|
# A hash to update values in the mash with. The keys and the values will be
|
96
90
|
# converted to Mash format.
|
97
91
|
#
|
@@ -103,7 +97,7 @@ class Mash < Hash
|
|
103
97
|
|
104
98
|
alias_method :merge!, :update
|
105
99
|
|
106
|
-
# @param key
|
100
|
+
# @param key [Object] The key to check for. This will be run through convert_key.
|
107
101
|
#
|
108
102
|
# @return [Boolean] True if the key exists in the mash.
|
109
103
|
def key?(key)
|
@@ -115,36 +109,34 @@ class Mash < Hash
|
|
115
109
|
alias_method :has_key?, :key?
|
116
110
|
alias_method :member?, :key?
|
117
111
|
|
118
|
-
# @param key
|
119
|
-
# @param
|
112
|
+
# @param key [Object] The key to fetch. This will be run through convert_key.
|
113
|
+
# @param extras [Array] Default value.
|
120
114
|
#
|
121
115
|
# @return [Object] The value at key or the default value.
|
122
116
|
def fetch(key, *extras)
|
123
117
|
super(convert_key(key), *extras)
|
124
118
|
end
|
125
119
|
|
126
|
-
# @param
|
127
|
-
# The keys to retrieve values for. These will be run through +convert_key+.
|
120
|
+
# @param indices [Array] The keys to retrieve values for. These will be run through +convert_key+.
|
128
121
|
#
|
129
122
|
# @return [Array] The values at each of the provided keys
|
130
123
|
def values_at(*indices)
|
131
124
|
indices.collect { |key| self[convert_key(key)] }
|
132
125
|
end
|
133
126
|
|
134
|
-
# @param hash
|
127
|
+
# @param hash [Hash] The hash to merge with the mash.
|
135
128
|
#
|
136
129
|
# @return [Mash] A new mash with the hash values merged in.
|
137
130
|
def merge(hash)
|
138
131
|
dup.update(hash)
|
139
132
|
end
|
140
133
|
|
141
|
-
# @param key
|
142
|
-
# The key to delete from the mash.\
|
134
|
+
# @param key [Object] The key to delete from the mash.
|
143
135
|
def delete(key)
|
144
136
|
super(convert_key(key))
|
145
137
|
end
|
146
138
|
|
147
|
-
# @param
|
139
|
+
# @param keys [Array<String, Symbol>] The mash keys to exclude.
|
148
140
|
#
|
149
141
|
# @return [Mash] A new mash without the selected keys.
|
150
142
|
#
|
@@ -172,8 +164,8 @@ class Mash < Hash
|
|
172
164
|
Hash.new(default).merge(self)
|
173
165
|
end
|
174
166
|
|
175
|
-
#
|
176
|
-
#
|
167
|
+
# Convert a Hash into a Mash. The input Hash's default value is maintained
|
168
|
+
# @return [Mash]
|
177
169
|
def self.from_hash(hash)
|
178
170
|
mash = Mash.new(hash)
|
179
171
|
mash.default = hash.default
|
@@ -182,18 +174,15 @@ class Mash < Hash
|
|
182
174
|
|
183
175
|
protected
|
184
176
|
|
185
|
-
# @param key
|
186
|
-
#
|
187
|
-
# @param [Object]
|
188
|
-
# The converted key. If the key was a symbol, it will be converted to a
|
189
|
-
# string.
|
177
|
+
# @param key [Object] The key to convert.
|
178
|
+
# @return [Object] The converted key. If the key was a symbol, it will be converted to a string.
|
190
179
|
#
|
191
180
|
# @api private
|
192
181
|
def convert_key(key)
|
193
182
|
key.kind_of?(Symbol) ? key.to_s : key
|
194
183
|
end
|
195
184
|
|
196
|
-
# @param value
|
185
|
+
# @param value [Object] The value to convert.
|
197
186
|
#
|
198
187
|
# @return [Object]
|
199
188
|
# The converted value. A Hash or an Array of hashes, will be converted to
|
@@ -72,6 +72,9 @@ module Ohai
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
# a net/http client with a timeout of 10s and a keepalive of 10s
|
76
|
+
#
|
77
|
+
# @return [Net::HTTP]
|
75
78
|
def http_client
|
76
79
|
@conn ||= Net::HTTP.start(EC2_METADATA_ADDR).tap do |h|
|
77
80
|
h.read_timeout = 10
|
@@ -81,11 +84,10 @@ module Ohai
|
|
81
84
|
|
82
85
|
# Get metadata for a given path and API version
|
83
86
|
#
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
# `nil` and continue the run instead of failing it.
|
87
|
+
# Typically, a 200 response is expected for valid metadata.
|
88
|
+
# On certain instance types, traversing the provided metadata path
|
89
|
+
# produces a 404 for some unknown reason. In that event, return
|
90
|
+
# `nil` and continue the run instead of failing it.
|
89
91
|
def metadata_get(id, api_version)
|
90
92
|
path = "/#{api_version}/meta-data/#{id}"
|
91
93
|
logger.trace("Mixin EC2: Fetching http://#{EC2_METADATA_ADDR}#{path}")
|
@@ -50,6 +50,9 @@ module Ohai
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
# @param [String] data that might be JSON
|
54
|
+
#
|
55
|
+
# @return [Boolean] is the data JSON or not?
|
53
56
|
def json?(data)
|
54
57
|
data = StringIO.new(data)
|
55
58
|
parser = FFI_Yajl::Parser.new
|
@@ -61,6 +64,9 @@ module Ohai
|
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
67
|
+
# @param data [String]
|
68
|
+
#
|
69
|
+
# @return [Boolean] is there a trailing /?
|
64
70
|
def has_trailing_slash?(data)
|
65
71
|
!! ( data =~ %r{/$} )
|
66
72
|
end
|
@@ -20,6 +20,13 @@ module Ohai
|
|
20
20
|
module Mixin
|
21
21
|
module HttpHelper
|
22
22
|
|
23
|
+
# see if we can socket connect to an address/port
|
24
|
+
#
|
25
|
+
# @param addr [String] the address to connect to
|
26
|
+
# @param port [Integer] the port to connect to
|
27
|
+
# @param timeout [Integer] the seconds before timing out
|
28
|
+
#
|
29
|
+
# @return [Boolean] can we connect?
|
23
30
|
def can_socket_connect?(addr, port, timeout = 2)
|
24
31
|
t = Socket.new(Socket::Constants::AF_INET, Socket::Constants::SOCK_STREAM, 0)
|
25
32
|
begin
|
data/lib/ohai/mixin/os.rb
CHANGED
@@ -23,10 +23,14 @@ module Ohai
|
|
23
23
|
SCALEWAY_METADATA_ADDR = "169.254.42.42" unless defined?(SCALEWAY_METADATA_ADDR)
|
24
24
|
SCALEWAY_METADATA_URL = "/conf?format=json" unless defined?(SCALEWAY_METADATA_URL)
|
25
25
|
|
26
|
+
# @return [Net::HTTP] net/http object without timeout set to 6
|
26
27
|
def http_client
|
27
28
|
Net::HTTP.start(SCALEWAY_METADATA_ADDR).tap { |h| h.read_timeout = 6 }
|
28
29
|
end
|
29
30
|
|
31
|
+
# fetch scaleway metadata and parse the resulting JSON
|
32
|
+
#
|
33
|
+
# @return [Hash]
|
30
34
|
def fetch_metadata
|
31
35
|
uri = "#{SCALEWAY_METADATA_URL}"
|
32
36
|
response = http_client.get(uri)
|
@@ -19,6 +19,11 @@
|
|
19
19
|
module Ohai
|
20
20
|
module Mixin
|
21
21
|
module SecondsToHuman
|
22
|
+
# given the number of seconds return a day/hours/minutes/seconds human form
|
23
|
+
#
|
24
|
+
# @param seconds [Integer]
|
25
|
+
#
|
26
|
+
# @return String
|
22
27
|
def seconds_to_human(seconds)
|
23
28
|
days = seconds.to_i / 86400
|
24
29
|
seconds -= 86400 * days
|
@@ -30,15 +35,15 @@ module Ohai
|
|
30
35
|
seconds -= 60 * minutes
|
31
36
|
|
32
37
|
if days > 1
|
33
|
-
|
38
|
+
sprintf("%d days %02d hours %02d minutes %02d seconds", days, hours, minutes, seconds)
|
34
39
|
elsif days == 1
|
35
|
-
|
40
|
+
sprintf("%d day %02d hours %02d minutes %02d seconds", days, hours, minutes, seconds)
|
36
41
|
elsif hours > 0
|
37
|
-
|
42
|
+
sprintf("%d hours %02d minutes %02d seconds", hours, minutes, seconds)
|
38
43
|
elsif minutes > 0
|
39
|
-
|
44
|
+
sprintf("%d minutes %02d seconds", minutes, seconds)
|
40
45
|
else
|
41
|
-
|
46
|
+
sprintf("%02d seconds", seconds)
|
42
47
|
end
|
43
48
|
end
|
44
49
|
end
|
@@ -20,10 +20,13 @@
|
|
20
20
|
require "net/https"
|
21
21
|
require "uri"
|
22
22
|
|
23
|
-
#
|
23
|
+
# https://softlayer.github.io/reference/services/SoftLayer_Resource_Metadata/
|
24
24
|
module ::Ohai::Mixin::SoftlayerMetadata
|
25
25
|
SOFTLAYER_API_QUERY_URL = "https://api.service.softlayer.com/rest/v3.1/SoftLayer_Resource_Metadata" unless defined?(SOFTLAYER_API_QUERY_URL)
|
26
26
|
|
27
|
+
# fetch metadata items and build out hash of data
|
28
|
+
#
|
29
|
+
# @return [Hash]
|
27
30
|
def fetch_metadata
|
28
31
|
{
|
29
32
|
"public_fqdn" => fetch_metadata_item("getFullyQualifiedDomainName.txt"),
|
@@ -39,10 +42,16 @@ module ::Ohai::Mixin::SoftlayerMetadata
|
|
39
42
|
# however Chef-omnibus should set SSL_CERT_FILE to point to a valid file.
|
40
43
|
# Manually supply and specify a suitable CA bundle here or
|
41
44
|
# set the SSL_CERT_FILE file environment variable to a valid value otherwise.
|
45
|
+
#
|
46
|
+
# @return [String]
|
42
47
|
def ca_file_location
|
43
48
|
::Ohai::Config[:ca_file]
|
44
49
|
end
|
45
50
|
|
51
|
+
# fetch a specified item from the Softlayer metadata API
|
52
|
+
# @param item [String] the metadata item to fetch
|
53
|
+
#
|
54
|
+
# @return [String] the response body
|
46
55
|
def fetch_metadata_item(item)
|
47
56
|
full_url = "#{SOFTLAYER_API_QUERY_URL}/#{item}"
|
48
57
|
u = URI(full_url)
|
data/lib/ohai/mixin/string.rb
CHANGED
@@ -22,6 +22,7 @@ class String
|
|
22
22
|
# underscore will also change ’::’ to ’/’ to convert namespaces to paths.
|
23
23
|
# This should implement the same functionality as underscore method in
|
24
24
|
# ActiveSupport::CoreExtensions::String::Inflections
|
25
|
+
# @return [String]
|
25
26
|
def wmi_underscore
|
26
27
|
gsub(/::/, "/").gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
27
28
|
gsub(/([a-z\d])([A-Z])/, '\1_\2').tr("-", "_").downcase
|
@@ -59,7 +59,7 @@ Ohai.plugin(:Filesystem) do
|
|
59
59
|
else
|
60
60
|
key = fields[0] + ":" + fields[1]
|
61
61
|
oldie[key] ||= Mash.new
|
62
|
-
oldie[key][:mount] = fields[
|
62
|
+
oldie[key][:mount] = fields[2]
|
63
63
|
oldie[key][:fs_type] = fields[3]
|
64
64
|
oldie[key][:mount_options] = fields[7].split(",")
|
65
65
|
end
|
@@ -32,6 +32,9 @@ Ohai.plugin(:Openstack) do
|
|
32
32
|
if get_attribute(:dmi, :system, :all_records, 0, :Manufacturer) =~ /OpenStack/
|
33
33
|
logger.trace("Plugin Openstack: has_openstack_dmi? == true")
|
34
34
|
true
|
35
|
+
elsif get_attribute(:dmi, :system, :product_name) == "OpenStack Compute"
|
36
|
+
logger.trace("Plugin Openstack: has_openstack_dmi? == true")
|
37
|
+
true
|
35
38
|
else
|
36
39
|
logger.trace("Plugin Openstack: has_openstack_dmi? == false")
|
37
40
|
false
|
@@ -30,7 +30,7 @@ Ohai.plugin(:CPU) do
|
|
30
30
|
currentcpu = 0
|
31
31
|
cpucores = Array.new
|
32
32
|
cpusockets = Array.new
|
33
|
-
processor_info.
|
33
|
+
processor_info.each do |processor|
|
34
34
|
_desc, instance, _record, keyvalue = processor.split(":")
|
35
35
|
cpu[instance] ||= Mash.new
|
36
36
|
if currentcpu != instance
|
data/lib/ohai/version.rb
CHANGED
@@ -69,7 +69,7 @@ DF_PK
|
|
69
69
|
/dev/hd11admin /admin jfs2 Jul 17 13:22 rw,log=/dev/hd8
|
70
70
|
/proc /proc procfs Jul 17 13:22 rw
|
71
71
|
/dev/hd10opt /opt jfs2 Jul 17 13:22 rw,log=/dev/hd8
|
72
|
-
192.168.1.11 /stage/
|
72
|
+
192.168.1.11 /stage/middleware1 /stage/middleware2 nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
|
73
73
|
MOUNT
|
74
74
|
|
75
75
|
@mount_wpar = <<-MOUNT
|
@@ -82,7 +82,7 @@ MOUNT
|
|
82
82
|
Global /tmp jfs2 Nov 23 21:03 rw,log=NULL
|
83
83
|
Global /usr jfs2 Nov 23 21:03 rw,log=NULL
|
84
84
|
Global /var jfs2 Nov 23 21:03 rw,log=NULL
|
85
|
-
192.168.1.11 /stage/
|
85
|
+
192.168.1.11 /stage/middleware3 /stage/middleware4 nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
|
86
86
|
MOUNT
|
87
87
|
|
88
88
|
@plugin = get_plugin("aix/filesystem")
|
@@ -134,19 +134,19 @@ MOUNT
|
|
134
134
|
expect(@plugin[:filesystem]["/dev/hd4"]["mount_options"]).to eq(["rw", "log=/dev/hd8"])
|
135
135
|
end
|
136
136
|
|
137
|
-
# For entries like 192.168.1.11 /stage/
|
137
|
+
# For entries like 192.168.1.11 /stage/middleware1 /stage/middleware2 nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
|
138
138
|
context "having node values" do
|
139
139
|
|
140
140
|
it "returns the filesystem mount location" do
|
141
|
-
expect(@plugin[:filesystem]["192.168.1.11:/stage/
|
141
|
+
expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware1"]["mount"]).to eq("/stage/middleware2")
|
142
142
|
end
|
143
143
|
|
144
144
|
it "returns the filesystem type" do
|
145
|
-
expect(@plugin[:filesystem]["192.168.1.11:/stage/
|
145
|
+
expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware1"]["fs_type"]).to eq("nfs3")
|
146
146
|
end
|
147
147
|
|
148
148
|
it "returns the filesystem mount options" do
|
149
|
-
expect(@plugin[:filesystem]["192.168.1.11:/stage/
|
149
|
+
expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware1"]["mount_options"]).to eq(["ro", "bg", "hard", "intr", "sec=sys"])
|
150
150
|
end
|
151
151
|
end
|
152
152
|
end
|
@@ -196,19 +196,19 @@ MOUNT
|
|
196
196
|
expect(@plugin[:filesystem]["Global:/"]["mount_options"]).to eq(["rw", "log=NULL"])
|
197
197
|
end
|
198
198
|
|
199
|
-
# For entries like 192.168.1.11 /stage/
|
199
|
+
# For entries like 192.168.1.11 /stage/middleware3 /stage/middleware4 nfs3 Jul 17 13:24 ro,bg,hard,intr,sec=sys
|
200
200
|
context "having node values" do
|
201
201
|
|
202
202
|
it "returns the filesystem mount location" do
|
203
|
-
expect(@plugin[:filesystem]["192.168.1.11:/stage/
|
203
|
+
expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware3"]["mount"]).to eq("/stage/middleware4")
|
204
204
|
end
|
205
205
|
|
206
206
|
it "returns the filesystem type" do
|
207
|
-
expect(@plugin[:filesystem]["192.168.1.11:/stage/
|
207
|
+
expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware3"]["fs_type"]).to eq("nfs3")
|
208
208
|
end
|
209
209
|
|
210
210
|
it "returns the filesystem mount options" do
|
211
|
-
expect(@plugin[:filesystem]["192.168.1.11:/stage/
|
211
|
+
expect(@plugin[:filesystem]["192.168.1.11:/stage/middleware3"]["mount_options"]).to eq(["ro", "bg", "hard", "intr", "sec=sys"])
|
212
212
|
end
|
213
213
|
end
|
214
214
|
end
|
@@ -40,16 +40,35 @@ describe Ohai::System, "plugin openstack" do
|
|
40
40
|
allow(plugin).to receive(:can_socket_connect?).
|
41
41
|
with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80).
|
42
42
|
and_return(false)
|
43
|
-
plugin[:dmi] =
|
43
|
+
plugin[:dmi] = dmi_data
|
44
44
|
plugin.run
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
context "with normal openstack metadata" do
|
48
|
+
let(:dmi_data) do
|
49
|
+
{ :system => { :all_records => [ { :Manufacturer => "OpenStack Foundation" } ] } }
|
50
|
+
end
|
51
|
+
|
52
|
+
it "sets openstack attribute" do
|
53
|
+
expect(plugin[:openstack][:provider]).to eq("openstack")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "doesn't set metadata attributes" do
|
57
|
+
expect(plugin[:openstack][:instance_id]).to be_nil
|
58
|
+
end
|
49
59
|
end
|
60
|
+
context "with Red Hat openstack metadata" do
|
61
|
+
let(:dmi_data) do
|
62
|
+
{ :system => { :manufacturer => "Red Hat", :product_name => "OpenStack Compute" } }
|
63
|
+
end
|
50
64
|
|
51
|
-
|
52
|
-
|
65
|
+
it "sets openstack attribute" do
|
66
|
+
expect(plugin[:openstack][:provider]).to eq("openstack")
|
67
|
+
end
|
68
|
+
|
69
|
+
it "doesn't set metadata attributes" do
|
70
|
+
expect(plugin[:openstack][:instance_id]).to be_nil
|
71
|
+
end
|
53
72
|
end
|
54
73
|
end
|
55
74
|
end
|
data/spec/unit/system_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 14.
|
4
|
+
version: 14.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: systemu
|