smart_proxy_pulp 1.6.0 → 2.0.0
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 +4 -4
- data/lib/smart_proxy_pulp.rb +1 -1
- data/lib/smart_proxy_pulp_plugin/pulpcore_api.rb +20 -0
- data/lib/smart_proxy_pulp_plugin/{pulp3_client.rb → pulpcore_client.rb} +3 -3
- data/lib/smart_proxy_pulp_plugin/pulpcore_http_config.ru +5 -0
- data/lib/smart_proxy_pulp_plugin/{pulp3_plugin.rb → pulpcore_plugin.rb} +5 -7
- data/lib/smart_proxy_pulp_plugin/version.rb +1 -1
- data/settings.d/{pulp3.yml.example → pulpcore.yml.example} +0 -2
- metadata +7 -7
- data/lib/smart_proxy_pulp_plugin/pulp3_api.rb +0 -38
- data/lib/smart_proxy_pulp_plugin/pulp3_http_config.ru +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 505ec0472b43a70f2f6c3c27da3586c0d8880665dfec8de14e38f4b5fe61a66c
|
4
|
+
data.tar.gz: 42ca3476e031944a1968e104bc6eee31d8df914c6174c09901964063fa62acfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a83d77270955785b69d3d777b86a089b632c32561eb7072a24e3fcafee382595a438fa6ff6e160f8e358f1d223f3cae98d0772e94272d181fdbe8fcb6031a90
|
7
|
+
data.tar.gz: 874d123e511b960abdd7da9cd70b9a2a743bfcb91173f8b5cf5382f780917f1fdbf3a4f7e740259eb0a874699384d94fb6a09b43e57952ee18e3c63cdb8a9023
|
data/lib/smart_proxy_pulp.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'smart_proxy_pulp_plugin/pulpcore_client'
|
3
|
+
require 'smart_proxy_pulp_plugin/disk_usage'
|
4
|
+
|
5
|
+
module PulpProxy
|
6
|
+
class PulpcoreApi < Sinatra::Base
|
7
|
+
helpers ::Proxy::Helpers
|
8
|
+
|
9
|
+
get '/status' do
|
10
|
+
content_type :json
|
11
|
+
begin
|
12
|
+
result = PulpcoreClient.get("/pulp/api/v3/status/")
|
13
|
+
return result.body if result.is_a?(Net::HTTPSuccess)
|
14
|
+
log_halt result.code, "Pulp server at #{::PulpProxy::Settings.settings.pulp_url} returned an error: '#{result.message}'"
|
15
|
+
rescue SocketError, Errno::ECONNREFUSED => e
|
16
|
+
log_halt 503, "Communication error with '#{URI.parse(::PulpProxy::Settings.settings.pulp_url.to_s).host}': #{e.message}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -5,9 +5,9 @@ require 'smart_proxy_pulp_plugin/settings'
|
|
5
5
|
require 'proxy/log'
|
6
6
|
|
7
7
|
module PulpProxy
|
8
|
-
class
|
8
|
+
class PulpcoreClient
|
9
9
|
def self.get(path)
|
10
|
-
uri = URI.parse(::PulpProxy::
|
10
|
+
uri = URI.parse(::PulpProxy::PulpcorePlugin.settings.pulp_url.to_s)
|
11
11
|
req = Net::HTTP::Get.new(URI.join(uri.to_s.chomp('/') + '/', path))
|
12
12
|
req.add_field('Accept', 'application/json')
|
13
13
|
self.http.request(req)
|
@@ -26,7 +26,7 @@ module PulpProxy
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.http
|
29
|
-
uri = URI.parse(::PulpProxy::
|
29
|
+
uri = URI.parse(::PulpProxy::PulpcorePlugin.settings.pulp_url.to_s)
|
30
30
|
http = Net::HTTP.new(uri.host, uri.port)
|
31
31
|
http.use_ssl = uri.scheme == 'https'
|
32
32
|
http
|
@@ -1,12 +1,10 @@
|
|
1
1
|
require 'smart_proxy_pulp_plugin/validators/pulp_url_validator'
|
2
2
|
|
3
3
|
module PulpProxy
|
4
|
-
class
|
5
|
-
plugin "
|
4
|
+
class PulpcorePlugin < ::Proxy::Plugin
|
5
|
+
plugin "pulpcore", ::PulpProxy::VERSION
|
6
6
|
default_settings :pulp_url => 'https://localhost',
|
7
7
|
:content_app_url => 'https://localhost:24816/',
|
8
|
-
:pulp_dir => '/var/lib/pulp',
|
9
|
-
:pulp_content_dir => '/var/lib/pulp/content',
|
10
8
|
:mirror => false
|
11
9
|
|
12
10
|
load_validators :url => ::PulpProxy::Validators::PulpUrlValidator
|
@@ -17,9 +15,9 @@ module PulpProxy
|
|
17
15
|
expose_setting :mirror
|
18
16
|
expose_setting :content_app_url
|
19
17
|
capability( lambda do ||
|
20
|
-
|
18
|
+
PulpcoreClient.capabilities
|
21
19
|
end)
|
22
|
-
http_rackup_path File.expand_path("
|
23
|
-
https_rackup_path File.expand_path("
|
20
|
+
http_rackup_path File.expand_path("pulpcore_http_config.ru", File.expand_path("../", __FILE__))
|
21
|
+
https_rackup_path File.expand_path("pulpcore_http_config.ru", File.expand_path("../", __FILE__))
|
24
22
|
end
|
25
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_pulp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitri Dolguikh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -92,21 +92,21 @@ files:
|
|
92
92
|
- bundler.d/pulp.rb
|
93
93
|
- lib/smart_proxy_pulp.rb
|
94
94
|
- lib/smart_proxy_pulp_plugin/disk_usage.rb
|
95
|
-
- lib/smart_proxy_pulp_plugin/pulp3_api.rb
|
96
|
-
- lib/smart_proxy_pulp_plugin/pulp3_client.rb
|
97
|
-
- lib/smart_proxy_pulp_plugin/pulp3_http_config.ru
|
98
|
-
- lib/smart_proxy_pulp_plugin/pulp3_plugin.rb
|
99
95
|
- lib/smart_proxy_pulp_plugin/pulp_api.rb
|
100
96
|
- lib/smart_proxy_pulp_plugin/pulp_client.rb
|
101
97
|
- lib/smart_proxy_pulp_plugin/pulp_http_config.ru
|
102
98
|
- lib/smart_proxy_pulp_plugin/pulp_node_http_config.ru
|
103
99
|
- lib/smart_proxy_pulp_plugin/pulp_node_plugin.rb
|
104
100
|
- lib/smart_proxy_pulp_plugin/pulp_plugin.rb
|
101
|
+
- lib/smart_proxy_pulp_plugin/pulpcore_api.rb
|
102
|
+
- lib/smart_proxy_pulp_plugin/pulpcore_client.rb
|
103
|
+
- lib/smart_proxy_pulp_plugin/pulpcore_http_config.ru
|
104
|
+
- lib/smart_proxy_pulp_plugin/pulpcore_plugin.rb
|
105
105
|
- lib/smart_proxy_pulp_plugin/settings.rb
|
106
106
|
- lib/smart_proxy_pulp_plugin/validators/pulp_url_validator.rb
|
107
107
|
- lib/smart_proxy_pulp_plugin/version.rb
|
108
108
|
- settings.d/pulp.yml.example
|
109
|
-
- settings.d/
|
109
|
+
- settings.d/pulpcore.yml.example
|
110
110
|
- settings.d/pulpnode.yml.example
|
111
111
|
homepage: https://github.com/theforeman/smart-proxy-pulp-plugin
|
112
112
|
licenses:
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'sinatra'
|
2
|
-
require 'smart_proxy_pulp_plugin/pulp3_client'
|
3
|
-
require 'smart_proxy_pulp_plugin/disk_usage'
|
4
|
-
|
5
|
-
module PulpProxy
|
6
|
-
class Pulp3Api < Sinatra::Base
|
7
|
-
helpers ::Proxy::Helpers
|
8
|
-
|
9
|
-
get '/status' do
|
10
|
-
content_type :json
|
11
|
-
begin
|
12
|
-
result = Pulp3Client.get("/pulp/api/v3/status/")
|
13
|
-
return result.body if result.is_a?(Net::HTTPSuccess)
|
14
|
-
log_halt result.code, "Pulp server at #{::PulpProxy::Settings.settings.pulp_url} returned an error: '#{result.message}'"
|
15
|
-
rescue SocketError, Errno::ECONNREFUSED => e
|
16
|
-
log_halt 503, "Communication error with '#{URI.parse(::PulpProxy::Settings.settings.pulp_url.to_s).host}': #{e.message}"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
get '/status/disk_usage' do
|
21
|
-
content_type :json
|
22
|
-
if params[:size]
|
23
|
-
size = params[:size] ? params[:size].to_sym : nil
|
24
|
-
log_halt 400, "size parameter must be of: #{DiskUsage::SIZE.keys.join(',')}" unless DiskUsage::SIZE.include?(size)
|
25
|
-
else
|
26
|
-
size = :byte
|
27
|
-
end
|
28
|
-
|
29
|
-
monitor_dirs = Hash[::PulpProxy::Pulp3Plugin.settings.marshal_dump.select { |key, _| key == :pulp_dir || key == :pulp_content_dir }]
|
30
|
-
begin
|
31
|
-
pulp_disk = DiskUsage.new({:path => monitor_dirs, :size => size.to_sym})
|
32
|
-
pulp_disk.to_json
|
33
|
-
rescue ::Proxy::Error::ConfigurationError
|
34
|
-
log_halt 500, 'Could not find df command to evaluate disk space'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|