summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-02-04 11:00:49 +0000
committerThom May <thom@may.lt>2016-02-04 11:00:49 +0000
commit9b21b5184e4a369c65a81768e518e0c6af670afa (patch)
treee929c463b1d457edf7ecf6c7bddd2c4ccb1cf955
parent237129a0fc69430396d60a95e4c192ddec2890d0 (diff)
parent42afd29c44dc3d9c1c772496a02e70313215d46c (diff)
downloadohai-9b21b5184e4a369c65a81768e518e0c6af670afa.tar.gz
Merge pull request #724 from tas50/cloud_debug
Improved debug logging for cloud plugins
-rw-r--r--lib/ohai/plugins/digital_ocean.rb6
-rw-r--r--lib/ohai/plugins/eucalyptus.rb20
-rw-r--r--lib/ohai/plugins/gce.rb4
-rw-r--r--lib/ohai/plugins/linode.rb3
-rw-r--r--lib/ohai/plugins/rackspace.rb8
-rw-r--r--lib/ohai/plugins/softlayer.rb7
6 files changed, 28 insertions, 20 deletions
diff --git a/lib/ohai/plugins/digital_ocean.rb b/lib/ohai/plugins/digital_ocean.rb
index f637e748..abc5f853 100644
--- a/lib/ohai/plugins/digital_ocean.rb
+++ b/lib/ohai/plugins/digital_ocean.rb
@@ -22,7 +22,6 @@ Ohai.plugin(:DigitalOcean) do
DIGITALOCEAN_FILE = '/etc/digitalocean' unless defined?(DIGITALOCEAN_FILE)
provides "digital_ocean"
-
depends "network/interfaces"
def extract_droplet_ip_addresses
@@ -35,7 +34,7 @@ Ohai.plugin(:DigitalOcean) do
type = digital_ocean_address_type(ip)
address_hash = build_address_hash(ip, details)
addresses[type] << address_hash
- end
+ end
end
addresses
end
@@ -64,6 +63,7 @@ Ohai.plugin(:DigitalOcean) do
collect_data do
if looks_like_digital_ocean?
+ Ohai::Log.debug("digitalocean plugin: looks_like_digital_ocean? == true")
digital_ocean Mash.new
hint = hint?('digital_ocean') || {}
hint.each {|k, v| digital_ocean[k] = v unless k == 'ip_addresses'}
@@ -74,7 +74,7 @@ Ohai.plugin(:DigitalOcean) do
# https://developers.digitalocean.com/#droplets
digital_ocean[:networks] = extract_droplet_ip_addresses
else
- Ohai::Log.debug("No hints present for digital_ocean.")
+ Ohai::Log.debug("digitalocean plugin: No hints present for and doesn't look like digitalocean")
false
end
end
diff --git a/lib/ohai/plugins/eucalyptus.rb b/lib/ohai/plugins/eucalyptus.rb
index eb04009d..0a0c0b4b 100644
--- a/lib/ohai/plugins/eucalyptus.rb
+++ b/lib/ohai/plugins/eucalyptus.rb
@@ -17,15 +17,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# eucalyptus metadata service is compatible with the ec2 service calls
require 'ohai/mixin/ec2_metadata'
Ohai.plugin(:Eucalyptus) do
include Ohai::Mixin::Ec2Metadata
provides "eucalyptus"
-
depends "network/interfaces"
+ # returns the mac address from the collection of all address types
def get_mac_address(addresses)
detected_addresses = addresses.detect { |address, keypair| keypair == {"family"=>"lladdr"} }
if detected_addresses
@@ -35,26 +36,29 @@ Ohai.plugin(:Eucalyptus) do
end
end
+ # detect if the mac address starts with d0:0d
def has_euca_mac?
network[:interfaces].values.each do |iface|
- has_mac = (get_mac_address(iface[:addresses]) =~ /^[dD]0:0[dD]:/)
- Ohai::Log.debug("has_euca_mac? == #{!!has_mac}")
- return true if has_mac
+ mac = get_mac_address(iface[:addresses])
+ if mac =~ /^[dD]0:0[dD]:/
+ Ohai::Log.debug("eucalyptus plugin: has_euca_mac? == true (#{mac})")
+ return true
+ end
end
- Ohai::Log.debug("has_euca_mac? == false")
+ Ohai::Log.debug("eucalyptus plugin: has_euca_mac? == false")
false
end
def looks_like_euca?
# Try non-blocking connect so we don't "block" if
- # the Xen environment is *not* EC2
+ # the metadata service doesn't respond
hint?('eucalyptus') || has_euca_mac? && can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80)
end
collect_data do
if looks_like_euca?
- Ohai::Log.debug("looks_like_euca? == true")
+ Ohai::Log.debug("eucalyptus plugin: looks_like_euca? == true")
eucalyptus Mash.new
self.fetch_metadata.each do |k, v|
# Eucalyptus 3.4+ supports IAM roles and Instance Profiles much like AWS
@@ -69,7 +73,7 @@ Ohai.plugin(:Eucalyptus) do
end
eucalyptus[:userdata] = self.fetch_userdata
else
- Ohai::Log.debug("looks_like_euca? == false")
+ Ohai::Log.debug("eucalyptus plugin: looks_like_euca? == false")
false
end
end
diff --git a/lib/ohai/plugins/gce.rb b/lib/ohai/plugins/gce.rb
index 6a03f0fc..82abaf08 100644
--- a/lib/ohai/plugins/gce.rb
+++ b/lib/ohai/plugins/gce.rb
@@ -41,11 +41,11 @@ Ohai.plugin(:GCE) do
collect_data do
if looks_like_gce?
- Ohai::Log.debug("looks_like_gce? == true")
+ Ohai::Log.debug("gce plugin: looks_like_gce? == true")
gce Mash.new
fetch_metadata.each {|k, v| gce[k] = v }
else
- Ohai::Log.debug("looks_like_gce? == false")
+ Ohai::Log.debug("gce plugin: looks_like_gce? == false")
false
end
end
diff --git a/lib/ohai/plugins/linode.rb b/lib/ohai/plugins/linode.rb
index 72c40a2d..a585783d 100644
--- a/lib/ohai/plugins/linode.rb
+++ b/lib/ohai/plugins/linode.rb
@@ -53,10 +53,13 @@ Ohai.plugin(:Linode) do
collect_data do
# Setup linode mash if it is a linode system
if looks_like_linode?
+ Ohai::Log.debug("linode plugin: looks_like_linode? == true")
linode Mash.new
get_ip_address(:public_ip, :eth0)
get_ip_address(:private_ip, "eth0:1")
hint?('linode').each{|k,v| linode[k] = v } if hint?('linode').kind_of?(Hash)
+ else
+ Ohai::Log.debug("linode plugin: looks_like_linode? == false")
end
end
end
diff --git a/lib/ohai/plugins/rackspace.rb b/lib/ohai/plugins/rackspace.rb
index 195fed06..7aa02b2d 100644
--- a/lib/ohai/plugins/rackspace.rb
+++ b/lib/ohai/plugins/rackspace.rb
@@ -92,7 +92,7 @@ Ohai.plugin(:Rackspace) do
end
end
rescue Errno::ENOENT
- Ohai::Log.debug("Unable to find xenstore-ls, cannot capture region information for Rackspace cloud")
+ Ohai::Log.debug("rackspace plugin: Unable to find xenstore-ls, cannot capture region information for Rackspace cloud")
nil
end
@@ -104,7 +104,7 @@ Ohai.plugin(:Rackspace) do
rackspace[:instance_id] = so.stdout.gsub(/instance-/, "")
end
rescue Errno::ENOENT
- Ohai::Log.debug("Unable to find xenstore-read, cannot capture instance ID information for Rackspace cloud")
+ Ohai::Log.debug("rackspace plugin: Unable to find xenstore-read, cannot capture instance ID information for Rackspace cloud")
nil
end
@@ -119,7 +119,7 @@ Ohai.plugin(:Rackspace) do
if _so.exitstatus == 0
networks.push(FFI_Yajl::Parser.new.parse(_so.stdout))
else
- Ohai::Log.debug('Unable to capture custom private networking information for Rackspace cloud')
+ Ohai::Log.debug('rackspace plugin: Unable to capture custom private networking information for Rackspace cloud')
return false
end
end
@@ -128,7 +128,7 @@ Ohai.plugin(:Rackspace) do
networks.delete_if { |hash| hash['label'] == 'public' }
end
rescue Errno::ENOENT
- Ohai::Log.debug('Unable to capture custom private networking information for Rackspace cloud')
+ Ohai::Log.debug('rackspace plugin: Unable to capture custom private networking information for Rackspace cloud')
nil
end
diff --git a/lib/ohai/plugins/softlayer.rb b/lib/ohai/plugins/softlayer.rb
index 028a744f..4704e0a6 100644
--- a/lib/ohai/plugins/softlayer.rb
+++ b/lib/ohai/plugins/softlayer.rb
@@ -37,11 +37,12 @@ Ohai.plugin(:Softlayer) do
collect_data do
# Adds softlayer Mash
if looks_like_softlayer?
- ::Ohai::Log.debug("looks_like_softlayer? == true")
+ Ohai::Log.debug("softlayer plugin: looks_like_softlayer? == true")
metadata = fetch_metadata
softlayer Mash.new
metadata.each { |k,v| softlayer[k] = v } if metadata
+ else
+ Ohai::Log.debug("softlayer plugin: looks_like_softlayer? == false")
end
-
end
-end \ No newline at end of file
+end