smart_proxy_pulp 1.6.0 → 2.0.0

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
  SHA256:
3
- metadata.gz: b877e4d04354d2589c3a051e4723da0e9ab3a1d8e16ff2a27623b250631df05f
4
- data.tar.gz: a922da7e9d0981d1a5f90c2a26d81d7d609c25c82f4ffdf1e666ecf92b5eca33
3
+ metadata.gz: 505ec0472b43a70f2f6c3c27da3586c0d8880665dfec8de14e38f4b5fe61a66c
4
+ data.tar.gz: 42ca3476e031944a1968e104bc6eee31d8df914c6174c09901964063fa62acfe
5
5
  SHA512:
6
- metadata.gz: c9356b22cb7f402569342d7fdd3f420af829b0e1fb329b60800f7cb1df0502840c71b596d845491fa21855de88b7094fb92e00e62f053640a4d14ee5b86b51c3
7
- data.tar.gz: '095e9ae318f742a89a286beac7167e8d699b874f9adae6846947164c7e5ed6f1c02832c7bf69ea1caded394300d4be0b83aa62771ff8e3ecd0f4e7dd69a3f76a'
6
+ metadata.gz: 0a83d77270955785b69d3d777b86a089b632c32561eb7072a24e3fcafee382595a438fa6ff6e160f8e358f1d223f3cae98d0772e94272d181fdbe8fcb6031a90
7
+ data.tar.gz: 874d123e511b960abdd7da9cd70b9a2a743bfcb91173f8b5cf5382f780917f1fdbf3a4f7e740259eb0a874699384d94fb6a09b43e57952ee18e3c63cdb8a9023
@@ -1,4 +1,4 @@
1
1
  require 'smart_proxy_pulp_plugin/version'
2
2
  require 'smart_proxy_pulp_plugin/pulp_plugin'
3
3
  require 'smart_proxy_pulp_plugin/pulp_node_plugin'
4
- require 'smart_proxy_pulp_plugin/pulp3_plugin'
4
+ require 'smart_proxy_pulp_plugin/pulpcore_plugin'
@@ -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 Pulp3Client
8
+ class PulpcoreClient
9
9
  def self.get(path)
10
- uri = URI.parse(::PulpProxy::Pulp3Plugin.settings.pulp_url.to_s)
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::Pulp3Plugin.settings.pulp_url.to_s)
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
@@ -0,0 +1,5 @@
1
+ require 'smart_proxy_pulp_plugin/pulpcore_api'
2
+
3
+ map "/pulpcore" do
4
+ run PulpProxy::PulpcoreApi
5
+ end
@@ -1,12 +1,10 @@
1
1
  require 'smart_proxy_pulp_plugin/validators/pulp_url_validator'
2
2
 
3
3
  module PulpProxy
4
- class Pulp3Plugin < ::Proxy::Plugin
5
- plugin "pulp3", ::PulpProxy::VERSION
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
- Pulp3Client.capabilities
18
+ PulpcoreClient.capabilities
21
19
  end)
22
- http_rackup_path File.expand_path("pulp3_http_config.ru", File.expand_path("../", __FILE__))
23
- https_rackup_path File.expand_path("pulp3_http_config.ru", File.expand_path("../", __FILE__))
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
@@ -1,3 +1,3 @@
1
1
  module PulpProxy
2
- VERSION = "1.6.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -2,6 +2,4 @@
2
2
  :enabled: true
3
3
  #:pulp_url: https://localhost/
4
4
  #:content_app_url: https://localhost:24816/
5
- #:pulp_dir: /var/lib/pulp
6
- #:pulp_content_dir: /var/lib/pulp/content
7
5
  #:mirror: false
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: 1.6.0
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-06 00:00:00.000000000 Z
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/pulp3.yml.example
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
@@ -1,5 +0,0 @@
1
- require 'smart_proxy_pulp_plugin/pulp3_api'
2
-
3
- map "/pulp3" do
4
- run PulpProxy::Pulp3Api
5
- end