smart_proxy_pulp 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +21 -2
- data/lib/smart_proxy_pulp.rb +2 -1
- data/lib/smart_proxy_pulp_plugin/disk_usage.rb +1 -1
- data/lib/smart_proxy_pulp_plugin/pulp3_api.rb +38 -0
- data/lib/smart_proxy_pulp_plugin/pulp3_client.rb +35 -0
- data/lib/smart_proxy_pulp_plugin/pulp3_http_config.ru +5 -0
- data/lib/smart_proxy_pulp_plugin/pulp3_plugin.rb +22 -0
- data/lib/smart_proxy_pulp_plugin/pulp_api.rb +3 -1
- data/lib/smart_proxy_pulp_plugin/pulp_client.rb +1 -2
- data/lib/smart_proxy_pulp_plugin/pulp_node_plugin.rb +1 -0
- data/lib/smart_proxy_pulp_plugin/pulp_plugin.rb +2 -0
- data/lib/smart_proxy_pulp_plugin/version.rb +1 -1
- data/settings.d/pulp3.yml.example +7 -0
- metadata +11 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e11236f52109a604b1171429f0d824d2997d1f366af7ddec1c606d3b041cf8ad
|
4
|
+
data.tar.gz: 4f3d157ba4e93fcabbbc846ecec510235f0010c0dd728560e9e83331a06a624f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92005aeed682489ea51bdca541668fca8c2ba453974d99642e13abe1b8e4774b46d2d269c4ec4b37bceb8ff97bdce83b08eeecc9fbeac5508768e2c0da46ea50
|
7
|
+
data.tar.gz: 95c595b02e6006bfc53fa99d3dce666a9274cfc7b61446f3f51202cd1a23c0c783c4776ef0b24b3f575db17bd34f56995b1d29302ef7608df99f3d0a8baffbbf
|
data/Gemfile
CHANGED
@@ -5,5 +5,24 @@ group :development do
|
|
5
5
|
gem 'smart_proxy', :git => 'https://github.com/theforeman/smart-proxy', :branch => 'develop'
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
gem '
|
8
|
+
group :test do
|
9
|
+
gem 'webmock'
|
10
|
+
if RUBY_VERSION < '2.1'
|
11
|
+
gem 'public_suffix', '< 3'
|
12
|
+
else
|
13
|
+
gem 'public_suffix'
|
14
|
+
end
|
15
|
+
if RUBY_VERSION < '2.2'
|
16
|
+
gem 'rack-test', '< 0.8'
|
17
|
+
else
|
18
|
+
gem 'rack-test'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if RUBY_VERSION < '2.2'
|
23
|
+
gem 'sinatra', '< 2'
|
24
|
+
gem 'rack', '>= 1.1', '< 2.0.0'
|
25
|
+
else
|
26
|
+
gem 'sinatra'
|
27
|
+
gem 'rack', '>= 1.1'
|
28
|
+
end
|
data/lib/smart_proxy_pulp.rb
CHANGED
@@ -2,7 +2,7 @@ module PulpProxy
|
|
2
2
|
class DiskUsage
|
3
3
|
include ::Proxy::Util
|
4
4
|
include ::Proxy::Log
|
5
|
-
SIZE = { :kilobyte => 1_024, :megabyte => 1_048_576, :gigabyte => 1_073_741_824, :terabyte => 1_099_511_627_776 }
|
5
|
+
SIZE = { :byte => 1, :kilobyte => 1_024, :megabyte => 1_048_576, :gigabyte => 1_073_741_824, :terabyte => 1_099_511_627_776 }
|
6
6
|
|
7
7
|
attr_reader :path, :stat, :size
|
8
8
|
|
@@ -0,0 +1,38 @@
|
|
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("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
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
require 'uri'
|
4
|
+
require 'smart_proxy_pulp_plugin/settings'
|
5
|
+
require 'proxy/log'
|
6
|
+
|
7
|
+
module PulpProxy
|
8
|
+
class Pulp3Client
|
9
|
+
def self.get(path)
|
10
|
+
uri = URI.parse(::PulpProxy::Pulp3Plugin.settings.pulp_url.to_s)
|
11
|
+
req = Net::HTTP::Get.new(URI.join(uri.to_s.chomp('/') + '/', path))
|
12
|
+
req.add_field('Accept', 'application/json')
|
13
|
+
self.http.request(req)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.capabilities
|
17
|
+
body = JSON.parse(get("api/v3/status/").body)
|
18
|
+
body['versions'].map{|item| item['component'] }
|
19
|
+
rescue => e
|
20
|
+
logger.error("Could not fetch capabilities: #{e.message}")
|
21
|
+
[]
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.logger
|
25
|
+
Proxy::LoggerFactory.logger
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.http
|
29
|
+
uri = URI.parse(::PulpProxy::Pulp3Plugin.settings.pulp_url.to_s)
|
30
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
31
|
+
http.use_ssl = uri.scheme == 'https'
|
32
|
+
http
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'puppet_proxy_common/custom_validators'
|
2
|
+
|
3
|
+
module PulpProxy
|
4
|
+
class Pulp3Plugin < ::Proxy::Plugin
|
5
|
+
plugin "pulp3", ::PulpProxy::VERSION
|
6
|
+
default_settings :pulp_url => 'https://localhost/pulp/',
|
7
|
+
:pulp_dir => '/var/lib/pulp',
|
8
|
+
:pulp_content_dir => '/var/lib/pulp/content',
|
9
|
+
:mirror => false
|
10
|
+
|
11
|
+
load_validators :url => ::Proxy::Puppet::Validators::UrlValidator
|
12
|
+
validate :pulp_url, :url => true
|
13
|
+
|
14
|
+
expose_setting :pulp_url
|
15
|
+
expose_setting :mirror
|
16
|
+
capability( lambda do ||
|
17
|
+
Pulp3Client.capabilities
|
18
|
+
end)
|
19
|
+
http_rackup_path File.expand_path("pulp3_http_config.ru", File.expand_path("../", __FILE__))
|
20
|
+
https_rackup_path File.expand_path("pulp3_http_config.ru", File.expand_path("../", __FILE__))
|
21
|
+
end
|
22
|
+
end
|
@@ -6,11 +6,13 @@ require 'smart_proxy_pulp_plugin/settings'
|
|
6
6
|
module PulpProxy
|
7
7
|
class Api < Sinatra::Base
|
8
8
|
helpers ::Proxy::Helpers
|
9
|
+
authorize_with_trusted_hosts
|
10
|
+
authorize_with_ssl_client
|
9
11
|
|
10
12
|
get "/status" do
|
11
13
|
content_type :json
|
12
14
|
begin
|
13
|
-
result = PulpClient.get("
|
15
|
+
result = PulpClient.get("api/v2/status/")
|
14
16
|
return result.body if result.is_a?(Net::HTTPSuccess)
|
15
17
|
log_halt result.code, "Pulp server at #{::PulpProxy::Settings.settings.pulp_url} returned an error: '#{result.message}'"
|
16
18
|
rescue Errno::ECONNREFUSED => e
|
@@ -7,8 +7,7 @@ module PulpProxy
|
|
7
7
|
class PulpClient
|
8
8
|
def self.get(path)
|
9
9
|
uri = URI.parse(::PulpProxy::Settings.settings.pulp_url.to_s)
|
10
|
-
|
11
|
-
req = Net::HTTP::Get.new(URI.join(uri.to_s, path).path)
|
10
|
+
req = Net::HTTP::Get.new(URI.join(uri.to_s.chomp('/') + '/', path))
|
12
11
|
req.add_field('Accept', 'application/json')
|
13
12
|
req.content_type = 'application/json'
|
14
13
|
response = self.http.request(req)
|
@@ -7,6 +7,7 @@ module PulpNodeProxy
|
|
7
7
|
:puppet_content_dir => '/etc/puppet/environments',
|
8
8
|
:mongodb_dir => '/var/lib/mongodb'
|
9
9
|
|
10
|
+
expose_setting :pulp_url
|
10
11
|
http_rackup_path File.expand_path("pulp_node_http_config.ru", File.expand_path("../", __FILE__))
|
11
12
|
https_rackup_path File.expand_path("pulp_node_http_config.ru", File.expand_path("../", __FILE__))
|
12
13
|
end
|
@@ -7,6 +7,8 @@ module PulpProxy
|
|
7
7
|
:puppet_content_dir => '/etc/puppet/environments',
|
8
8
|
:mongodb_dir => '/var/lib/mongodb'
|
9
9
|
|
10
|
+
expose_setting :pulp_url
|
11
|
+
|
10
12
|
http_rackup_path File.expand_path("pulp_http_config.ru", File.expand_path("../", __FILE__))
|
11
13
|
https_rackup_path File.expand_path("pulp_http_config.ru", File.expand_path("../", __FILE__))
|
12
14
|
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: 1.
|
4
|
+
version: 1.4.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:
|
11
|
+
date: 2019-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
name: rack-test
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
@@ -92,6 +92,10 @@ 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
|
95
99
|
- lib/smart_proxy_pulp_plugin/pulp_api.rb
|
96
100
|
- lib/smart_proxy_pulp_plugin/pulp_client.rb
|
97
101
|
- lib/smart_proxy_pulp_plugin/pulp_http_config.ru
|
@@ -101,10 +105,11 @@ files:
|
|
101
105
|
- lib/smart_proxy_pulp_plugin/settings.rb
|
102
106
|
- lib/smart_proxy_pulp_plugin/version.rb
|
103
107
|
- settings.d/pulp.yml.example
|
108
|
+
- settings.d/pulp3.yml.example
|
104
109
|
- settings.d/pulpnode.yml.example
|
105
110
|
homepage: https://github.com/theforeman/smart-proxy-pulp-plugin
|
106
111
|
licenses:
|
107
|
-
-
|
112
|
+
- GPL-3.0
|
108
113
|
metadata: {}
|
109
114
|
post_install_message:
|
110
115
|
rdoc_options: []
|
@@ -122,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
127
|
version: '0'
|
123
128
|
requirements: []
|
124
129
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.7.6
|
126
131
|
signing_key:
|
127
132
|
specification_version: 4
|
128
133
|
summary: Basic Pulp support for Foreman Smart-Proxy
|