smart_proxy_discovery 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7ba59c0ad52b0cd69c9ab51fdfe85d833dd624e
|
4
|
+
data.tar.gz: 849a4f4ae8f9de1092d5e96569a358c7d49c67e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b780662313b5efcd778a3d203e396294806a93aa68a681cc56217564c847bf65ba3de69c8990a57374573d068d4bba8bc6ee4f8a264cdaa4d35054b4f0c11faf
|
7
|
+
data.tar.gz: e266f8c9cfb8ea229de42a39db7d5865403998af0d085fa1c6132f8c0dffbb029da62df69582b9f2dedfbd9a49d503df5db0d06fe5a9cde29fb07e9048b0b152
|
@@ -4,9 +4,29 @@ require 'smart_proxy_discovery/discovery_main'
|
|
4
4
|
|
5
5
|
module Proxy::Discovery
|
6
6
|
|
7
|
-
|
7
|
+
# This plugin has two separate Sinatra applications with different contexts
|
8
|
+
# (authorization helpers). Inbound communication is unauthorized,
|
9
|
+
class Dispatcher
|
10
|
+
def call(env)
|
11
|
+
if env['PATH_INFO'] == '/create'
|
12
|
+
InboundApi.new.call(env)
|
13
|
+
else
|
14
|
+
OutboundApi.new.call(env)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module ApiHelpers
|
20
|
+
def error_responder(error)
|
21
|
+
error_code = error.respond_to?(:http_code) ? error.http_code : 500
|
22
|
+
log_halt(error_code, "failed to update Foreman: #{error}")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Inbound communication: Discovered Host -> Proxy Plugin -> Foreman
|
27
|
+
class InboundApi < ::Sinatra::Base
|
8
28
|
helpers ::Proxy::Helpers
|
9
|
-
|
29
|
+
include ApiHelpers
|
10
30
|
|
11
31
|
post '/create' do
|
12
32
|
content_type :json
|
@@ -17,6 +37,14 @@ module Proxy::Discovery
|
|
17
37
|
end
|
18
38
|
end
|
19
39
|
|
40
|
+
end
|
41
|
+
|
42
|
+
# Outbound communication: Foreman -> Proxy Plugin -> Discovered Host
|
43
|
+
class OutboundApi < ::Sinatra::Base
|
44
|
+
helpers ::Proxy::Helpers
|
45
|
+
include ApiHelpers
|
46
|
+
authorize_with_trusted_hosts
|
47
|
+
|
20
48
|
get '/:ip/facts' do
|
21
49
|
content_type :json
|
22
50
|
begin
|
@@ -34,12 +62,5 @@ module Proxy::Discovery
|
|
34
62
|
error_responder(error)
|
35
63
|
end
|
36
64
|
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def error_responder(error)
|
41
|
-
error_code = error.respond_to?(:http_code) ? error.http_code : 500
|
42
|
-
log_halt(error_code, "failed to update Foreman: #{error}")
|
43
|
-
end
|
44
65
|
end
|
45
66
|
end
|
@@ -11,8 +11,11 @@ module Proxy::Discovery
|
|
11
11
|
|
12
12
|
def create_discovered_host(request)
|
13
13
|
foreman_request = Proxy::HttpRequest::ForemanRequest.new()
|
14
|
-
req = foreman_request.request_factory.create_post(CREATE_DISCOVERED_HOST_PATH, request.body)
|
15
|
-
foreman_request.send_request(req)
|
14
|
+
req = foreman_request.request_factory.create_post(CREATE_DISCOVERED_HOST_PATH, request.body.read)
|
15
|
+
response = foreman_request.send_request(req)
|
16
|
+
unless response.is_a? Net::HTTPSuccess
|
17
|
+
raise response
|
18
|
+
end
|
16
19
|
end
|
17
20
|
|
18
21
|
def refresh_facts(ip)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_discovery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shlomi Zadok
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -70,16 +70,22 @@ dependencies:
|
|
70
70
|
name: rest-client
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.6.2
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '1.7'
|
76
79
|
type: :runtime
|
77
80
|
prerelease: false
|
78
81
|
version_requirements: !ruby/object:Gem::Requirement
|
79
82
|
requirements:
|
80
|
-
- - "
|
83
|
+
- - ">"
|
81
84
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
85
|
+
version: 1.6.2
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.7'
|
83
89
|
description: Smart proxy discovery plugin
|
84
90
|
email: szadok@redhat.com
|
85
91
|
executables: []
|