Class: Proxy::Omaha::OmahaProtocol::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_proxy_omaha/omaha_protocol/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options)
  @body = body
  @ip = options.fetch(:ip)
  @base_url = options.fetch(:base_url)
  @distribution = options.fetch(:distribution)
  parse_request
  parse_ipaddress
  raise "Could not determine request hostname." if hostname.nil?
end

Instance Attribute Details

#alephversionObject (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

#appidObject (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_urlObject (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

#boardObject (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

#bodyObject (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

#distributionObject (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

#eventresultObject (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

#eventtypeObject (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

#hostnameObject (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

#ipObject (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

#ipaddressObject (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

#ipaddress6Object (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

#machineidObject (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

#oemObject (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

#oemversionObject (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

#osmajorObject (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

#osminorObject (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

#pingObject (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

#platformObject (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

#trackObject (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

#updatecheckObject (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

#versionObject (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

Returns:

  • (Boolean)


58
59
60
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 58

def event?
  !@event.empty?
end

#event_descriptionObject



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_resultObject



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_dataObject



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

Returns:

  • (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

Returns:

  • (Boolean)


54
55
56
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 54

def ping?
  !@ping.empty?
end

#to_statusObject



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

Returns:

  • (Boolean)


50
51
52
# File 'lib/smart_proxy_omaha/omaha_protocol/request.rb', line 50

def updatecheck?
  !@updatecheck.empty?
end