runcible 1.2.0 → 1.3.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.
- data/Gemfile +2 -1
- data/README.md +1 -1
- data/Rakefile +16 -10
- data/lib/runcible.rb +1 -1
- data/lib/runcible/base.rb +24 -29
- data/lib/runcible/extensions/consumer.rb +25 -26
- data/lib/runcible/extensions/consumer_group.rb +10 -13
- data/lib/runcible/extensions/distribution.rb +0 -2
- data/lib/runcible/extensions/docker_image.rb +0 -1
- data/lib/runcible/extensions/errata.rb +0 -3
- data/lib/runcible/extensions/package_category.rb +0 -3
- data/lib/runcible/extensions/package_group.rb +0 -2
- data/lib/runcible/extensions/puppet_module.rb +0 -3
- data/lib/runcible/extensions/repository.rb +88 -72
- data/lib/runcible/extensions/rpm.rb +3 -5
- data/lib/runcible/extensions/unit.rb +10 -13
- data/lib/runcible/extensions/yum_repo_metadata_file.rb +0 -3
- data/lib/runcible/instance.rb +22 -28
- data/lib/runcible/models/distributor.rb +4 -5
- data/lib/runcible/models/docker_distributor.rb +4 -4
- data/lib/runcible/models/docker_importer.rb +2 -2
- data/lib/runcible/models/export_distributor.rb +1 -1
- data/lib/runcible/models/importer.rb +3 -6
- data/lib/runcible/models/iso_distributor.rb +3 -3
- data/lib/runcible/models/iso_importer.rb +1 -1
- data/lib/runcible/models/nodes_http_distributor.rb +0 -1
- data/lib/runcible/models/puppet_distributor.rb +2 -2
- data/lib/runcible/models/yum_clone_distributor.rb +3 -4
- data/lib/runcible/models/yum_distributor.rb +7 -7
- data/lib/runcible/models/yum_importer.rb +17 -17
- data/lib/runcible/resources/consumer.rb +17 -20
- data/lib/runcible/resources/consumer_group.rb +13 -15
- data/lib/runcible/resources/content.rb +10 -10
- data/lib/runcible/resources/event_notifier.rb +5 -9
- data/lib/runcible/resources/repository.rb +23 -23
- data/lib/runcible/resources/repository_group.rb +5 -7
- data/lib/runcible/resources/repository_schedule.rb +5 -7
- data/lib/runcible/resources/role.rb +5 -8
- data/lib/runcible/resources/task.rb +10 -13
- data/lib/runcible/resources/unit.rb +3 -6
- data/lib/runcible/resources/user.rb +7 -10
- data/lib/runcible/version.rb +1 -1
- metadata +2 -2
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
Exposing Pulp's juiciest parts. http://www.pulpproject.org/
|
6
6
|
|
7
|
-
Latest Live Tested Version: **pulp-server-2.5.0-0.
|
7
|
+
Latest Live Tested Version: **pulp-server-2.5.0-0.7.beta.el6.noarch**
|
8
8
|
|
9
9
|
Current stable Runcible: https://github.com/Katello/runcible/tree/0.3
|
10
10
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rake/testtask'
|
4
4
|
|
5
5
|
def clear_cassettes
|
6
6
|
`rm -rf test/fixtures/vcr_cassettes/*.yml`
|
@@ -9,9 +9,8 @@ def clear_cassettes
|
|
9
9
|
print "Cassettes cleared\n"
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
12
|
namespace :test do
|
14
|
-
|
13
|
+
desc 'Runs the unit tests'
|
15
14
|
Rake::TestTask.new :unit do |t|
|
16
15
|
t.pattern = 'test/unit/test_*.rb'
|
17
16
|
end
|
@@ -27,9 +26,9 @@ namespace :test do
|
|
27
26
|
options[:logging] = ENV['logging']
|
28
27
|
|
29
28
|
if !['new_episodes', 'all', 'none', 'once'].include?(options[:mode])
|
30
|
-
puts
|
29
|
+
puts 'Invalid test mode'
|
31
30
|
else
|
32
|
-
require
|
31
|
+
require './test/test_runner'
|
33
32
|
|
34
33
|
test_runner = PulpMiniTestRunner.new
|
35
34
|
|
@@ -41,13 +40,13 @@ namespace :test do
|
|
41
40
|
|
42
41
|
clear_cassettes if options[:mode] == 'all' && options[:test_name].nil? && ENV['record'] != 'false'
|
43
42
|
test_runner.run_tests(task_name, options)
|
44
|
-
Rake::Task[:update_test_version].invoke if options[:mode] ==
|
43
|
+
Rake::Task[:update_test_version].invoke if options[:mode] == 'all' && ENV['record'] != 'false'
|
45
44
|
end
|
46
45
|
end
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
50
|
-
desc
|
49
|
+
desc 'Updats the version of Pulp tested against in README'
|
51
50
|
task :update_test_version do
|
52
51
|
text = File.open('README.md').read
|
53
52
|
|
@@ -60,15 +59,22 @@ task :update_test_version do
|
|
60
59
|
end
|
61
60
|
end
|
62
61
|
|
63
|
-
desc
|
62
|
+
desc 'Clears out all cassette files'
|
64
63
|
task :clear_cassettes do
|
65
64
|
clear_cassettes
|
66
65
|
end
|
67
66
|
|
68
|
-
desc
|
67
|
+
desc 'Runs all tests'
|
69
68
|
task :test do
|
70
69
|
Rake::Task['test:unit'].invoke
|
71
70
|
Rake::Task['test:models'].invoke
|
72
71
|
Rake::Task['test:resources'].invoke
|
73
72
|
Rake::Task['test:extensions'].invoke
|
74
73
|
end
|
74
|
+
|
75
|
+
begin
|
76
|
+
require 'rubocop/rake_task'
|
77
|
+
RuboCop::RakeTask.new
|
78
|
+
rescue
|
79
|
+
puts "Rubocop not loaded"
|
80
|
+
end
|
data/lib/runcible.rb
CHANGED
@@ -36,4 +36,4 @@ resources += Dir[File.dirname(__FILE__) + '/runcible/models/importer.rb']
|
|
36
36
|
resources += Dir[File.dirname(__FILE__) + '/runcible/models/distributor.rb']
|
37
37
|
resources += Dir[File.dirname(__FILE__) + '/runcible/models/*.rb']
|
38
38
|
|
39
|
-
resources.uniq.each{ |f| require f }
|
39
|
+
resources.uniq.each { |f| require f }
|
data/lib/runcible/base.rb
CHANGED
@@ -26,11 +26,9 @@ require 'oauth'
|
|
26
26
|
require 'json'
|
27
27
|
require 'thread'
|
28
28
|
|
29
|
-
|
30
29
|
module Runcible
|
31
30
|
class Base
|
32
|
-
|
33
|
-
def initialize(config={})
|
31
|
+
def initialize(config = {})
|
34
32
|
@mutex = Mutex.new
|
35
33
|
@config = config
|
36
34
|
end
|
@@ -42,7 +40,7 @@ module Runcible
|
|
42
40
|
def config
|
43
41
|
@mutex.synchronize do
|
44
42
|
@config = @lazy_config.call if defined?(@lazy_config)
|
45
|
-
|
43
|
+
fail Runcible::ConfigurationUndefinedError, Runcible::ConfigurationUndefinedError.message unless @config
|
46
44
|
@config
|
47
45
|
end
|
48
46
|
end
|
@@ -51,16 +49,12 @@ module Runcible
|
|
51
49
|
self.class.path(*args)
|
52
50
|
end
|
53
51
|
|
54
|
-
def call(method, path, options={})
|
52
|
+
def call(method, path, options = {})
|
55
53
|
clone_config = self.config.clone
|
56
54
|
#on occation path will already have prefix (sync cancel)
|
57
|
-
path = clone_config[:api_path] + path
|
55
|
+
path = clone_config[:api_path] + path unless path.start_with?(clone_config[:api_path])
|
58
56
|
|
59
57
|
RestClient.log = []
|
60
|
-
logger = clone_config[:logging][:logger]
|
61
|
-
debug_logging = clone_config[:logging][:debug]
|
62
|
-
exception_logging = clone_config[:logging][:exception]
|
63
|
-
|
64
58
|
headers = clone_config[:headers].clone
|
65
59
|
|
66
60
|
get_params = options[:params] if options[:params]
|
@@ -69,10 +63,11 @@ module Runcible
|
|
69
63
|
client_options = {}
|
70
64
|
client_options[:timeout] = clone_config[:timeout] if clone_config[:timeout]
|
71
65
|
client_options[:open_timeout] = clone_config[:open_timeout] if clone_config[:open_timeout]
|
66
|
+
client_options[:verify_ssl] = clone_config[:verify_ssl] unless clone_config[:verify_ssl].nil?
|
72
67
|
|
73
68
|
if clone_config[:oauth]
|
74
69
|
headers = add_oauth_header(method, path, headers) if clone_config[:oauth]
|
75
|
-
headers[
|
70
|
+
headers['pulp-user'] = clone_config[:user]
|
76
71
|
client = RestClient::Resource.new(clone_config[:url], client_options)
|
77
72
|
else
|
78
73
|
client_options[:user] = clone_config[:user]
|
@@ -93,7 +88,7 @@ module Runcible
|
|
93
88
|
end
|
94
89
|
|
95
90
|
def get_response(client, path, *args)
|
96
|
-
client[path].send(*args) do |response, request, result, &
|
91
|
+
client[path].send(*args) do |response, request, result, &_block|
|
97
92
|
resp = response.return!(request, result)
|
98
93
|
log_debug
|
99
94
|
return resp
|
@@ -101,13 +96,14 @@ module Runcible
|
|
101
96
|
end
|
102
97
|
|
103
98
|
def combine_get_params(path, params)
|
104
|
-
query_string = params.
|
99
|
+
query_string = params.map do |k, v|
|
105
100
|
if v.is_a? Array
|
106
|
-
v.
|
101
|
+
v.map { |y| "#{k}=#{y}" }.join('&')
|
107
102
|
else
|
108
|
-
"#{k
|
103
|
+
"#{k}=#{v}"
|
109
104
|
end
|
110
|
-
end
|
105
|
+
end
|
106
|
+
query_string = query_string.flatten.join('&')
|
111
107
|
path + "?#{query_string}"
|
112
108
|
end
|
113
109
|
|
@@ -145,19 +141,20 @@ module Runcible
|
|
145
141
|
if body.respond_to? :with_indifferent_access
|
146
142
|
body = body.with_indifferent_access
|
147
143
|
elsif body.is_a? Array
|
148
|
-
body = body.
|
144
|
+
body = body.map do |i|
|
149
145
|
i.respond_to?(:with_indifferent_access) ? i.with_indifferent_access : i
|
150
146
|
end
|
151
147
|
end
|
152
148
|
response = RestClient::Response.create(body, response.net_http_res, response.args)
|
153
149
|
rescue JSON::ParserError
|
150
|
+
log_exception
|
154
151
|
end
|
155
152
|
|
156
153
|
return response
|
157
154
|
end
|
158
155
|
|
159
|
-
def required_params(local_names, binding, keys_to_remove=[])
|
160
|
-
local_names = local_names.
|
156
|
+
def required_params(local_names, binding, keys_to_remove = [])
|
157
|
+
local_names = local_names.each_with_object({}) do |v, acc|
|
161
158
|
value = binding.eval(v.to_s) unless v == :_
|
162
159
|
acc[v] = value unless value.nil?
|
163
160
|
acc
|
@@ -166,8 +163,8 @@ module Runcible
|
|
166
163
|
#The double delete is to support 1.8.7 and 1.9.3
|
167
164
|
local_names.delete(:payload)
|
168
165
|
local_names.delete(:optional)
|
169
|
-
local_names.delete(
|
170
|
-
local_names.delete(
|
166
|
+
local_names.delete('payload')
|
167
|
+
local_names.delete('optional')
|
171
168
|
keys_to_remove.each do |key|
|
172
169
|
local_names.delete(key)
|
173
170
|
local_names.delete(key.to_sym)
|
@@ -183,9 +180,9 @@ module Runcible
|
|
183
180
|
def add_oauth_header(method, path, headers)
|
184
181
|
default_options = { :site => config[:url],
|
185
182
|
:http_method => method,
|
186
|
-
:request_token_path =>
|
187
|
-
:authorize_path =>
|
188
|
-
:access_token_path =>
|
183
|
+
:request_token_path => '',
|
184
|
+
:authorize_path => '',
|
185
|
+
:access_token_path => '' }
|
189
186
|
|
190
187
|
default_options[:ca_file] = config[:ca_cert_file] unless config[:ca_cert_file].nil?
|
191
188
|
consumer = OAuth::Consumer.new(config[:oauth][:oauth_key], config[:oauth][:oauth_secret], default_options)
|
@@ -204,7 +201,7 @@ module Runcible
|
|
204
201
|
|
205
202
|
def log_debug
|
206
203
|
if self.config[:logging][:debug]
|
207
|
-
log_message = generate_log_message
|
204
|
+
log_message = generate_log_message
|
208
205
|
self.config[:logging][:logger].debug(log_message)
|
209
206
|
end
|
210
207
|
end
|
@@ -223,14 +220,12 @@ module Runcible
|
|
223
220
|
def logger
|
224
221
|
self.config[:logging][:logger]
|
225
222
|
end
|
226
|
-
|
227
|
-
end
|
223
|
+
end
|
228
224
|
|
229
225
|
class ConfigurationUndefinedError < StandardError
|
230
|
-
|
231
226
|
def self.message
|
232
227
|
# override me to change the error message
|
233
|
-
|
228
|
+
'Configuration not set. Runcible::Base.config= must be called before Runcible::Base.config.'
|
234
229
|
end
|
235
230
|
end
|
236
231
|
end
|
@@ -21,11 +21,9 @@
|
|
21
21
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
23
|
|
24
|
-
|
25
24
|
module Runcible
|
26
25
|
module Extensions
|
27
26
|
class Consumer < Runcible::Resources::Consumer
|
28
|
-
|
29
27
|
# Bind a consumer to all repositories with a given ID
|
30
28
|
#
|
31
29
|
# @param [String] id the consumer ID
|
@@ -35,10 +33,11 @@ module Runcible
|
|
35
33
|
# @option options [Boolean] :notify_agent sends consumer a notification
|
36
34
|
# @option options [Hash] :binding_config sends consumer a notification
|
37
35
|
# @return [RestClient::Response] set of tasks representing each bind operation
|
38
|
-
def bind_all(id, repo_id, type_id, options={})
|
39
|
-
repository_extension.retrieve_with_details(repo_id)['distributors'].
|
36
|
+
def bind_all(id, repo_id, type_id, options = {})
|
37
|
+
details = repository_extension.retrieve_with_details(repo_id)['distributors'].map do |d|
|
40
38
|
bind(id, repo_id, d['id'], options) if d['distributor_type_id'] == type_id
|
41
|
-
end
|
39
|
+
end
|
40
|
+
details.compact.flatten
|
42
41
|
end
|
43
42
|
|
44
43
|
# Unbind a consumer to all repositories with a given ID
|
@@ -48,9 +47,10 @@ module Runcible
|
|
48
47
|
# @param [String] type_id the distributor type_id to unbind from
|
49
48
|
# @return [RestClient::Response] set of tasks representing each unbind operation
|
50
49
|
def unbind_all(id, repo_id, type_id)
|
51
|
-
repository_extension.retrieve_with_details(repo_id)['distributors'].
|
50
|
+
details = repository_extension.retrieve_with_details(repo_id)['distributors'].map do |d|
|
52
51
|
unbind(id, repo_id, d['id']) if d['distributor_type_id'] == type_id
|
53
|
-
end
|
52
|
+
end
|
53
|
+
details.compact.flatten
|
54
54
|
end
|
55
55
|
|
56
56
|
# Activate a consumer as a pulp node
|
@@ -58,9 +58,9 @@ module Runcible
|
|
58
58
|
# @param [String] id the consumer ID
|
59
59
|
# @param [String] update_strategy update_strategy for the node (defaults to additive)
|
60
60
|
# @return [RestClient::Response] response from update call
|
61
|
-
def activate_node(id, update_strategy=
|
62
|
-
delta = {:notes=>{'_child-node' => true,
|
63
|
-
|
61
|
+
def activate_node(id, update_strategy = 'additive')
|
62
|
+
delta = {:notes => {'_child-node' => true,
|
63
|
+
'_node-update-strategy' => update_strategy}}
|
64
64
|
self.update(id, delta)
|
65
65
|
end
|
66
66
|
|
@@ -69,9 +69,9 @@ module Runcible
|
|
69
69
|
# @param [String] id the consumer ID
|
70
70
|
# @return [RestClient::Response] response from update call
|
71
71
|
def deactivate_node(id)
|
72
|
-
delta = {:notes=>{'child-node' => nil,
|
73
|
-
|
74
|
-
self.update(id, :delta=>delta)
|
72
|
+
delta = {:notes => {'child-node' => nil,
|
73
|
+
'update_strategy' => nil}}
|
74
|
+
self.update(id, :delta => delta)
|
75
75
|
end
|
76
76
|
|
77
77
|
# Install content to a consumer
|
@@ -81,7 +81,7 @@ module Runcible
|
|
81
81
|
# @param [Array] units array of units to install
|
82
82
|
# @param [Hash] options to pass to content install
|
83
83
|
# @return [RestClient::Response] task representing the install operation
|
84
|
-
def install_content(id, type_id, units, options={})
|
84
|
+
def install_content(id, type_id, units, options = {})
|
85
85
|
install_units(id, generate_content(type_id, units), options)
|
86
86
|
end
|
87
87
|
|
@@ -92,7 +92,7 @@ module Runcible
|
|
92
92
|
# @param [Array] units array of units to update
|
93
93
|
# @param [Hash] options to pass to content update
|
94
94
|
# @return [RestClient::Response] task representing the update operation
|
95
|
-
def update_content(id, type_id, units, options={})
|
95
|
+
def update_content(id, type_id, units, options = {})
|
96
96
|
update_units(id, generate_content(type_id, units, options), options)
|
97
97
|
end
|
98
98
|
|
@@ -112,18 +112,18 @@ module Runcible
|
|
112
112
|
# @param [Array] units array of units
|
113
113
|
# @param [Hash] options contains options which may impact the format of the content (e.g :all => true)
|
114
114
|
# @return [Array] array of formatted content units
|
115
|
-
def generate_content(type_id, units, options={})
|
115
|
+
def generate_content(type_id, units, options = {})
|
116
116
|
content = []
|
117
117
|
|
118
118
|
case type_id
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
119
|
+
when 'rpm', 'package_group'
|
120
|
+
unit_key = :name
|
121
|
+
when 'erratum'
|
122
|
+
unit_key = :id
|
123
|
+
when 'repository'
|
124
|
+
unit_key = :repo_id
|
125
|
+
else
|
126
|
+
unit_key = :id
|
127
127
|
end
|
128
128
|
|
129
129
|
if options[:all]
|
@@ -132,7 +132,7 @@ module Runcible
|
|
132
132
|
content_unit[:unit_key] = {}
|
133
133
|
content.push(content_unit)
|
134
134
|
elsif units.nil?
|
135
|
-
content = [{:unit_key=> nil, :type_id=>type_id}]
|
135
|
+
content = [{:unit_key => nil, :type_id => type_id}]
|
136
136
|
else
|
137
137
|
units.each do |unit|
|
138
138
|
content_unit = {}
|
@@ -184,7 +184,6 @@ module Runcible
|
|
184
184
|
def repository_extension
|
185
185
|
Runcible::Extensions::Repository.new(self.config)
|
186
186
|
end
|
187
|
-
|
188
187
|
end
|
189
188
|
end
|
190
189
|
end
|
@@ -21,11 +21,9 @@
|
|
21
21
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
23
|
|
24
|
-
|
25
24
|
module Runcible
|
26
25
|
module Extensions
|
27
26
|
class ConsumerGroup < Runcible::Resources::ConsumerGroup
|
28
|
-
|
29
27
|
# Add consumers by ID to a consumer group
|
30
28
|
#
|
31
29
|
# @param [String] id the consumer group ID
|
@@ -51,7 +49,7 @@ module Runcible
|
|
51
49
|
def make_consumer_criteria(consumer_ids)
|
52
50
|
{:criteria =>
|
53
51
|
{:filters =>
|
54
|
-
{:id =>{
|
52
|
+
{:id => {'$in' => consumer_ids}}
|
55
53
|
}
|
56
54
|
}
|
57
55
|
end
|
@@ -63,7 +61,7 @@ module Runcible
|
|
63
61
|
# @param [Array] units array of units to install
|
64
62
|
# @param [Hash] options to pass to content install
|
65
63
|
# @return [RestClient::Response] task representing the install operation
|
66
|
-
def install_content(id, type_id, units, options={})
|
64
|
+
def install_content(id, type_id, units, options = {})
|
67
65
|
install_units(id, generate_content(type_id, units), options)
|
68
66
|
end
|
69
67
|
|
@@ -74,7 +72,7 @@ module Runcible
|
|
74
72
|
# @param [Array] units array of units to update
|
75
73
|
# @param [Hash] options to pass to content update
|
76
74
|
# @return [RestClient::Response] task representing the update operation
|
77
|
-
def update_content(id, type_id, units, options={})
|
75
|
+
def update_content(id, type_id, units, options = {})
|
78
76
|
update_units(id, generate_content(type_id, units, options), options)
|
79
77
|
end
|
80
78
|
|
@@ -94,16 +92,16 @@ module Runcible
|
|
94
92
|
# @param [Array] units array of units
|
95
93
|
# @param [Hash] options contains options which may impact the format of the content (e.g :all => true)
|
96
94
|
# @return [Array] array of formatted content units
|
97
|
-
def generate_content(type_id, units, options={})
|
95
|
+
def generate_content(type_id, units, options = {})
|
98
96
|
content = []
|
99
97
|
|
100
98
|
case type_id
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
99
|
+
when 'rpm', 'package_group'
|
100
|
+
unit_key = :name
|
101
|
+
when 'erratum'
|
102
|
+
unit_key = :id
|
103
|
+
else
|
104
|
+
unit_key = :id
|
107
105
|
end
|
108
106
|
|
109
107
|
if options[:all]
|
@@ -121,7 +119,6 @@ module Runcible
|
|
121
119
|
end
|
122
120
|
content
|
123
121
|
end
|
124
|
-
|
125
122
|
end
|
126
123
|
end
|
127
124
|
end
|
@@ -21,11 +21,9 @@
|
|
21
21
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
23
|
|
24
|
-
|
25
24
|
module Runcible
|
26
25
|
module Extensions
|
27
26
|
class Distribution < Runcible::Extensions::Unit
|
28
|
-
|
29
27
|
def self.content_type
|
30
28
|
'distribution'
|
31
29
|
end
|