ohai 18.1.3 → 19.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +28 -28
- data/LICENSE +201 -201
- data/bin/ohai +25 -25
- data/lib/ohai/application.rb +189 -189
- data/lib/ohai/common/dmi.rb +167 -167
- data/lib/ohai/config.rb +51 -51
- data/lib/ohai/dsl/plugin/versionvii.rb +203 -203
- data/lib/ohai/dsl/plugin.rb +232 -232
- data/lib/ohai/dsl.rb +22 -22
- data/lib/ohai/exception.rb +36 -36
- data/lib/ohai/hints.rb +68 -68
- data/lib/ohai/loader.rb +178 -178
- data/lib/ohai/log.rb +34 -34
- data/lib/ohai/mash.rb +22 -22
- data/lib/ohai/mixin/alibaba_metadata.rb +83 -73
- data/lib/ohai/mixin/azure_metadata.rb +105 -104
- data/lib/ohai/mixin/chef_utils_wiring.rb +52 -52
- data/lib/ohai/mixin/command.rb +4 -4
- data/lib/ohai/mixin/constant_helper.rb +55 -55
- data/lib/ohai/mixin/dmi_decode.rb +54 -54
- data/lib/ohai/mixin/do_metadata.rb +48 -48
- data/lib/ohai/mixin/ec2_metadata.rb +264 -264
- data/lib/ohai/mixin/gce_metadata.rb +79 -77
- data/lib/ohai/mixin/http_helper.rb +64 -64
- data/lib/ohai/mixin/json_helper.rb +36 -36
- data/lib/ohai/mixin/network_helper.rb +92 -65
- data/lib/ohai/mixin/oci_metadata.rb +60 -60
- data/lib/ohai/mixin/os.rb +128 -128
- data/lib/ohai/mixin/scaleway_metadata.rb +51 -51
- data/lib/ohai/mixin/seconds_to_human.rb +52 -52
- data/lib/ohai/mixin/shell_out.rb +51 -51
- data/lib/ohai/mixin/softlayer_metadata.rb +74 -74
- data/lib/ohai/mixin/string.rb +31 -31
- data/lib/ohai/mixin/train_helpers.rb +36 -36
- data/lib/ohai/mixin/which.rb +39 -39
- data/lib/ohai/plugin_config.rb +47 -47
- data/lib/ohai/plugins/aix/kernel.rb +50 -50
- data/lib/ohai/plugins/aix/memory.rb +37 -37
- data/lib/ohai/plugins/aix/network.rb +142 -142
- data/lib/ohai/plugins/aix/platform.rb +30 -30
- data/lib/ohai/plugins/aix/uptime.rb +54 -54
- data/lib/ohai/plugins/aix/virtualization.rb +154 -154
- data/lib/ohai/plugins/alibaba.rb +72 -72
- data/lib/ohai/plugins/azure.rb +154 -154
- data/lib/ohai/plugins/bsd/virtualization.rb +121 -121
- data/lib/ohai/plugins/c.rb +178 -178
- data/lib/ohai/plugins/chef.rb +50 -50
- data/lib/ohai/plugins/cloud.rb +379 -379
- data/lib/ohai/plugins/command.rb +26 -26
- data/lib/ohai/plugins/cpu.rb +642 -635
- data/lib/ohai/plugins/darwin/hardware.rb +99 -99
- data/lib/ohai/plugins/darwin/memory.rb +62 -62
- data/lib/ohai/plugins/darwin/network.rb +207 -207
- data/lib/ohai/plugins/darwin/platform.rb +40 -38
- data/lib/ohai/plugins/darwin/virtualization.rb +104 -90
- data/lib/ohai/plugins/digital_ocean.rb +67 -67
- data/lib/ohai/plugins/dmi.rb +134 -134
- data/lib/ohai/plugins/docker.rb +58 -58
- data/lib/ohai/plugins/dragonflybsd/memory.rb +60 -60
- data/lib/ohai/plugins/dragonflybsd/network.rb +128 -128
- data/lib/ohai/plugins/dragonflybsd/platform.rb +28 -28
- data/lib/ohai/plugins/ec2.rb +148 -148
- data/lib/ohai/plugins/elixir.rb +36 -36
- data/lib/ohai/plugins/erlang.rb +60 -60
- data/lib/ohai/plugins/eucalyptus.rb +86 -86
- data/lib/ohai/plugins/filesystem.rb +753 -751
- data/lib/ohai/plugins/fips.rb +36 -36
- data/lib/ohai/plugins/freebsd/memory.rb +60 -60
- data/lib/ohai/plugins/freebsd/network.rb +128 -128
- data/lib/ohai/plugins/freebsd/platform.rb +28 -28
- data/lib/ohai/plugins/gce.rb +89 -89
- data/lib/ohai/plugins/go.rb +34 -34
- data/lib/ohai/plugins/groovy.rb +38 -38
- data/lib/ohai/plugins/grub2.rb +40 -40
- data/lib/ohai/plugins/habitat.rb +73 -73
- data/lib/ohai/plugins/haskell.rb +96 -96
- data/lib/ohai/plugins/hostname.rb +133 -133
- data/lib/ohai/plugins/init_package.rb +26 -26
- data/lib/ohai/plugins/java.rb +78 -78
- data/lib/ohai/plugins/kernel.rb +292 -292
- data/lib/ohai/plugins/keys.rb +27 -27
- data/lib/ohai/plugins/languages.rb +26 -26
- data/lib/ohai/plugins/libvirt.rb +114 -114
- data/lib/ohai/plugins/linode.rb +73 -73
- data/lib/ohai/plugins/linux/block_device.rb +48 -48
- data/lib/ohai/plugins/linux/hostnamectl.rb +34 -34
- data/lib/ohai/plugins/linux/interrupts.rb +84 -84
- data/lib/ohai/plugins/linux/ipc.rb +52 -52
- data/lib/ohai/plugins/linux/livepatch.rb +38 -38
- data/lib/ohai/plugins/linux/lsb.rb +46 -46
- data/lib/ohai/plugins/linux/lspci.rb +80 -76
- data/lib/ohai/plugins/linux/machineid.rb +36 -36
- data/lib/ohai/plugins/linux/mdadm.rb +120 -120
- data/lib/ohai/plugins/linux/memory.rb +106 -106
- data/lib/ohai/plugins/linux/network.rb +879 -879
- data/lib/ohai/plugins/linux/os_release.rb +38 -38
- data/lib/ohai/plugins/linux/platform.rb +314 -314
- data/lib/ohai/plugins/linux/selinux.rb +69 -69
- data/lib/ohai/plugins/linux/sessions.rb +54 -54
- data/lib/ohai/plugins/linux/sysctl.rb +39 -39
- data/lib/ohai/plugins/linux/systemd_paths.rb +36 -36
- data/lib/ohai/plugins/linux/tc.rb +61 -61
- data/lib/ohai/plugins/linux/virtualization.rb +300 -300
- data/lib/ohai/plugins/lua.rb +39 -39
- data/lib/ohai/plugins/mono.rb +50 -50
- data/lib/ohai/plugins/netbsd/memory.rb +99 -99
- data/lib/ohai/plugins/netbsd/network.rb +122 -122
- data/lib/ohai/plugins/netbsd/platform.rb +28 -28
- data/lib/ohai/plugins/network.rb +186 -186
- data/lib/ohai/plugins/nodejs.rb +40 -40
- data/lib/ohai/plugins/oci.rb +94 -94
- data/lib/ohai/plugins/ohai.rb +29 -29
- data/lib/ohai/plugins/ohai_time.rb +26 -26
- data/lib/ohai/plugins/openbsd/memory.rb +99 -99
- data/lib/ohai/plugins/openbsd/network.rb +122 -122
- data/lib/ohai/plugins/openbsd/platform.rb +28 -28
- data/lib/ohai/plugins/openstack.rb +84 -84
- data/lib/ohai/plugins/os.rb +55 -55
- data/lib/ohai/plugins/packages.rb +234 -234
- data/lib/ohai/plugins/passwd.rb +104 -104
- data/lib/ohai/plugins/perl.rb +45 -45
- data/lib/ohai/plugins/php.rb +52 -52
- data/lib/ohai/plugins/platform.rb +41 -29
- data/lib/ohai/plugins/powershell.rb +82 -82
- data/lib/ohai/plugins/ps.rb +35 -35
- data/lib/ohai/plugins/python.rb +43 -43
- data/lib/ohai/plugins/rackspace.rb +177 -177
- data/lib/ohai/plugins/root_group.rb +41 -41
- data/lib/ohai/plugins/rpm.rb +121 -121
- data/lib/ohai/plugins/ruby.rb +66 -66
- data/lib/ohai/plugins/rust.rb +34 -34
- data/lib/ohai/plugins/scala.rb +38 -38
- data/lib/ohai/plugins/scaleway.rb +58 -58
- data/lib/ohai/plugins/scsi.rb +52 -52
- data/lib/ohai/plugins/shard.rb +142 -142
- data/lib/ohai/plugins/shells.rb +32 -32
- data/lib/ohai/plugins/softlayer.rb +48 -48
- data/lib/ohai/plugins/solaris2/dmi.rb +191 -191
- data/lib/ohai/plugins/solaris2/memory.rb +32 -32
- data/lib/ohai/plugins/solaris2/network.rb +192 -192
- data/lib/ohai/plugins/solaris2/platform.rb +58 -58
- data/lib/ohai/plugins/solaris2/virtualization.rb +90 -90
- data/lib/ohai/plugins/ssh_host_key.rb +84 -84
- data/lib/ohai/plugins/sysconf.rb +46 -46
- data/lib/ohai/plugins/timezone.rb +45 -45
- data/lib/ohai/plugins/train.rb +35 -35
- data/lib/ohai/plugins/uptime.rb +95 -95
- data/lib/ohai/plugins/virtualbox.rb +197 -197
- data/lib/ohai/plugins/vmware.rb +109 -109
- data/lib/ohai/plugins/windows/dmi.rb +95 -95
- data/lib/ohai/plugins/windows/drivers.rb +52 -52
- data/lib/ohai/plugins/windows/memory.rb +39 -39
- data/lib/ohai/plugins/windows/network.rb +222 -222
- data/lib/ohai/plugins/windows/platform.rb +34 -34
- data/lib/ohai/plugins/windows/system_enclosure.rb +29 -29
- data/lib/ohai/plugins/windows/virtualization.rb +45 -45
- data/lib/ohai/plugins/zpools.rb +94 -94
- data/lib/ohai/provides_map.rb +208 -208
- data/lib/ohai/runner.rb +128 -128
- data/lib/ohai/system.rb +258 -258
- data/lib/ohai/train_transport.rb +29 -29
- data/lib/ohai/util/file_helper.rb +6 -6
- data/lib/ohai/util/ip_helper.rb +56 -56
- data/lib/ohai/util/win32.rb +47 -47
- data/lib/ohai/version.rb +23 -23
- data/lib/ohai.rb +23 -23
- data/ohai.gemspec +35 -35
- metadata +10 -10
data/lib/ohai/plugins/cloud.rb
CHANGED
@@ -1,379 +1,379 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Cary Penniman (<cary@rightscale.com>)
|
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
|
-
Ohai.plugin(:Cloud) do
|
19
|
-
provides "cloud"
|
20
|
-
|
21
|
-
depends "alibaba"
|
22
|
-
depends "ec2"
|
23
|
-
depends "gce"
|
24
|
-
depends "rackspace"
|
25
|
-
depends "eucalyptus"
|
26
|
-
depends "linode"
|
27
|
-
depends "openstack"
|
28
|
-
depends "azure"
|
29
|
-
depends "digital_ocean"
|
30
|
-
depends "softlayer"
|
31
|
-
depends "oci"
|
32
|
-
|
33
|
-
# Class to help enforce the interface exposed to node[:cloud] (OHAI-542)
|
34
|
-
#
|
35
|
-
# cloud[:provider] - (String) the cloud provider the VM is running on.
|
36
|
-
#
|
37
|
-
# cloud[:public_hostname] - (String) a fully qualified hostname
|
38
|
-
# cloud[:local_hostname] - (String) a hostname resolvable on the internal (private) network
|
39
|
-
#
|
40
|
-
# cloud[:public_ipv4_addrs] - (Array) a list of all publicly accessible IPv4 addresses
|
41
|
-
# cloud[:local_ipv4_addrs] - (Array) a list of all private IPv4 addresses
|
42
|
-
# cloud[:public_ipv4] - (String) the first public IPv4 address detected
|
43
|
-
# cloud[:local_ipv4] - (String) the first private IPv4 address detected
|
44
|
-
#
|
45
|
-
# cloud[:public_ipv6_addrs] - (Array) a list of all publicly accessible IPv6 addresses
|
46
|
-
# cloud[:local_ipv6_addrs] - (Array) a list of all private IPv6 addresses
|
47
|
-
# cloud[:public_ipv6] - (String) the first public IPv6 address detected
|
48
|
-
# cloud[:local_ipv6] - (String) the first private IPv6 address detected
|
49
|
-
#
|
50
|
-
class CloudAttrs
|
51
|
-
attr_writer :provider, :public_hostname, :local_hostname
|
52
|
-
|
53
|
-
def initialize
|
54
|
-
@cloud = Mash.new
|
55
|
-
end
|
56
|
-
|
57
|
-
def add_ipv4_addr(ip, accessibility)
|
58
|
-
return if ip.nil? # just skip if ip is nil
|
59
|
-
|
60
|
-
ipaddr = validate_ip_addr(ip, :ipv4)
|
61
|
-
|
62
|
-
case accessibility
|
63
|
-
when :public
|
64
|
-
@cloud[:public_ipv4_addrs] ||= []
|
65
|
-
@cloud[:public_ipv4_addrs] << ipaddr.to_s
|
66
|
-
when :private
|
67
|
-
@cloud[:local_ipv4_addrs] ||= []
|
68
|
-
@cloud[:local_ipv4_addrs] << ipaddr.to_s
|
69
|
-
else
|
70
|
-
raise "ERROR: invalid accessibility param of '#{accessibility}'. must be :public or :private."
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def add_ipv6_addr(ip, accessibility)
|
75
|
-
return if ip.nil? # just skip if ip is nil
|
76
|
-
|
77
|
-
ipaddr = validate_ip_addr(ip, :ipv6)
|
78
|
-
|
79
|
-
raise "ERROR: invalid ipv6 address of '#{ip}' detected. " unless ipaddr.ipv6?
|
80
|
-
|
81
|
-
case accessibility
|
82
|
-
when :public
|
83
|
-
@cloud[:public_ipv6_addrs] ||= []
|
84
|
-
@cloud[:public_ipv6_addrs] << ipaddr.to_s
|
85
|
-
when :private
|
86
|
-
@cloud[:local_ipv6_addrs] ||= []
|
87
|
-
@cloud[:local_ipv6_addrs] << ipaddr.to_s
|
88
|
-
else
|
89
|
-
raise "ERROR: invalid accessibility param of '#{accessibility}'. must be :public or :private."
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def cloud_mash
|
94
|
-
@cloud[:provider] = @provider if @provider
|
95
|
-
|
96
|
-
@cloud[:public_hostname] = @public_hostname if @public_hostname
|
97
|
-
@cloud[:local_hostname] = @local_hostname if @local_hostname
|
98
|
-
|
99
|
-
@cloud[:public_ipv4] = @cloud[:public_ipv4_addrs][0] if @cloud[:public_ipv4_addrs]
|
100
|
-
@cloud[:local_ipv4] = @cloud[:local_ipv4_addrs][0] if @cloud[:local_ipv4_addrs]
|
101
|
-
|
102
|
-
@cloud[:public_ipv6] = @cloud[:public_ipv6_addrs][0] if @cloud[:public_ipv6_addrs]
|
103
|
-
@cloud[:local_ipv6] = @cloud[:local_ipv6_addrs][0] if @cloud[:local_ipv6_addrs]
|
104
|
-
|
105
|
-
# if empty, return nil
|
106
|
-
@cloud.empty? ? nil : @cloud
|
107
|
-
end
|
108
|
-
|
109
|
-
private
|
110
|
-
|
111
|
-
def validate_ip_addr(ip, address_family = :ipv4)
|
112
|
-
ipaddr = ""
|
113
|
-
begin
|
114
|
-
ipaddr = IPAddr.new(ip)
|
115
|
-
raise ArgumentError, "not valid #{address_family} address" unless address_family == :ipv4 ? ipaddr.ipv4? : ipaddr.ipv6?
|
116
|
-
rescue ArgumentError => e
|
117
|
-
raise "ERROR: the ohai 'cloud' plugin failed with an IP address of '#{ip}' : #{e.message}"
|
118
|
-
end
|
119
|
-
ipaddr
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
#--------------------------------------
|
124
|
-
# Alibaba Cloud
|
125
|
-
#--------------------------------------
|
126
|
-
|
127
|
-
def on_alibaba?
|
128
|
-
alibaba != nil
|
129
|
-
end
|
130
|
-
|
131
|
-
def get_alibaba_values
|
132
|
-
@cloud_attr_obj.add_ipv4_addr(alibaba["meta_data"]["eipv4"], :public)
|
133
|
-
@cloud_attr_obj.add_ipv4_addr(alibaba["meta_data"]["private_ipv4"], :private)
|
134
|
-
@cloud_attr_obj.local_hostname = alibaba["meta_data"]["hostname"]
|
135
|
-
@cloud_attr_obj.provider = "alibaba"
|
136
|
-
end
|
137
|
-
|
138
|
-
#--------------------------------------
|
139
|
-
# Google Compute Engine (gce)
|
140
|
-
#--------------------------------------
|
141
|
-
|
142
|
-
def on_gce?
|
143
|
-
gce != nil
|
144
|
-
end
|
145
|
-
|
146
|
-
def get_gce_values
|
147
|
-
public_ips = gce["instance"]["networkInterfaces"].collect do |interface|
|
148
|
-
if interface.key?("accessConfigs")
|
149
|
-
interface["accessConfigs"].collect { |ac| ac["externalIp"] unless ac["externalIp"] == "" }
|
150
|
-
end
|
151
|
-
end.flatten.compact
|
152
|
-
|
153
|
-
private_ips = gce["instance"]["networkInterfaces"].filter_map do |interface|
|
154
|
-
interface["ip"]
|
155
|
-
end
|
156
|
-
|
157
|
-
public_ips.each { |ipaddr| @cloud_attr_obj.add_ipv4_addr(ipaddr, :public) }
|
158
|
-
private_ips.each { |ipaddr| @cloud_attr_obj.add_ipv4_addr(ipaddr, :private) }
|
159
|
-
@cloud_attr_obj.local_hostname = gce["instance"]["hostname"]
|
160
|
-
@cloud_attr_obj.provider = "gce"
|
161
|
-
end
|
162
|
-
|
163
|
-
# ----------------------------------------
|
164
|
-
# ec2
|
165
|
-
# ----------------------------------------
|
166
|
-
|
167
|
-
# Is current cloud ec2?
|
168
|
-
#
|
169
|
-
# === Return
|
170
|
-
# true:: If ec2 Hash is defined
|
171
|
-
# false:: Otherwise
|
172
|
-
def on_ec2?
|
173
|
-
ec2 != nil
|
174
|
-
end
|
175
|
-
|
176
|
-
# Fill cloud hash with ec2 values
|
177
|
-
def get_ec2_values
|
178
|
-
@cloud_attr_obj.add_ipv4_addr(ec2["public_ipv4"], :public)
|
179
|
-
@cloud_attr_obj.add_ipv4_addr(ec2["local_ipv4"], :private)
|
180
|
-
@cloud_attr_obj.public_hostname = ec2["public_hostname"]
|
181
|
-
@cloud_attr_obj.local_hostname = ec2["local_hostname"]
|
182
|
-
@cloud_attr_obj.provider = "ec2"
|
183
|
-
end
|
184
|
-
|
185
|
-
# ----------------------------------------
|
186
|
-
# rackspace
|
187
|
-
# ----------------------------------------
|
188
|
-
|
189
|
-
# Is current cloud rackspace?
|
190
|
-
#
|
191
|
-
# === Return
|
192
|
-
# true:: If rackspace Hash is defined
|
193
|
-
# false:: Otherwise
|
194
|
-
def on_rackspace?
|
195
|
-
rackspace != nil
|
196
|
-
end
|
197
|
-
|
198
|
-
# Fill cloud hash with rackspace values
|
199
|
-
def get_rackspace_values
|
200
|
-
@cloud_attr_obj.add_ipv4_addr(rackspace["public_ipv4"], :public)
|
201
|
-
@cloud_attr_obj.add_ipv4_addr(rackspace["local_ipv4"], :private)
|
202
|
-
@cloud_attr_obj.add_ipv6_addr(rackspace["public_ipv6"], :public)
|
203
|
-
@cloud_attr_obj.add_ipv6_addr(rackspace["local_ipv6"], :private)
|
204
|
-
@cloud_attr_obj.public_hostname = rackspace["public_hostname"]
|
205
|
-
@cloud_attr_obj.local_hostname = rackspace["local_hostname"]
|
206
|
-
@cloud_attr_obj.provider = "rackspace"
|
207
|
-
end
|
208
|
-
|
209
|
-
# ----------------------------------------
|
210
|
-
# linode
|
211
|
-
# ----------------------------------------
|
212
|
-
|
213
|
-
# Is current cloud linode?
|
214
|
-
#
|
215
|
-
# === Return
|
216
|
-
# true:: If linode Hash is defined
|
217
|
-
# false:: Otherwise
|
218
|
-
def on_linode?
|
219
|
-
linode != nil
|
220
|
-
end
|
221
|
-
|
222
|
-
# Fill cloud hash with linode values
|
223
|
-
def get_linode_values
|
224
|
-
@cloud_attr_obj.add_ipv4_addr(linode["public_ip"], :public)
|
225
|
-
@cloud_attr_obj.add_ipv4_addr(linode["private_ip"], :private)
|
226
|
-
@cloud_attr_obj.public_hostname = linode["public_hostname"]
|
227
|
-
@cloud_attr_obj.local_hostname = linode["local_hostname"]
|
228
|
-
@cloud_attr_obj.provider = "linode"
|
229
|
-
end
|
230
|
-
|
231
|
-
# ----------------------------------------
|
232
|
-
# eucalyptus
|
233
|
-
# ----------------------------------------
|
234
|
-
|
235
|
-
# Is current cloud eucalyptus?
|
236
|
-
#
|
237
|
-
# === Return
|
238
|
-
# true:: If eucalyptus Hash is defined
|
239
|
-
# false:: Otherwise
|
240
|
-
def on_eucalyptus?
|
241
|
-
eucalyptus != nil
|
242
|
-
end
|
243
|
-
|
244
|
-
def get_eucalyptus_values
|
245
|
-
@cloud_attr_obj.add_ipv4_addr(eucalyptus["public_ipv4"], :public)
|
246
|
-
@cloud_attr_obj.add_ipv4_addr(eucalyptus["local_ipv4"], :private)
|
247
|
-
@cloud_attr_obj.public_hostname = eucalyptus["public_hostname"]
|
248
|
-
@cloud_attr_obj.local_hostname = eucalyptus["local_hostname"]
|
249
|
-
@cloud_attr_obj.provider = "eucalyptus"
|
250
|
-
end
|
251
|
-
|
252
|
-
# ----------------------------------------
|
253
|
-
# openstack
|
254
|
-
# ----------------------------------------
|
255
|
-
|
256
|
-
# Is current cloud openstack-based?
|
257
|
-
#
|
258
|
-
# === Return
|
259
|
-
# true:: If openstack Hash is defined
|
260
|
-
# false:: Otherwise
|
261
|
-
def on_openstack?
|
262
|
-
openstack != nil
|
263
|
-
end
|
264
|
-
|
265
|
-
# Fill cloud hash with openstack values
|
266
|
-
def get_openstack_values
|
267
|
-
@cloud_attr_obj.add_ipv4_addr(openstack["public_ipv4"], :public)
|
268
|
-
@cloud_attr_obj.add_ipv4_addr(openstack["local_ipv4"], :private)
|
269
|
-
@cloud_attr_obj.public_hostname = openstack["public_hostname"]
|
270
|
-
@cloud_attr_obj.local_hostname = openstack["local_hostname"]
|
271
|
-
@cloud_attr_obj.provider = openstack["provider"]
|
272
|
-
end
|
273
|
-
|
274
|
-
# ----------------------------------------
|
275
|
-
# azure
|
276
|
-
# ----------------------------------------
|
277
|
-
|
278
|
-
# Is current cloud azure?
|
279
|
-
#
|
280
|
-
# === Return
|
281
|
-
# true:: If azure Hash is defined
|
282
|
-
# false:: Otherwise
|
283
|
-
def on_azure?
|
284
|
-
azure != nil
|
285
|
-
end
|
286
|
-
|
287
|
-
# Fill cloud hash with azure values
|
288
|
-
def get_azure_values
|
289
|
-
azure["metadata"]["network"]["public_ipv4"].each { |ipaddr| @cloud_attr_obj.add_ipv4_addr(ipaddr, :public) }
|
290
|
-
azure["metadata"]["network"]["public_ipv6"].each { |ipaddr| @cloud_attr_obj.add_ipv6_addr(ipaddr, :public) }
|
291
|
-
azure["metadata"]["network"]["local_ipv4"].each { |ipaddr| @cloud_attr_obj.add_ipv4_addr(ipaddr, :private) }
|
292
|
-
azure["metadata"]["network"]["local_ipv6"].each { |ipaddr| @cloud_attr_obj.add_ipv6_addr(ipaddr, :private) }
|
293
|
-
@cloud_attr_obj.public_hostname = azure["public_fqdn"]
|
294
|
-
@cloud_attr_obj.provider = "azure"
|
295
|
-
end
|
296
|
-
|
297
|
-
# ----------------------------------------
|
298
|
-
# digital_ocean
|
299
|
-
# ----------------------------------------
|
300
|
-
|
301
|
-
# Is current cloud digital_ocean?
|
302
|
-
#
|
303
|
-
# === Return
|
304
|
-
# true:: If digital_ocean Mash is defined
|
305
|
-
# false:: Otherwise
|
306
|
-
def on_digital_ocean?
|
307
|
-
digital_ocean != nil
|
308
|
-
end
|
309
|
-
|
310
|
-
# Fill cloud hash with digital_ocean values
|
311
|
-
def get_digital_ocean_values
|
312
|
-
@cloud_attr_obj.add_ipv4_addr(digital_ocean["interfaces"]["public"][0]["ipv4"]["ip_address"], :public) rescue NoMethodError
|
313
|
-
@cloud_attr_obj.add_ipv4_addr(digital_ocean["interfaces"]["private"][0]["ipv4"]["ip_address"], :private) rescue NoMethodError
|
314
|
-
@cloud_attr_obj.add_ipv6_addr(digital_ocean["interfaces"]["public"][0]["ipv6"]["ip_address"], :public) rescue NoMethodError
|
315
|
-
@cloud_attr_obj.add_ipv6_addr(digital_ocean["interfaces"]["private"][0]["ipv6"]["ip_address"], :private) rescue NoMethodError
|
316
|
-
@cloud_attr_obj.provider = "digital_ocean"
|
317
|
-
end
|
318
|
-
|
319
|
-
# ----------------------------------------
|
320
|
-
# softlayer
|
321
|
-
# ----------------------------------------
|
322
|
-
|
323
|
-
# Is current cloud softlayer?
|
324
|
-
#
|
325
|
-
# === Return
|
326
|
-
# true:: If softlayer Hash is defined
|
327
|
-
# false:: Otherwise
|
328
|
-
def on_softlayer?
|
329
|
-
softlayer != nil
|
330
|
-
end
|
331
|
-
|
332
|
-
# Fill cloud hash with softlayer values
|
333
|
-
def get_softlayer_values
|
334
|
-
@cloud_attr_obj.add_ipv4_addr(softlayer["public_ipv4"], :public)
|
335
|
-
@cloud_attr_obj.add_ipv4_addr(softlayer["local_ipv4"], :private)
|
336
|
-
@cloud_attr_obj.public_hostname = softlayer["public_fqdn"]
|
337
|
-
@cloud_attr_obj.provider = "softlayer"
|
338
|
-
end
|
339
|
-
|
340
|
-
# ----------------------------------------
|
341
|
-
# OCI
|
342
|
-
# ----------------------------------------
|
343
|
-
|
344
|
-
# Is current Oracle Cloud Infrastructure?
|
345
|
-
#
|
346
|
-
# === Return
|
347
|
-
# true:: If oci Hash is defined
|
348
|
-
# false:: Otherwise
|
349
|
-
def on_oci?
|
350
|
-
oci != nil
|
351
|
-
end
|
352
|
-
|
353
|
-
# Fill cloud hash with OCI values
|
354
|
-
def oci_values
|
355
|
-
oci["metadata"]["network"]["interface"].each { |vnic| @cloud_attr_obj.add_ipv4_addr(vnic["privateIp"], :private) }
|
356
|
-
@cloud_attr_obj.local_hostname = oci["metadata"]["compute"]["hostname"]
|
357
|
-
@cloud_attr_obj.provider = "oci"
|
358
|
-
end
|
359
|
-
|
360
|
-
collect_data do
|
361
|
-
require "ipaddr" unless defined?(IPAddr)
|
362
|
-
|
363
|
-
@cloud_attr_obj = CloudAttrs.new
|
364
|
-
|
365
|
-
get_gce_values if on_gce?
|
366
|
-
get_ec2_values if on_ec2?
|
367
|
-
get_rackspace_values if on_rackspace?
|
368
|
-
get_linode_values if on_linode?
|
369
|
-
get_eucalyptus_values if on_eucalyptus?
|
370
|
-
get_openstack_values if on_openstack?
|
371
|
-
get_azure_values if on_azure?
|
372
|
-
get_digital_ocean_values if on_digital_ocean?
|
373
|
-
get_softlayer_values if on_softlayer?
|
374
|
-
get_alibaba_values if on_alibaba?
|
375
|
-
oci_values if on_oci?
|
376
|
-
|
377
|
-
cloud @cloud_attr_obj.cloud_mash
|
378
|
-
end
|
379
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Cary Penniman (<cary@rightscale.com>)
|
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
|
+
Ohai.plugin(:Cloud) do
|
19
|
+
provides "cloud"
|
20
|
+
|
21
|
+
depends "alibaba"
|
22
|
+
depends "ec2"
|
23
|
+
depends "gce"
|
24
|
+
depends "rackspace"
|
25
|
+
depends "eucalyptus"
|
26
|
+
depends "linode"
|
27
|
+
depends "openstack"
|
28
|
+
depends "azure"
|
29
|
+
depends "digital_ocean"
|
30
|
+
depends "softlayer"
|
31
|
+
depends "oci"
|
32
|
+
|
33
|
+
# Class to help enforce the interface exposed to node[:cloud] (OHAI-542)
|
34
|
+
#
|
35
|
+
# cloud[:provider] - (String) the cloud provider the VM is running on.
|
36
|
+
#
|
37
|
+
# cloud[:public_hostname] - (String) a fully qualified hostname
|
38
|
+
# cloud[:local_hostname] - (String) a hostname resolvable on the internal (private) network
|
39
|
+
#
|
40
|
+
# cloud[:public_ipv4_addrs] - (Array) a list of all publicly accessible IPv4 addresses
|
41
|
+
# cloud[:local_ipv4_addrs] - (Array) a list of all private IPv4 addresses
|
42
|
+
# cloud[:public_ipv4] - (String) the first public IPv4 address detected
|
43
|
+
# cloud[:local_ipv4] - (String) the first private IPv4 address detected
|
44
|
+
#
|
45
|
+
# cloud[:public_ipv6_addrs] - (Array) a list of all publicly accessible IPv6 addresses
|
46
|
+
# cloud[:local_ipv6_addrs] - (Array) a list of all private IPv6 addresses
|
47
|
+
# cloud[:public_ipv6] - (String) the first public IPv6 address detected
|
48
|
+
# cloud[:local_ipv6] - (String) the first private IPv6 address detected
|
49
|
+
#
|
50
|
+
class CloudAttrs
|
51
|
+
attr_writer :provider, :public_hostname, :local_hostname
|
52
|
+
|
53
|
+
def initialize
|
54
|
+
@cloud = Mash.new
|
55
|
+
end
|
56
|
+
|
57
|
+
def add_ipv4_addr(ip, accessibility)
|
58
|
+
return if ip.nil? # just skip if ip is nil
|
59
|
+
|
60
|
+
ipaddr = validate_ip_addr(ip, :ipv4)
|
61
|
+
|
62
|
+
case accessibility
|
63
|
+
when :public
|
64
|
+
@cloud[:public_ipv4_addrs] ||= []
|
65
|
+
@cloud[:public_ipv4_addrs] << ipaddr.to_s
|
66
|
+
when :private
|
67
|
+
@cloud[:local_ipv4_addrs] ||= []
|
68
|
+
@cloud[:local_ipv4_addrs] << ipaddr.to_s
|
69
|
+
else
|
70
|
+
raise "ERROR: invalid accessibility param of '#{accessibility}'. must be :public or :private."
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def add_ipv6_addr(ip, accessibility)
|
75
|
+
return if ip.nil? # just skip if ip is nil
|
76
|
+
|
77
|
+
ipaddr = validate_ip_addr(ip, :ipv6)
|
78
|
+
|
79
|
+
raise "ERROR: invalid ipv6 address of '#{ip}' detected. " unless ipaddr.ipv6?
|
80
|
+
|
81
|
+
case accessibility
|
82
|
+
when :public
|
83
|
+
@cloud[:public_ipv6_addrs] ||= []
|
84
|
+
@cloud[:public_ipv6_addrs] << ipaddr.to_s
|
85
|
+
when :private
|
86
|
+
@cloud[:local_ipv6_addrs] ||= []
|
87
|
+
@cloud[:local_ipv6_addrs] << ipaddr.to_s
|
88
|
+
else
|
89
|
+
raise "ERROR: invalid accessibility param of '#{accessibility}'. must be :public or :private."
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def cloud_mash
|
94
|
+
@cloud[:provider] = @provider if @provider
|
95
|
+
|
96
|
+
@cloud[:public_hostname] = @public_hostname if @public_hostname
|
97
|
+
@cloud[:local_hostname] = @local_hostname if @local_hostname
|
98
|
+
|
99
|
+
@cloud[:public_ipv4] = @cloud[:public_ipv4_addrs][0] if @cloud[:public_ipv4_addrs]
|
100
|
+
@cloud[:local_ipv4] = @cloud[:local_ipv4_addrs][0] if @cloud[:local_ipv4_addrs]
|
101
|
+
|
102
|
+
@cloud[:public_ipv6] = @cloud[:public_ipv6_addrs][0] if @cloud[:public_ipv6_addrs]
|
103
|
+
@cloud[:local_ipv6] = @cloud[:local_ipv6_addrs][0] if @cloud[:local_ipv6_addrs]
|
104
|
+
|
105
|
+
# if empty, return nil
|
106
|
+
@cloud.empty? ? nil : @cloud
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def validate_ip_addr(ip, address_family = :ipv4)
|
112
|
+
ipaddr = ""
|
113
|
+
begin
|
114
|
+
ipaddr = IPAddr.new(ip)
|
115
|
+
raise ArgumentError, "not valid #{address_family} address" unless address_family == :ipv4 ? ipaddr.ipv4? : ipaddr.ipv6?
|
116
|
+
rescue ArgumentError => e
|
117
|
+
raise "ERROR: the ohai 'cloud' plugin failed with an IP address of '#{ip}' : #{e.message}"
|
118
|
+
end
|
119
|
+
ipaddr
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
#--------------------------------------
|
124
|
+
# Alibaba Cloud
|
125
|
+
#--------------------------------------
|
126
|
+
|
127
|
+
def on_alibaba?
|
128
|
+
alibaba != nil
|
129
|
+
end
|
130
|
+
|
131
|
+
def get_alibaba_values
|
132
|
+
@cloud_attr_obj.add_ipv4_addr(alibaba["meta_data"]["eipv4"], :public)
|
133
|
+
@cloud_attr_obj.add_ipv4_addr(alibaba["meta_data"]["private_ipv4"], :private)
|
134
|
+
@cloud_attr_obj.local_hostname = alibaba["meta_data"]["hostname"]
|
135
|
+
@cloud_attr_obj.provider = "alibaba"
|
136
|
+
end
|
137
|
+
|
138
|
+
#--------------------------------------
|
139
|
+
# Google Compute Engine (gce)
|
140
|
+
#--------------------------------------
|
141
|
+
|
142
|
+
def on_gce?
|
143
|
+
gce != nil
|
144
|
+
end
|
145
|
+
|
146
|
+
def get_gce_values
|
147
|
+
public_ips = gce["instance"]["networkInterfaces"].collect do |interface|
|
148
|
+
if interface.key?("accessConfigs")
|
149
|
+
interface["accessConfigs"].collect { |ac| ac["externalIp"] unless ac["externalIp"] == "" }
|
150
|
+
end
|
151
|
+
end.flatten.compact
|
152
|
+
|
153
|
+
private_ips = gce["instance"]["networkInterfaces"].filter_map do |interface|
|
154
|
+
interface["ip"]
|
155
|
+
end
|
156
|
+
|
157
|
+
public_ips.each { |ipaddr| @cloud_attr_obj.add_ipv4_addr(ipaddr, :public) }
|
158
|
+
private_ips.each { |ipaddr| @cloud_attr_obj.add_ipv4_addr(ipaddr, :private) }
|
159
|
+
@cloud_attr_obj.local_hostname = gce["instance"]["hostname"]
|
160
|
+
@cloud_attr_obj.provider = "gce"
|
161
|
+
end
|
162
|
+
|
163
|
+
# ----------------------------------------
|
164
|
+
# ec2
|
165
|
+
# ----------------------------------------
|
166
|
+
|
167
|
+
# Is current cloud ec2?
|
168
|
+
#
|
169
|
+
# === Return
|
170
|
+
# true:: If ec2 Hash is defined
|
171
|
+
# false:: Otherwise
|
172
|
+
def on_ec2?
|
173
|
+
ec2 != nil
|
174
|
+
end
|
175
|
+
|
176
|
+
# Fill cloud hash with ec2 values
|
177
|
+
def get_ec2_values
|
178
|
+
@cloud_attr_obj.add_ipv4_addr(ec2["public_ipv4"], :public)
|
179
|
+
@cloud_attr_obj.add_ipv4_addr(ec2["local_ipv4"], :private)
|
180
|
+
@cloud_attr_obj.public_hostname = ec2["public_hostname"]
|
181
|
+
@cloud_attr_obj.local_hostname = ec2["local_hostname"]
|
182
|
+
@cloud_attr_obj.provider = "ec2"
|
183
|
+
end
|
184
|
+
|
185
|
+
# ----------------------------------------
|
186
|
+
# rackspace
|
187
|
+
# ----------------------------------------
|
188
|
+
|
189
|
+
# Is current cloud rackspace?
|
190
|
+
#
|
191
|
+
# === Return
|
192
|
+
# true:: If rackspace Hash is defined
|
193
|
+
# false:: Otherwise
|
194
|
+
def on_rackspace?
|
195
|
+
rackspace != nil
|
196
|
+
end
|
197
|
+
|
198
|
+
# Fill cloud hash with rackspace values
|
199
|
+
def get_rackspace_values
|
200
|
+
@cloud_attr_obj.add_ipv4_addr(rackspace["public_ipv4"], :public)
|
201
|
+
@cloud_attr_obj.add_ipv4_addr(rackspace["local_ipv4"], :private)
|
202
|
+
@cloud_attr_obj.add_ipv6_addr(rackspace["public_ipv6"], :public)
|
203
|
+
@cloud_attr_obj.add_ipv6_addr(rackspace["local_ipv6"], :private)
|
204
|
+
@cloud_attr_obj.public_hostname = rackspace["public_hostname"]
|
205
|
+
@cloud_attr_obj.local_hostname = rackspace["local_hostname"]
|
206
|
+
@cloud_attr_obj.provider = "rackspace"
|
207
|
+
end
|
208
|
+
|
209
|
+
# ----------------------------------------
|
210
|
+
# linode
|
211
|
+
# ----------------------------------------
|
212
|
+
|
213
|
+
# Is current cloud linode?
|
214
|
+
#
|
215
|
+
# === Return
|
216
|
+
# true:: If linode Hash is defined
|
217
|
+
# false:: Otherwise
|
218
|
+
def on_linode?
|
219
|
+
linode != nil
|
220
|
+
end
|
221
|
+
|
222
|
+
# Fill cloud hash with linode values
|
223
|
+
def get_linode_values
|
224
|
+
@cloud_attr_obj.add_ipv4_addr(linode["public_ip"], :public)
|
225
|
+
@cloud_attr_obj.add_ipv4_addr(linode["private_ip"], :private)
|
226
|
+
@cloud_attr_obj.public_hostname = linode["public_hostname"]
|
227
|
+
@cloud_attr_obj.local_hostname = linode["local_hostname"]
|
228
|
+
@cloud_attr_obj.provider = "linode"
|
229
|
+
end
|
230
|
+
|
231
|
+
# ----------------------------------------
|
232
|
+
# eucalyptus
|
233
|
+
# ----------------------------------------
|
234
|
+
|
235
|
+
# Is current cloud eucalyptus?
|
236
|
+
#
|
237
|
+
# === Return
|
238
|
+
# true:: If eucalyptus Hash is defined
|
239
|
+
# false:: Otherwise
|
240
|
+
def on_eucalyptus?
|
241
|
+
eucalyptus != nil
|
242
|
+
end
|
243
|
+
|
244
|
+
def get_eucalyptus_values
|
245
|
+
@cloud_attr_obj.add_ipv4_addr(eucalyptus["public_ipv4"], :public)
|
246
|
+
@cloud_attr_obj.add_ipv4_addr(eucalyptus["local_ipv4"], :private)
|
247
|
+
@cloud_attr_obj.public_hostname = eucalyptus["public_hostname"]
|
248
|
+
@cloud_attr_obj.local_hostname = eucalyptus["local_hostname"]
|
249
|
+
@cloud_attr_obj.provider = "eucalyptus"
|
250
|
+
end
|
251
|
+
|
252
|
+
# ----------------------------------------
|
253
|
+
# openstack
|
254
|
+
# ----------------------------------------
|
255
|
+
|
256
|
+
# Is current cloud openstack-based?
|
257
|
+
#
|
258
|
+
# === Return
|
259
|
+
# true:: If openstack Hash is defined
|
260
|
+
# false:: Otherwise
|
261
|
+
def on_openstack?
|
262
|
+
openstack != nil
|
263
|
+
end
|
264
|
+
|
265
|
+
# Fill cloud hash with openstack values
|
266
|
+
def get_openstack_values
|
267
|
+
@cloud_attr_obj.add_ipv4_addr(openstack["public_ipv4"], :public)
|
268
|
+
@cloud_attr_obj.add_ipv4_addr(openstack["local_ipv4"], :private)
|
269
|
+
@cloud_attr_obj.public_hostname = openstack["public_hostname"]
|
270
|
+
@cloud_attr_obj.local_hostname = openstack["local_hostname"]
|
271
|
+
@cloud_attr_obj.provider = openstack["provider"]
|
272
|
+
end
|
273
|
+
|
274
|
+
# ----------------------------------------
|
275
|
+
# azure
|
276
|
+
# ----------------------------------------
|
277
|
+
|
278
|
+
# Is current cloud azure?
|
279
|
+
#
|
280
|
+
# === Return
|
281
|
+
# true:: If azure Hash is defined
|
282
|
+
# false:: Otherwise
|
283
|
+
def on_azure?
|
284
|
+
azure != nil
|
285
|
+
end
|
286
|
+
|
287
|
+
# Fill cloud hash with azure values
|
288
|
+
def get_azure_values
|
289
|
+
azure["metadata"]["network"]["public_ipv4"].each { |ipaddr| @cloud_attr_obj.add_ipv4_addr(ipaddr, :public) }
|
290
|
+
azure["metadata"]["network"]["public_ipv6"].each { |ipaddr| @cloud_attr_obj.add_ipv6_addr(ipaddr, :public) }
|
291
|
+
azure["metadata"]["network"]["local_ipv4"].each { |ipaddr| @cloud_attr_obj.add_ipv4_addr(ipaddr, :private) }
|
292
|
+
azure["metadata"]["network"]["local_ipv6"].each { |ipaddr| @cloud_attr_obj.add_ipv6_addr(ipaddr, :private) }
|
293
|
+
@cloud_attr_obj.public_hostname = azure["public_fqdn"]
|
294
|
+
@cloud_attr_obj.provider = "azure"
|
295
|
+
end
|
296
|
+
|
297
|
+
# ----------------------------------------
|
298
|
+
# digital_ocean
|
299
|
+
# ----------------------------------------
|
300
|
+
|
301
|
+
# Is current cloud digital_ocean?
|
302
|
+
#
|
303
|
+
# === Return
|
304
|
+
# true:: If digital_ocean Mash is defined
|
305
|
+
# false:: Otherwise
|
306
|
+
def on_digital_ocean?
|
307
|
+
digital_ocean != nil
|
308
|
+
end
|
309
|
+
|
310
|
+
# Fill cloud hash with digital_ocean values
|
311
|
+
def get_digital_ocean_values
|
312
|
+
@cloud_attr_obj.add_ipv4_addr(digital_ocean["interfaces"]["public"][0]["ipv4"]["ip_address"], :public) rescue NoMethodError
|
313
|
+
@cloud_attr_obj.add_ipv4_addr(digital_ocean["interfaces"]["private"][0]["ipv4"]["ip_address"], :private) rescue NoMethodError
|
314
|
+
@cloud_attr_obj.add_ipv6_addr(digital_ocean["interfaces"]["public"][0]["ipv6"]["ip_address"], :public) rescue NoMethodError
|
315
|
+
@cloud_attr_obj.add_ipv6_addr(digital_ocean["interfaces"]["private"][0]["ipv6"]["ip_address"], :private) rescue NoMethodError
|
316
|
+
@cloud_attr_obj.provider = "digital_ocean"
|
317
|
+
end
|
318
|
+
|
319
|
+
# ----------------------------------------
|
320
|
+
# softlayer
|
321
|
+
# ----------------------------------------
|
322
|
+
|
323
|
+
# Is current cloud softlayer?
|
324
|
+
#
|
325
|
+
# === Return
|
326
|
+
# true:: If softlayer Hash is defined
|
327
|
+
# false:: Otherwise
|
328
|
+
def on_softlayer?
|
329
|
+
softlayer != nil
|
330
|
+
end
|
331
|
+
|
332
|
+
# Fill cloud hash with softlayer values
|
333
|
+
def get_softlayer_values
|
334
|
+
@cloud_attr_obj.add_ipv4_addr(softlayer["public_ipv4"], :public)
|
335
|
+
@cloud_attr_obj.add_ipv4_addr(softlayer["local_ipv4"], :private)
|
336
|
+
@cloud_attr_obj.public_hostname = softlayer["public_fqdn"]
|
337
|
+
@cloud_attr_obj.provider = "softlayer"
|
338
|
+
end
|
339
|
+
|
340
|
+
# ----------------------------------------
|
341
|
+
# OCI
|
342
|
+
# ----------------------------------------
|
343
|
+
|
344
|
+
# Is current Oracle Cloud Infrastructure?
|
345
|
+
#
|
346
|
+
# === Return
|
347
|
+
# true:: If oci Hash is defined
|
348
|
+
# false:: Otherwise
|
349
|
+
def on_oci?
|
350
|
+
oci != nil
|
351
|
+
end
|
352
|
+
|
353
|
+
# Fill cloud hash with OCI values
|
354
|
+
def oci_values
|
355
|
+
oci["metadata"]["network"]["interface"].each { |vnic| @cloud_attr_obj.add_ipv4_addr(vnic["privateIp"], :private) }
|
356
|
+
@cloud_attr_obj.local_hostname = oci["metadata"]["compute"]["hostname"]
|
357
|
+
@cloud_attr_obj.provider = "oci"
|
358
|
+
end
|
359
|
+
|
360
|
+
collect_data do
|
361
|
+
require "ipaddr" unless defined?(IPAddr)
|
362
|
+
|
363
|
+
@cloud_attr_obj = CloudAttrs.new
|
364
|
+
|
365
|
+
get_gce_values if on_gce?
|
366
|
+
get_ec2_values if on_ec2?
|
367
|
+
get_rackspace_values if on_rackspace?
|
368
|
+
get_linode_values if on_linode?
|
369
|
+
get_eucalyptus_values if on_eucalyptus?
|
370
|
+
get_openstack_values if on_openstack?
|
371
|
+
get_azure_values if on_azure?
|
372
|
+
get_digital_ocean_values if on_digital_ocean?
|
373
|
+
get_softlayer_values if on_softlayer?
|
374
|
+
get_alibaba_values if on_alibaba?
|
375
|
+
oci_values if on_oci?
|
376
|
+
|
377
|
+
cloud @cloud_attr_obj.cloud_mash
|
378
|
+
end
|
379
|
+
end
|