Parent

CloudAttrs

Class to help enforce the interface exposed to node (OHAI-542)

cloud - (String) the cloud provider the VM is running on.

cloud - (String) a fully qualified hostname cloud - (String) a hostname resolvable on the internal (private) network

cloud - (Array) a list of all publicly accessible IPv4 addresses cloud - (Array) a list of all private IPv4 addresses cloud - (String) the first public IPv4 address detected cloud - (String) the first private IPv4 address detected

cloud - (Array) a list of all publicly accessible IPv6 addresses cloud - (Array) a list of all private IPv6 addresses cloud - (String) the first public IPv6 address detected cloud - (String) the first private IPv6 address detected

Attributes

local_hostname[W]
provider[W]
public_hostname[W]

Public Class Methods

new() click to toggle source
# File lib/ohai/plugins/cloud_v2.rb, line 48
def initialize
  @cloud = Mash.new
end

Public Instance Methods

add_ipv4_addr(ip, accessibility) click to toggle source
# File lib/ohai/plugins/cloud_v2.rb, line 52
def add_ipv4_addr(ip, accessibility)
  return if ip.nil? # just skip if ip is nil
  ipaddr = validate_ip_addr(ip, :ipv4)

  case accessibility
  when :public
    @cloud[:public_ipv4_addrs] ||= Array.new
    @cloud[:public_ipv4_addrs] << ipaddr.to_s
  when :private
    @cloud[:local_ipv4_addrs] ||= Array.new
    @cloud[:local_ipv4_addrs] << ipaddr.to_s
  else
    raise "ERROR: in valid accessibility param of '#{accessibility}'. must be :public or :private."
  end
end
add_ipv6_addr(ip, accessibility) click to toggle source
# File lib/ohai/plugins/cloud_v2.rb, line 68
def add_ipv6_addr(ip, accessibility)
  return if ip.nil? # just skip if ip is nil
  ipaddr = validate_ip_addr(ip, :ipv6)

  raise "ERROR: invalid ipv6 address of '#{ip}' detected. " unless ipaddr.ipv6?
  case accessibility
  when :public
    @cloud[:public_ipv6_addrs] ||= Array.new
    @cloud[:public_ipv6_addrs] << ipaddr.to_s
  when :private
    @cloud[:local_ipv6_addrs] ||= Array.new
    @cloud[:local_ipv6_addrs] << ipaddr.to_s
  else
    raise "ERROR: in valid accessibility param of '#{accessibility}'. must be :public or :private."
  end
end
cloud_mash() click to toggle source
# File lib/ohai/plugins/cloud_v2.rb, line 85
def cloud_mash
  @cloud[:provider] = @provider if @provider

  @cloud[:public_hostname] = @public_hostname if @public_hostname
  @cloud[:local_hostname] = @local_hostname if @local_hostname

  @cloud[:public_ipv4] = @cloud[:public_ipv4_addrs][0] if @cloud[:public_ipv4_addrs]
  @cloud[:local_ipv4] = @cloud[:local_ipv4_addrs][0] if @cloud[:local_ipv4_addrs]

  @cloud[:public_ipv6] = @cloud[:public_ipv6_addrs][0] if @cloud[:public_ipv6_addrs]
  @cloud[:local_ipv6] = @cloud[:local_ipv6_addrs][0] if @cloud[:local_ipv6_addrs]

  # if empty, return nil
  (@cloud.empty?) ? nil : @cloud
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.