Class: Proxy::Dynflow::Callback::Request
- Inherits:
-
Object
- Object
- Proxy::Dynflow::Callback::Request
- Defined in:
- lib/smart_proxy_dynflow/callback.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.send_to_foreman_tasks(callback_info, data) ⇒ Object
7 8 9 |
# File 'lib/smart_proxy_dynflow/callback.rb', line 7 def send_to_foreman_tasks(callback_info, data) self.new.callback(prepare_payload(callback_info, data)) end |
.ssl_options ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/smart_proxy_dynflow/callback.rb', line 11 def return @ssl_options if defined? @ssl_options @ssl_options = {} settings = Proxy::SETTINGS return @ssl_options unless URI.parse(settings.foreman_url).scheme == 'https' @ssl_options[: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_options[: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_options[:ssl_client_cert] = OpenSSL::X509::Certificate.new(certificate) end ca_file = settings.foreman_ssl_ca || settings.ssl_ca_file @ssl_options[:ssl_ca_file] = ca_file if ca_file @ssl_options end |
Instance Method Details
#callback(payload) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/smart_proxy_dynflow/callback.rb', line 42 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 |