Class: SmartProxyDynflowCore::Callback::Request
- Inherits:
-
Object
- Object
- SmartProxyDynflowCore::Callback::Request
- Defined in:
- lib/smart_proxy_dynflow_core/callback.rb
Class Method Summary collapse
- .send_to_foreman_tasks(callback_info, data) ⇒ Object
-
.ssl_options ⇒ Object
rubocop:disable Metrics/PerceivedComplexity.
Instance Method Summary collapse
Class Method Details
.send_to_foreman_tasks(callback_info, data) ⇒ Object
14 15 16 |
# File 'lib/smart_proxy_dynflow_core/callback.rb', line 14 def send_to_foreman_tasks(callback_info, data) self.new.callback(prepare_payload(callback_info, data)) end |
.ssl_options ⇒ Object
rubocop:disable Metrics/PerceivedComplexity
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/smart_proxy_dynflow_core/callback.rb', line 19 def return if defined? = {} settings = Settings.instance return unless URI.parse(settings.foreman_url).scheme == 'https' [:verify_ssl] = OpenSSL::SSL::VERIFY_PEER private_key_file = settings.foreman_ssl_key || settings.ssl_private_key if private_key_file private_key = File.read(private_key_file) [:ssl_client_key] = OpenSSL::PKey::RSA.new(private_key) end certificate_file = settings.foreman_ssl_cert || settings.ssl_certificate if certificate_file certificate = File.read(certificate_file) [:ssl_client_cert] = OpenSSL::X509::Certificate.new(certificate) end ca_file = settings.foreman_ssl_ca || settings.ssl_ca_file [:ssl_ca_file] = ca_file if ca_file end |
Instance Method Details
#callback(payload) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/smart_proxy_dynflow_core/callback.rb', line 50 def callback(payload) response = callback_resource.post(payload, :content_type => :json) if response.code.to_s != "200" raise "Failed performing callback to Foreman server: #{response.code} #{response.body}" end response end |