smart_proxy_discovery 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02de287c3c81909a6ebf627361f303b21874c998
|
4
|
+
data.tar.gz: 59d4362be288a33f18c22e9bc405337d8496a28a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66859faacc3d6882164d4ce185bb74e8f69d2737cd24f4e5bde00451491d7199ac3086781c2fb6025bea5949358780accd0bd0518d2934543cf61d3f2dbbe304
|
7
|
+
data.tar.gz: cd79673ed414988fb9f06d5a9082bdf49c7720528affbe68838064708bc7d2310021b5597c723c27d01f9ff4003e4b388d6e2b262a8f48595170046d8a4e37f5
|
@@ -6,5 +6,6 @@ module Proxy::Discovery
|
|
6
6
|
|
7
7
|
http_rackup_path File.expand_path('http_config.ru', File.expand_path('../', __FILE__))
|
8
8
|
https_rackup_path File.expand_path('http_config.ru', File.expand_path('../', __FILE__))
|
9
|
+
default_settings :node_scheme => 'https', :node_port => 8443
|
9
10
|
end
|
10
11
|
end
|
@@ -19,7 +19,11 @@ module Proxy::Discovery
|
|
19
19
|
module ApiHelpers
|
20
20
|
def error_responder(error)
|
21
21
|
error_code = error.respond_to?(:http_code) ? error.http_code : 500
|
22
|
-
|
22
|
+
if error.respond_to?(:http_code) && error.respond_to?(:http_body)
|
23
|
+
log_halt(error_code, "Proxy error HTTP #{error.http_code} (#{error.message}): #{error.http_body})")
|
24
|
+
else
|
25
|
+
log_halt(error_code, error)
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
@@ -45,16 +49,25 @@ module Proxy::Discovery
|
|
45
49
|
include ApiHelpers
|
46
50
|
authorize_with_trusted_hosts
|
47
51
|
|
52
|
+
get '/:ip/inventory/facter' do
|
53
|
+
content_type :json
|
54
|
+
begin
|
55
|
+
Proxy::Discovery.inventory_facter(params[:ip])
|
56
|
+
rescue => error
|
57
|
+
error_responder(error)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
48
61
|
get '/:ip/facts' do
|
49
62
|
content_type :json
|
50
63
|
begin
|
51
|
-
Proxy::Discovery.
|
64
|
+
Proxy::Discovery.refresh_facts_legacy(params[:ip])
|
52
65
|
rescue => error
|
53
66
|
error_responder(error)
|
54
67
|
end
|
55
68
|
end
|
56
69
|
|
57
|
-
put '/:ip/reboot' do
|
70
|
+
put '/:ip/power/reboot' do
|
58
71
|
content_type :json
|
59
72
|
begin
|
60
73
|
Proxy::Discovery.reboot(params[:ip])
|
@@ -62,5 +75,23 @@ module Proxy::Discovery
|
|
62
75
|
error_responder(error)
|
63
76
|
end
|
64
77
|
end
|
78
|
+
|
79
|
+
put '/:ip/power/kexec' do
|
80
|
+
content_type :json
|
81
|
+
begin
|
82
|
+
Proxy::Discovery.kexec(params[:ip], request.body.read)
|
83
|
+
rescue => error
|
84
|
+
error_responder(error)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
put '/:ip/reboot' do
|
89
|
+
content_type :json
|
90
|
+
begin
|
91
|
+
Proxy::Discovery.reboot_legacy(params[:ip])
|
92
|
+
rescue => error
|
93
|
+
error_responder(error)
|
94
|
+
end
|
95
|
+
end
|
65
96
|
end
|
66
97
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rest-client'
|
2
2
|
require 'proxy/request'
|
3
|
+
require 'json'
|
3
4
|
|
4
5
|
module Proxy::Discovery
|
5
6
|
extend ::Proxy::Util
|
@@ -7,32 +8,52 @@ module Proxy::Discovery
|
|
7
8
|
|
8
9
|
class << self
|
9
10
|
CREATE_DISCOVERED_HOST_PATH = '/api/v2/discovered_hosts/facts'
|
10
|
-
|
11
|
+
SCHEME = Proxy::Discovery::Plugin.settings.node_scheme
|
12
|
+
PORT = Proxy::Discovery::Plugin.settings.node_port
|
11
13
|
|
12
14
|
def create_discovered_host(request)
|
13
15
|
foreman_request = Proxy::HttpRequest::ForemanRequest.new()
|
14
16
|
req = foreman_request.request_factory.create_post(CREATE_DISCOVERED_HOST_PATH, request.body.read)
|
15
17
|
response = foreman_request.send_request(req)
|
16
18
|
unless response.is_a? Net::HTTPSuccess
|
17
|
-
|
19
|
+
msg = JSON.parse(response.body)['message'] rescue "N/A"
|
20
|
+
raise "Discovery failed, code #{response.code}, reason: #{msg}"
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
21
|
-
def
|
22
|
-
|
23
|
-
client
|
24
|
-
client[REFRESH_HOST_PATH].get
|
24
|
+
def inventory_facter(ip)
|
25
|
+
client = get_rest_client(generate_url(ip))
|
26
|
+
client["/inventory/facter"].get()
|
25
27
|
end
|
26
28
|
|
27
|
-
def
|
29
|
+
def refresh_facts_legacy(ip)
|
30
|
+
client = get_rest_client(generate_url(ip))
|
31
|
+
client['/facts'].get
|
32
|
+
end
|
33
|
+
|
34
|
+
def reboot_legacy(ip)
|
28
35
|
url = "http://#{ip}:8443"
|
29
36
|
reboot_path = "/bmc/#{ip}/chassis/power/cycle"
|
30
37
|
client = get_rest_client(url)
|
31
38
|
client[reboot_path].put({})
|
32
39
|
end
|
33
40
|
|
41
|
+
def reboot(ip)
|
42
|
+
client = get_rest_client(generate_url(ip))
|
43
|
+
client["/power/reboot"].put({})
|
44
|
+
end
|
45
|
+
|
46
|
+
def kexec(ip, body)
|
47
|
+
client = get_rest_client(generate_url(ip))
|
48
|
+
client["/power/kexec"].put(body)
|
49
|
+
end
|
50
|
+
|
34
51
|
private
|
35
52
|
|
53
|
+
def generate_url(ip)
|
54
|
+
"#{SCHEME}://#{ip}:#{PORT}"
|
55
|
+
end
|
56
|
+
|
36
57
|
def get_rest_client(url)
|
37
58
|
RestClient::Resource.new(url, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
|
38
59
|
end
|
metadata
CHANGED
@@ -1,89 +1,103 @@
|
|
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.3
|
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-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - <
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - <
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rack-test
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - '>='
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- -
|
52
|
+
- - '>='
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: mocha
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - '>='
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - '>='
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: webmock
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - '>='
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - '>='
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rest-client
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - '>'
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: 1.6.2
|
76
|
-
- -
|
90
|
+
- - <
|
77
91
|
- !ruby/object:Gem::Version
|
78
92
|
version: '1.7'
|
79
93
|
type: :runtime
|
80
94
|
prerelease: false
|
81
95
|
version_requirements: !ruby/object:Gem::Requirement
|
82
96
|
requirements:
|
83
|
-
- -
|
97
|
+
- - '>'
|
84
98
|
- !ruby/object:Gem::Version
|
85
99
|
version: 1.6.2
|
86
|
-
- -
|
100
|
+
- - <
|
87
101
|
- !ruby/object:Gem::Version
|
88
102
|
version: '1.7'
|
89
103
|
description: Smart proxy discovery plugin
|
@@ -94,16 +108,16 @@ extra_rdoc_files:
|
|
94
108
|
- README.md
|
95
109
|
- LICENSE
|
96
110
|
files:
|
97
|
-
- LICENSE
|
98
|
-
- README.md
|
99
|
-
- bundler.d/discovery.rb
|
100
|
-
- lib/smart_proxy_discovery.rb
|
101
|
-
- lib/smart_proxy_discovery/discovery.rb
|
102
111
|
- lib/smart_proxy_discovery/discovery_api.rb
|
103
|
-
- lib/smart_proxy_discovery/discovery_main.rb
|
104
112
|
- lib/smart_proxy_discovery/http_config.ru
|
113
|
+
- lib/smart_proxy_discovery/discovery.rb
|
114
|
+
- lib/smart_proxy_discovery/discovery_main.rb
|
105
115
|
- lib/smart_proxy_discovery/version.rb
|
116
|
+
- lib/smart_proxy_discovery.rb
|
106
117
|
- settings.d/discovery.yml.example
|
118
|
+
- bundler.d/discovery.rb
|
119
|
+
- README.md
|
120
|
+
- LICENSE
|
107
121
|
homepage: http://github.com/theforeman/smart_proxy_discovery
|
108
122
|
licenses:
|
109
123
|
- GPLv3
|
@@ -114,17 +128,17 @@ require_paths:
|
|
114
128
|
- lib
|
115
129
|
required_ruby_version: !ruby/object:Gem::Requirement
|
116
130
|
requirements:
|
117
|
-
- -
|
131
|
+
- - '>='
|
118
132
|
- !ruby/object:Gem::Version
|
119
133
|
version: '0'
|
120
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- -
|
136
|
+
- - '>='
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
125
139
|
requirements: []
|
126
140
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
141
|
+
rubygems_version: 2.0.14
|
128
142
|
signing_key:
|
129
143
|
specification_version: 4
|
130
144
|
summary: Smart proxy discovery plugin
|