class DeviceInfo

Public Class Methods

new(host, gg_config) click to toggle source
# File lib/device_info/device_info.rb, line 24
def initialize(host, gg_config)
  @host = host
  @gg_config = gg_config
end

Public Instance Methods

data() click to toggle source

Get the device data, if the data does not exist get it from Ohai

# File lib/device_info/device_info.rb, line 47
def data
  @data||=get_ohai_data
end
get_ohai_data() click to toggle source

Get data about the client by using the Ohai component developed by Opscode

# File lib/device_info/device_info.rb, line 39
def get_ohai_data
  Ohai::Config[:plugin_path] << '/etc/chef/ohai_plugins'
  ohai_system = Ohai::System.new
  ohai_system.all_plugins
  ohai_system.data
end
gg_config() click to toggle source
# File lib/device_info/device_info.rb, line 34
def gg_config
  @gg_config
end
host() click to toggle source

Give the host name set previous

# File lib/device_info/device_info.rb, line 30
def host
  @host
end
post() click to toggle source

Will post the device data to the client service

# File lib/device_info/device_info.rb, line 52
def post
  url = Request.get_base_url(host) + "/device/set_device_data/1/#{gg_config.config[:user_id_salt]}/#{gg_config.config[:device_id]}/#{gg_config.config[:token]}"
  logger.debug "Will post this ohai data:\n #{data}"
  response = Request.client_service_post url, :ohai_data => data
  logger.debug "The response for the request is #{response} #{response.class}"
  raise JCouldNotPostClientDataException.new({:message=> "Could not post data to the gaddygaddy service, error code is #{response.body}"}) unless response[:status].to_i == 0
end