smart_proxy_pulp 2.1.0 → 3.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/Gemfile +2 -21
- data/lib/smart_proxy_pulp.rb +0 -2
- data/lib/smart_proxy_pulp_plugin/pulpcore_api.rb +2 -3
- data/lib/smart_proxy_pulp_plugin/pulpcore_client.rb +6 -3
- data/lib/smart_proxy_pulp_plugin/pulpcore_plugin.rb +2 -8
- data/lib/smart_proxy_pulp_plugin/version.rb +1 -1
- metadata +14 -25
- data/lib/smart_proxy_pulp_plugin/disk_usage.rb +0 -120
- data/lib/smart_proxy_pulp_plugin/pulp_api.rb +0 -41
- data/lib/smart_proxy_pulp_plugin/pulp_client.rb +0 -36
- data/lib/smart_proxy_pulp_plugin/pulp_http_config.ru +0 -5
- data/lib/smart_proxy_pulp_plugin/pulp_node_http_config.ru +0 -5
- data/lib/smart_proxy_pulp_plugin/pulp_node_plugin.rb +0 -14
- data/lib/smart_proxy_pulp_plugin/pulp_plugin.rb +0 -15
- data/lib/smart_proxy_pulp_plugin/settings.rb +0 -12
- data/lib/smart_proxy_pulp_plugin/validators/pulp_url_validator.rb +0 -12
- data/settings.d/pulp.yml.example +0 -8
- data/settings.d/pulpnode.yml.example +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c62f3048872a9abdf3004d0d7af57b90ea8612e527f335231a0b25c6de22f86c
|
|
4
|
+
data.tar.gz: 6bfa286ef21e1e00139593e88bfe50360de8866e867920bfefeb03eeeb39227d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9f0185c2c5daadd9b4bc360c5c83bb5170de105a2d0767eda9653ce574ba7a7c6abc3bc303e63cc22ec76bacae1509207fc0d93d32e940a2bec184f2677e24c8
|
|
7
|
+
data.tar.gz: 8caebd183fbd1f7cdf8eb715a60d3d48813869414fa02ebecf220cc49d5f9746fd389c647a5cb99d35f4fd8d7a58076ec75f2f0f504d1da104a22f19e5983213
|
data/Gemfile
CHANGED
|
@@ -5,24 +5,5 @@ group :development do
|
|
|
5
5
|
gem 'smart_proxy', :git => 'https://github.com/theforeman/smart-proxy', :branch => 'develop'
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
8
|
+
gem 'sinatra'
|
|
9
|
+
gem 'rack', '>= 1.1'
|
data/lib/smart_proxy_pulp.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
require 'sinatra'
|
|
2
2
|
require 'smart_proxy_pulp_plugin/pulpcore_client'
|
|
3
|
-
require 'smart_proxy_pulp_plugin/disk_usage'
|
|
4
3
|
|
|
5
4
|
module PulpProxy
|
|
6
5
|
class PulpcoreApi < Sinatra::Base
|
|
@@ -11,9 +10,9 @@ module PulpProxy
|
|
|
11
10
|
begin
|
|
12
11
|
result = PulpcoreClient.get("/pulp/api/v3/status/")
|
|
13
12
|
return result.body if result.is_a?(Net::HTTPSuccess)
|
|
14
|
-
log_halt result.code, "Pulp server at #{
|
|
13
|
+
log_halt result.code, "Pulp server at #{PulpcoreClient.pulp_url} returned an error: '#{result.message}'"
|
|
15
14
|
rescue SocketError, Errno::ECONNREFUSED => e
|
|
16
|
-
log_halt 503, "Communication error with '#{URI.parse(
|
|
15
|
+
log_halt 503, "Communication error with '#{URI.parse(PulpcoreClient.pulp_url).host}': #{e.message}"
|
|
17
16
|
end
|
|
18
17
|
end
|
|
19
18
|
end
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
require 'net/http'
|
|
2
2
|
require 'net/https'
|
|
3
3
|
require 'uri'
|
|
4
|
-
require 'smart_proxy_pulp_plugin/settings'
|
|
5
4
|
require 'proxy/log'
|
|
6
5
|
|
|
7
6
|
module PulpProxy
|
|
8
7
|
class PulpcoreClient
|
|
9
8
|
def self.get(path)
|
|
10
|
-
uri = URI.parse(
|
|
9
|
+
uri = URI.parse(pulp_url)
|
|
11
10
|
req = Net::HTTP::Get.new(URI.join(uri.to_s.chomp('/') + '/', path))
|
|
12
11
|
req.add_field('Accept', 'application/json')
|
|
13
12
|
self.http.request(req)
|
|
@@ -26,10 +25,14 @@ module PulpProxy
|
|
|
26
25
|
end
|
|
27
26
|
|
|
28
27
|
def self.http
|
|
29
|
-
uri = URI.parse(
|
|
28
|
+
uri = URI.parse(pulp_url)
|
|
30
29
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
31
30
|
http.use_ssl = uri.scheme == 'https'
|
|
32
31
|
http
|
|
33
32
|
end
|
|
33
|
+
|
|
34
|
+
def self.pulp_url
|
|
35
|
+
::PulpProxy::PulpcorePlugin.settings.pulp_url.to_s
|
|
36
|
+
end
|
|
34
37
|
end
|
|
35
38
|
end
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require 'smart_proxy_pulp_plugin/validators/pulp_url_validator'
|
|
2
|
-
|
|
3
1
|
module PulpProxy
|
|
4
2
|
class PulpcorePlugin < ::Proxy::Plugin
|
|
5
3
|
plugin "pulpcore", ::PulpProxy::VERSION
|
|
@@ -7,7 +5,6 @@ module PulpProxy
|
|
|
7
5
|
:content_app_url => 'https://localhost:24816/',
|
|
8
6
|
:mirror => false
|
|
9
7
|
|
|
10
|
-
load_validators :url => ::PulpProxy::Validators::PulpUrlValidator
|
|
11
8
|
validate :pulp_url, :url => true
|
|
12
9
|
validate :content_app_url, :url => true
|
|
13
10
|
|
|
@@ -16,10 +13,7 @@ module PulpProxy
|
|
|
16
13
|
expose_setting :content_app_url
|
|
17
14
|
expose_setting :username
|
|
18
15
|
expose_setting :password
|
|
19
|
-
capability
|
|
20
|
-
|
|
21
|
-
end)
|
|
22
|
-
http_rackup_path File.expand_path("pulpcore_http_config.ru", File.expand_path("../", __FILE__))
|
|
23
|
-
https_rackup_path File.expand_path("pulpcore_http_config.ru", File.expand_path("../", __FILE__))
|
|
16
|
+
capability -> { PulpcoreClient.capabilities }
|
|
17
|
+
rackup_path File.expand_path('pulpcore_http_config.ru', __dir__)
|
|
24
18
|
end
|
|
25
19
|
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: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitri Dolguikh
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: test-unit
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '3'
|
|
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
|
-
version: '
|
|
26
|
+
version: '3'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: mocha
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -44,14 +44,14 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
47
|
+
version: '3'
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
54
|
+
version: '3'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: rack-test
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -72,14 +72,14 @@ dependencies:
|
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
75
|
+
version: '13'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
82
|
+
version: '13'
|
|
83
83
|
description: " Basic Pulp support for Foreman Smart-Proxy\n"
|
|
84
84
|
email:
|
|
85
85
|
- dmitri@redhat.com
|
|
@@ -91,44 +91,33 @@ files:
|
|
|
91
91
|
- LICENSE
|
|
92
92
|
- bundler.d/pulp.rb
|
|
93
93
|
- lib/smart_proxy_pulp.rb
|
|
94
|
-
- lib/smart_proxy_pulp_plugin/disk_usage.rb
|
|
95
|
-
- lib/smart_proxy_pulp_plugin/pulp_api.rb
|
|
96
|
-
- lib/smart_proxy_pulp_plugin/pulp_client.rb
|
|
97
|
-
- lib/smart_proxy_pulp_plugin/pulp_http_config.ru
|
|
98
|
-
- lib/smart_proxy_pulp_plugin/pulp_node_http_config.ru
|
|
99
|
-
- lib/smart_proxy_pulp_plugin/pulp_node_plugin.rb
|
|
100
|
-
- lib/smart_proxy_pulp_plugin/pulp_plugin.rb
|
|
101
94
|
- lib/smart_proxy_pulp_plugin/pulpcore_api.rb
|
|
102
95
|
- lib/smart_proxy_pulp_plugin/pulpcore_client.rb
|
|
103
96
|
- lib/smart_proxy_pulp_plugin/pulpcore_http_config.ru
|
|
104
97
|
- lib/smart_proxy_pulp_plugin/pulpcore_plugin.rb
|
|
105
|
-
- lib/smart_proxy_pulp_plugin/settings.rb
|
|
106
|
-
- lib/smart_proxy_pulp_plugin/validators/pulp_url_validator.rb
|
|
107
98
|
- lib/smart_proxy_pulp_plugin/version.rb
|
|
108
|
-
- settings.d/pulp.yml.example
|
|
109
99
|
- settings.d/pulpcore.yml.example
|
|
110
|
-
- settings.d/pulpnode.yml.example
|
|
111
100
|
homepage: https://github.com/theforeman/smart-proxy-pulp-plugin
|
|
112
101
|
licenses:
|
|
113
102
|
- GPL-3.0
|
|
114
103
|
metadata: {}
|
|
115
|
-
post_install_message:
|
|
104
|
+
post_install_message:
|
|
116
105
|
rdoc_options: []
|
|
117
106
|
require_paths:
|
|
118
107
|
- lib
|
|
119
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
109
|
requirements:
|
|
121
|
-
- - "
|
|
110
|
+
- - "~>"
|
|
122
111
|
- !ruby/object:Gem::Version
|
|
123
|
-
version: '
|
|
112
|
+
version: '2.5'
|
|
124
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
114
|
requirements:
|
|
126
115
|
- - ">="
|
|
127
116
|
- !ruby/object:Gem::Version
|
|
128
117
|
version: '0'
|
|
129
118
|
requirements: []
|
|
130
|
-
rubygems_version: 3.
|
|
131
|
-
signing_key:
|
|
119
|
+
rubygems_version: 3.1.4
|
|
120
|
+
signing_key:
|
|
132
121
|
specification_version: 4
|
|
133
122
|
summary: Basic Pulp support for Foreman Smart-Proxy
|
|
134
123
|
test_files: []
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
module PulpProxy
|
|
2
|
-
class DiskUsage
|
|
3
|
-
include ::Proxy::Util
|
|
4
|
-
include ::Proxy::Log
|
|
5
|
-
SIZE = { :byte => 1, :kilobyte => 1_024, :megabyte => 1_048_576, :gigabyte => 1_073_741_824, :terabyte => 1_099_511_627_776 }
|
|
6
|
-
|
|
7
|
-
attr_reader :path, :stat, :size
|
|
8
|
-
|
|
9
|
-
def initialize(opts ={})
|
|
10
|
-
raise(::Proxy::Error::ConfigurationError, 'Unable to continue - must provide a path.') if opts[:path].nil?
|
|
11
|
-
@paths_hash = validate_path(path_hash(opts[:path]))
|
|
12
|
-
@path = @paths_hash.values
|
|
13
|
-
@size_format = opts[:size] || :kilobyte
|
|
14
|
-
@size = SIZE[@size_format]
|
|
15
|
-
@stat = {}
|
|
16
|
-
find_df
|
|
17
|
-
get_stat
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def to_json
|
|
21
|
-
stat.to_json
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
attr_reader :command_path
|
|
27
|
-
|
|
28
|
-
def find_df
|
|
29
|
-
@command_path = which('df') || raise(::Proxy::Error::ConfigurationError, 'df command was not found unable to retrieve usage information.')
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def command
|
|
33
|
-
[command_path, "-P", "-B", "#{size}", *path]
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Inspired and copied from Facter
|
|
37
|
-
# @ https://github.com/puppetlabs/facter/blob/2.x/lib/facter/core/execution/base.rb
|
|
38
|
-
# @TODO: Refactor http://projects.theforeman.org/issues/15235 when removing support for 1.8.7
|
|
39
|
-
def with_env(values)
|
|
40
|
-
old = {}
|
|
41
|
-
values.each do |var, value|
|
|
42
|
-
# save the old value if it exists
|
|
43
|
-
if old_val = ENV[var]
|
|
44
|
-
old[var] = old_val
|
|
45
|
-
end
|
|
46
|
-
# set the new (temporary) value for the environment variable
|
|
47
|
-
ENV[var] = value
|
|
48
|
-
end
|
|
49
|
-
# execute the caller's block, capture the return value
|
|
50
|
-
rv = yield
|
|
51
|
-
# use an ensure block to make absolutely sure we restore the variables
|
|
52
|
-
ensure
|
|
53
|
-
# restore the old values
|
|
54
|
-
values.each do |var, value|
|
|
55
|
-
if old.include?(var)
|
|
56
|
-
ENV[var] = old[var]
|
|
57
|
-
else
|
|
58
|
-
# if there was no old value, delete the key from the current environment variables hash
|
|
59
|
-
ENV.delete(var)
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
# return the captured return value
|
|
63
|
-
rv
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def get_stat
|
|
67
|
-
with_env 'LC_ALL' => 'C' do
|
|
68
|
-
raw = Open3::popen3(*command) do |stdin, stdout, stderr, thread|
|
|
69
|
-
unless stderr.read.empty?
|
|
70
|
-
error_line = stderr.read
|
|
71
|
-
logger.error "[#{command_path}] #{error_line}"
|
|
72
|
-
raise(::Proxy::Error::ConfigurationError, "#{command_path} raised an error: #{error_line}")
|
|
73
|
-
end
|
|
74
|
-
stdout.read.split("\n")
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
logger.debug "[#{command_path}] #{raw.to_s}"
|
|
78
|
-
|
|
79
|
-
titles = normalize_titles(raw)
|
|
80
|
-
raw.each_with_index do |line, index|
|
|
81
|
-
mount_path = path[index]
|
|
82
|
-
values = normalize_values(line.split)
|
|
83
|
-
@stat[hash_key_for(mount_path)] = Hash[titles.zip(values)].merge({:path => mount_path, :size => @size_format})
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def path_hash(path)
|
|
89
|
-
path.is_a?(Hash) ? path : Hash[path, path]
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def hash_key_for(path)
|
|
93
|
-
@paths_hash.select { |k,v| v == path}.first[0]
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
def normalize_titles(raw)
|
|
98
|
-
replacers = {"mounted on" => :mounted, "capacity" => :percent, "1024-blocks" => :"1k-blocks" }
|
|
99
|
-
raw.shift.downcase.gsub(/(capacity|mounted on|1024-blocks)/) { |m| replacers.fetch(m,m)}.split.map(&:to_sym)
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def normalize_values(values)
|
|
103
|
-
values.each_with_index do |value, index|
|
|
104
|
-
is_int = Integer(value) rescue false
|
|
105
|
-
values[index] = is_int if is_int
|
|
106
|
-
end
|
|
107
|
-
values
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def validate_path(path_hash)
|
|
111
|
-
path_hash.each do |key, value|
|
|
112
|
-
unless File.readable?(value)
|
|
113
|
-
logger.warn "File at #{value} defined in #{key} parameter doesn't exist or is unreadable"
|
|
114
|
-
path_hash.delete(key)
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
path_hash
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
require 'sinatra'
|
|
2
|
-
require 'smart_proxy_pulp_plugin/pulp_client'
|
|
3
|
-
require 'smart_proxy_pulp_plugin/disk_usage'
|
|
4
|
-
require 'smart_proxy_pulp_plugin/settings'
|
|
5
|
-
|
|
6
|
-
module PulpProxy
|
|
7
|
-
class Api < Sinatra::Base
|
|
8
|
-
helpers ::Proxy::Helpers
|
|
9
|
-
authorize_with_trusted_hosts
|
|
10
|
-
authorize_with_ssl_client
|
|
11
|
-
|
|
12
|
-
get "/status" do
|
|
13
|
-
content_type :json
|
|
14
|
-
begin
|
|
15
|
-
result = PulpClient.get("api/v2/status/")
|
|
16
|
-
return result.body if result.is_a?(Net::HTTPSuccess)
|
|
17
|
-
log_halt result.code, "Pulp server at #{::PulpProxy::Settings.settings.pulp_url} returned an error: '#{result.message}'"
|
|
18
|
-
rescue Errno::ECONNREFUSED => e
|
|
19
|
-
log_halt 503, "Pulp server at #{::PulpProxy::Settings.settings.pulp_url} is not responding"
|
|
20
|
-
rescue SocketError => e
|
|
21
|
-
log_halt 503, "Pulp server '#{URI.parse(::PulpProxy::Settings.settings.pulp_url.to_s).host}' is unknown"
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
get '/status/disk_usage' do
|
|
26
|
-
size = (params[:size] && DiskUsage::SIZE.keys.include?(params[:size].to_sym)) ? params[:size].to_sym : :kilobyte
|
|
27
|
-
monitor_dirs = Hash[::PulpProxy::Settings.settings.marshal_dump.select { |key, _| key == :pulp_dir || key == :pulp_content_dir || key == :mongodb_dir }]
|
|
28
|
-
begin
|
|
29
|
-
pulp_disk = DiskUsage.new({:path => monitor_dirs, :size => size})
|
|
30
|
-
pulp_disk.to_json
|
|
31
|
-
rescue ::Proxy::Error::ConfigurationError
|
|
32
|
-
log_halt 500, 'Could not find df command to evaluate disk space'
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
get '/status/puppet' do
|
|
37
|
-
content_type :json
|
|
38
|
-
{:puppet_content_dir => ::PulpProxy::Settings.settings.puppet_content_dir}.to_json
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require 'net/http'
|
|
2
|
-
require 'net/https'
|
|
3
|
-
require 'uri'
|
|
4
|
-
require 'smart_proxy_pulp_plugin/settings'
|
|
5
|
-
|
|
6
|
-
module PulpProxy
|
|
7
|
-
class PulpClient
|
|
8
|
-
def self.get(path)
|
|
9
|
-
uri = URI.parse(::PulpProxy::Settings.settings.pulp_url.to_s)
|
|
10
|
-
req = Net::HTTP::Get.new(URI.join(uri.to_s.chomp('/') + '/', path))
|
|
11
|
-
req.add_field('Accept', 'application/json')
|
|
12
|
-
req.content_type = 'application/json'
|
|
13
|
-
response = self.http.request(req)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def self.http
|
|
17
|
-
uri = URI.parse(::PulpProxy::Settings.settings.pulp_url.to_s)
|
|
18
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
|
19
|
-
http.use_ssl = uri.scheme == 'https'
|
|
20
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
21
|
-
|
|
22
|
-
if http.use_ssl?
|
|
23
|
-
if Proxy::SETTINGS.ssl_ca_file && !Proxy::SETTINGS.ssl_ca_file.to_s.empty?
|
|
24
|
-
http.ca_file = Proxy::SETTINGS.ssl_ca_file
|
|
25
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
if Proxy::SETTINGS.ssl_certificate && !Proxy::SETTINGS.ssl_certificate.to_s.empty? && Proxy::SETTINGS.ssl_private_key && !Proxy::SETTINGS.ssl_private_key.to_s.empty?
|
|
29
|
-
http.cert = OpenSSL::X509::Certificate.new(File.read(Proxy::SETTINGS.ssl_certificate))
|
|
30
|
-
http.key = OpenSSL::PKey::RSA.new(File.read(Proxy::SETTINGS.ssl_private_key), nil)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
http
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module PulpNodeProxy
|
|
2
|
-
class Plugin < ::Proxy::Plugin
|
|
3
|
-
plugin "pulpnode", ::PulpProxy::VERSION
|
|
4
|
-
default_settings :pulp_url => 'https://localhost/pulp',
|
|
5
|
-
:pulp_dir => '/var/lib/pulp',
|
|
6
|
-
:pulp_content_dir => '/var/lib/pulp/content',
|
|
7
|
-
:puppet_content_dir => '/etc/puppet/environments',
|
|
8
|
-
:mongodb_dir => '/var/lib/mongodb'
|
|
9
|
-
|
|
10
|
-
expose_setting :pulp_url
|
|
11
|
-
http_rackup_path File.expand_path("pulp_node_http_config.ru", File.expand_path("../", __FILE__))
|
|
12
|
-
https_rackup_path File.expand_path("pulp_node_http_config.ru", File.expand_path("../", __FILE__))
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module PulpProxy
|
|
2
|
-
class Plugin < ::Proxy::Plugin
|
|
3
|
-
plugin "pulp", ::PulpProxy::VERSION
|
|
4
|
-
default_settings :pulp_url => 'https://localhost/pulp',
|
|
5
|
-
:pulp_dir => '/var/lib/pulp',
|
|
6
|
-
:pulp_content_dir => '/var/lib/pulp/content',
|
|
7
|
-
:puppet_content_dir => '/etc/puppet/environments',
|
|
8
|
-
:mongodb_dir => '/var/lib/mongodb'
|
|
9
|
-
|
|
10
|
-
expose_setting :pulp_url
|
|
11
|
-
|
|
12
|
-
http_rackup_path File.expand_path("pulp_http_config.ru", File.expand_path("../", __FILE__))
|
|
13
|
-
https_rackup_path File.expand_path("pulp_http_config.ru", File.expand_path("../", __FILE__))
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
require 'sinatra'
|
|
2
|
-
require 'smart_proxy_pulp_plugin/pulp_node_plugin'
|
|
3
|
-
require 'smart_proxy_pulp_plugin/pulp_plugin'
|
|
4
|
-
|
|
5
|
-
module PulpProxy
|
|
6
|
-
class Settings
|
|
7
|
-
def self.settings
|
|
8
|
-
# work around until pulp node settings are no longer needed by foreman proxy, as pulp nodes have been removed
|
|
9
|
-
::PulpProxy::Plugin.settings.pulp_url ? ::PulpProxy::Plugin.settings : ::PulpNodeProxy::Plugin.settings
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module PulpProxy
|
|
2
|
-
module Validators
|
|
3
|
-
class PulpUrlValidator < ::Proxy::PluginValidators::Base
|
|
4
|
-
def validate!(settings)
|
|
5
|
-
raise ::Proxy::Error::ConfigurationError, "Setting 'pulp_url' is expected to contain a url for pulp server" if settings[:pulp_url].to_s.empty?
|
|
6
|
-
URI.parse(settings[:pulp_url])
|
|
7
|
-
rescue URI::InvalidURIError
|
|
8
|
-
raise ::Proxy::Error::ConfigurationError.new("Setting 'pulp_url' contains an invalid url for pulp server")
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
data/settings.d/pulp.yml.example
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
:enabled: true
|
|
3
|
-
#:pulp_url: https://localhost/pulp
|
|
4
|
-
# Path to pulp, pulp content and mongodb directories
|
|
5
|
-
#:pulp_dir: /var/lib/pulp
|
|
6
|
-
#:pulp_content_dir: /var/lib/pulp/content
|
|
7
|
-
#:puppet_content_dir: /etc/pupppet/environments
|
|
8
|
-
#:mongodb_dir: /var/lib/mongodb
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
:enabled: true
|
|
3
|
-
#:pulp_url: https://localhost/pulp
|
|
4
|
-
# Path to pulp, pulp content and mongodb directories
|
|
5
|
-
#:pulp_dir: /var/lib/pulp
|
|
6
|
-
#:pulp_content_dir: /var/lib/pulp/content
|
|
7
|
-
#:puppet_content_dir: /etc/puppet/environments
|
|
8
|
-
#:mongodb_dir: /var/lib/mongodb
|