Class: Proxy::Omaha::OmahaProtocol::Handler
- Inherits:
-
Object
- Object
- Proxy::Omaha::OmahaProtocol::Handler
- Includes:
- Log
- Defined in:
- lib/smart_proxy_omaha/omaha_protocol/handler.rb
Instance Attribute Summary collapse
-
#foreman_client ⇒ Object
readonly
Returns the value of attribute foreman_client.
-
#metadata_provider ⇒ Object
readonly
Returns the value of attribute metadata_provider.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #handle ⇒ Object
-
#initialize(options = {}) ⇒ Handler
constructor
A new instance of Handler.
Constructor Details
#initialize(options = {}) ⇒ Handler
Returns a new instance of Handler.
8 9 10 11 12 13 |
# File 'lib/smart_proxy_omaha/omaha_protocol/handler.rb', line 8 def initialize( = {}) @request = .fetch(:request) @foreman_client = .fetch(:foreman_client) @repository = .fetch(:repository) @metadata_provider = .fetch(:metadata_provider) end |
Instance Attribute Details
#foreman_client ⇒ Object (readonly)
Returns the value of attribute foreman_client.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/handler.rb', line 6 def foreman_client @foreman_client end |
#metadata_provider ⇒ Object (readonly)
Returns the value of attribute metadata_provider.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/handler.rb', line 6 def @metadata_provider end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/handler.rb', line 6 def repository @repository end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/smart_proxy_omaha/omaha_protocol/handler.rb', line 6 def request @request end |
Instance Method Details
#handle ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/smart_proxy_omaha/omaha_protocol/handler.rb', line 15 def handle logger.info "OmahaHandler: Received #{request.event_description} event with result: #{request.event_result}" unless request.from_coreos? logger.error "Appid does not match CoreOS. Aborting Omaha request." return Proxy::Omaha::OmahaProtocol::Eventacknowledgeresponse.new( :appid => request.appid, :base_url => request.base_url, :status => 'error-unknownApplication' ) end unless Proxy::Omaha::Track.valid?(request.track) logger.error "Unknown track requested. Aborting Omaha request." return Proxy::Omaha::OmahaProtocol::Eventacknowledgeresponse.new( :appid => request.appid, :base_url => request.base_url, :status => 'error-unknownApplication' ) end upload_facts process_report if request.event? if request.updatecheck? handle_update elsif request.event? handle_event elsif request.ping? handle_ping else logger.info "OmahaHandler: Unknown request." handle_error end rescue StandardError => e logger.error("OmahaHandler: Aw, Snap! Error: #{e}", e.backtrace) handle_error end |