Class: DeviceInfo
- Inherits:
-
Object
- Object
- DeviceInfo
- Extended by:
- Logging
- Includes:
- Logging
- Defined in:
- lib/device_info/device_info.rb
Instance Method Summary collapse
-
#data ⇒ Object
Get the device data, if the data does not exist get it from Ohai.
-
#get_ohai_data ⇒ Object
Get data about the client by using the Ohai component developed by Opscode.
- #gg_config ⇒ Object
-
#host ⇒ Object
Give the host name set previous.
-
#initialize(host, gg_config) ⇒ DeviceInfo
constructor
A new instance of DeviceInfo.
-
#post ⇒ Object
Will post the device data to the client service.
Methods included from Logging
create_logger, logger, logger, set_log_conf, set_log_file, set_log_level
Constructor Details
#initialize(host, gg_config) ⇒ DeviceInfo
Returns a new instance of DeviceInfo.
24 25 26 27 |
# File 'lib/device_info/device_info.rb', line 24 def initialize(host, gg_config) @host = host @gg_config = gg_config end |
Instance Method Details
#data ⇒ Object
Get the device data, if the data does not exist get it from Ohai
47 48 49 |
# File 'lib/device_info/device_info.rb', line 47 def data @data||=get_ohai_data end |
#get_ohai_data ⇒ Object
Get data about the client by using the Ohai component developed by Opscode
39 40 41 42 43 44 |
# 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 ⇒ Object
34 35 36 |
# File 'lib/device_info/device_info.rb', line 34 def gg_config @gg_config end |
#host ⇒ Object
Give the host name set previous
30 31 32 |
# File 'lib/device_info/device_info.rb', line 30 def host @host end |
#post ⇒ Object
Will post the device data to the client service
52 53 54 55 56 57 58 |
# 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 |