Class: Proxy::Omaha::OmahaProtocol::Request
- Inherits:
-
Object
- Object
- Proxy::Omaha::OmahaProtocol::Request
- Defined in:
- lib/smart_proxy_omaha/omaha_protocol/request.rb
Instance Attribute Summary collapse
-
#alephversion ⇒ Object
readonly
Returns the value of attribute alephversion.
-
#appid ⇒ Object
readonly
Returns the value of attribute appid.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#board ⇒ Object
readonly
Returns the value of attribute board.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#distribution ⇒ Object
readonly
Returns the value of attribute distribution.
-
#eventresult ⇒ Object
readonly
Returns the value of attribute eventresult.
-
#eventtype ⇒ Object
readonly
Returns the value of attribute eventtype.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#ipaddress ⇒ Object
readonly
Returns the value of attribute ipaddress.
-
#ipaddress6 ⇒ Object
readonly
Returns the value of attribute ipaddress6.
-
#machineid ⇒ Object
readonly
Returns the value of attribute machineid.
-
#oem ⇒ Object
readonly
Returns the value of attribute oem.
-
#oemversion ⇒ Object
readonly
Returns the value of attribute oemversion.
-
#osmajor ⇒ Object
readonly
Returns the value of attribute osmajor.
-
#osminor ⇒ Object
readonly
Returns the value of attribute osminor.
-
#ping ⇒ Object
readonly
Returns the value of attribute ping.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#track ⇒ Object
readonly
Returns the value of attribute track.
-
#updatecheck ⇒ Object
readonly
Returns the value of attribute updatecheck.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #event? ⇒ Boolean
- #event_description ⇒ Object
- #event_result ⇒ Object
- #facts_data ⇒ Object
- #from_coreos? ⇒ Boolean
-
#initialize(body, options) ⇒ Request
constructor
A new instance of Request.
- #ping? ⇒ Boolean
- #to_status ⇒ Object
- #updatecheck? ⇒ Boolean
Constructor Details
#initialize(body, options) ⇒ Request
Returns a new instance of Request.
11 12 13 14 15 16 17 18 19 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 11 def initialize(body, ) @body = body @ip = .fetch(:ip) @base_url = .fetch(:base_url) @distribution = .fetch(:distribution) parse_request parse_ipaddress raise "Could not determine request hostname." if hostname.nil? end |
Instance Attribute Details
#alephversion ⇒ Object (readonly)
Returns the value of attribute alephversion.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def alephversion @alephversion end |
#appid ⇒ Object (readonly)
Returns the value of attribute appid.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def appid @appid end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def base_url @base_url end |
#board ⇒ Object (readonly)
Returns the value of attribute board.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def board @board end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def body @body end |
#distribution ⇒ Object (readonly)
Returns the value of attribute distribution.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def distribution @distribution end |
#eventresult ⇒ Object (readonly)
Returns the value of attribute eventresult.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def eventresult @eventresult end |
#eventtype ⇒ Object (readonly)
Returns the value of attribute eventtype.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def eventtype @eventtype end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def hostname @hostname end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def ip @ip end |
#ipaddress ⇒ Object (readonly)
Returns the value of attribute ipaddress.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def ipaddress @ipaddress end |
#ipaddress6 ⇒ Object (readonly)
Returns the value of attribute ipaddress6.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def ipaddress6 @ipaddress6 end |
#machineid ⇒ Object (readonly)
Returns the value of attribute machineid.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def machineid @machineid end |
#oem ⇒ Object (readonly)
Returns the value of attribute oem.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def oem @oem end |
#oemversion ⇒ Object (readonly)
Returns the value of attribute oemversion.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def oemversion @oemversion end |
#osmajor ⇒ Object (readonly)
Returns the value of attribute osmajor.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def osmajor @osmajor end |
#osminor ⇒ Object (readonly)
Returns the value of attribute osminor.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def osminor @osminor end |
#ping ⇒ Object (readonly)
Returns the value of attribute ping.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def ping @ping end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def platform @platform end |
#track ⇒ Object (readonly)
Returns the value of attribute track.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def track @track end |
#updatecheck ⇒ Object (readonly)
Returns the value of attribute updatecheck.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def updatecheck @updatecheck end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 6 def version @version end |
Instance Method Details
#event? ⇒ Boolean
58 59 60 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 58 def event? !@event.empty? end |
#event_description ⇒ Object
38 39 40 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 38 def event_description Proxy::Omaha::OmahaProtocol.event_description(eventtype) end |
#event_result ⇒ Object
42 43 44 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 42 def event_result Proxy::Omaha::OmahaProtocol.event_result(eventresult) end |
#facts_data ⇒ Object
21 22 23 24 25 26 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 21 def facts_data { :name => hostname, :facts => to_facts.merge({:_type => :foreman_omaha, :_timestamp => Time.now}) } end |
#from_coreos? ⇒ Boolean
46 47 48 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 46 def from_coreos? appid == Proxy::Omaha::OmahaProtocol::COREOS_APPID end |
#ping? ⇒ Boolean
54 55 56 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 54 def ping? !@ping.empty? end |
#to_status ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 28 def to_status return :downloading if eventtype == 13 && eventresult == 1 return :downloaded if eventtype == 14 && eventresult == 1 return :installed if eventtype == 3 && eventresult == 1 return :instance_hold if eventtype == 800 && eventresult == 1 return :complete if eventtype == 3 && eventresult == 2 return :error if eventtype == 3 && eventresult == 0 :unknown end |
#updatecheck? ⇒ Boolean
50 51 52 |
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 50 def updatecheck? !@updatecheck.empty? end |