runcible 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/runcible/base.rb +38 -4
- data/lib/runcible/extensions/distribution.rb +0 -1
- data/lib/runcible/extensions/package_group.rb +0 -1
- data/lib/runcible/extensions/repository.rb +6 -107
- data/lib/runcible/extensions/rpm.rb +4 -0
- data/lib/runcible/extensions/unit.rb +48 -0
- data/lib/runcible/resources/repository.rb +0 -1
- data/lib/runcible/version.rb +1 -1
- metadata +85 -8
data/lib/runcible/base.rb
CHANGED
@@ -44,7 +44,8 @@ module Runcible
|
|
44
44
|
:user => '',
|
45
45
|
:http_auth => {:password => {} },
|
46
46
|
:headers => {:content_type => 'application/json',
|
47
|
-
:accept => 'application/json'}
|
47
|
+
:accept => 'application/json'},
|
48
|
+
:logging => {}
|
48
49
|
}.merge(conf)
|
49
50
|
end
|
50
51
|
|
@@ -57,14 +58,16 @@ module Runcible
|
|
57
58
|
#on occation path will already have prefix (sync cancel)
|
58
59
|
path = clone_config[:api_path] + path if !path.start_with?(clone_config[:api_path])
|
59
60
|
|
60
|
-
RestClient.log
|
61
|
+
RestClient.log = []
|
62
|
+
logger = clone_config[:logging][:logger]
|
63
|
+
debug_logging = clone_config[:logging][:debug]
|
64
|
+
exception_logging = clone_config[:logging][:exception]
|
61
65
|
|
62
66
|
headers = clone_config[:headers].clone
|
63
67
|
|
64
68
|
get_params = options[:params] if options[:params]
|
65
69
|
path = combine_get_params(path, get_params) if get_params
|
66
70
|
|
67
|
-
|
68
71
|
if clone_config[:oauth]
|
69
72
|
headers = add_oauth_header(method, path, headers) if clone_config[:oauth]
|
70
73
|
headers["pulp-user"] = clone_config[:user]
|
@@ -77,7 +80,20 @@ module Runcible
|
|
77
80
|
args << generate_payload(options) if [:post, :put].include?(method)
|
78
81
|
args << headers
|
79
82
|
|
80
|
-
|
83
|
+
response = get_response(client, path, *args)
|
84
|
+
process_response(response)
|
85
|
+
|
86
|
+
rescue => e
|
87
|
+
log_exception
|
88
|
+
raise e
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.get_response(client, path, *args)
|
92
|
+
client[path].send(*args) do |response, request, result, &block|
|
93
|
+
resp = response.return!(request, result)
|
94
|
+
log_debug
|
95
|
+
return resp
|
96
|
+
end
|
81
97
|
end
|
82
98
|
|
83
99
|
def self.combine_get_params(path, params)
|
@@ -174,5 +190,23 @@ module Runcible
|
|
174
190
|
return headers
|
175
191
|
end
|
176
192
|
|
193
|
+
def self.log_debug
|
194
|
+
if self.config[:logging][:debug]
|
195
|
+
log_message = generate_log_message
|
196
|
+
self.config[:logging][:logger].debug(log_message)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def self.log_exception
|
201
|
+
if self.config[:logging][:exception]
|
202
|
+
log_message = generate_log_message
|
203
|
+
self.config[:logging][:logger].error(log_message)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def self.generate_log_message
|
208
|
+
RestClient.log.join('\n')
|
209
|
+
end
|
210
|
+
|
177
211
|
end
|
178
212
|
end
|
@@ -98,114 +98,13 @@ module Runcible
|
|
98
98
|
search(criteria)
|
99
99
|
end
|
100
100
|
|
101
|
-
# Copies RPMs from one repository to another
|
102
|
-
#
|
103
|
-
# optional
|
104
|
-
# :package_ids
|
105
|
-
# :name_blacklist
|
106
|
-
#
|
107
|
-
# @param [String] source_repo_id the source repository ID
|
108
|
-
# @param [String] destination_repo_id the destination repository ID
|
109
|
-
# @param [Hash] optional container for all optional parameters
|
110
|
-
# @return [RestClient::Response] a task representing the unit copy operation
|
111
|
-
def self.rpm_copy(source_repo_id, destination_repo_id, optional={})
|
112
|
-
|
113
|
-
criteria = {:type_ids => ['rpm'], :filters => {}}
|
114
|
-
criteria[:filters]['association'] = {'unit_id' => {'$in' => optional[:package_ids]}} if optional[:package_ids]
|
115
|
-
criteria[:filters]['unit'] = { 'name' => {'$not' => {'$in' => optional[:name_blacklist]}}} if optional[:name_blacklist]
|
116
|
-
|
117
|
-
payload = {:criteria=>criteria}
|
118
|
-
payload[:override_config] = optional[:override_config] if optional[:override_config]
|
119
|
-
unit_copy(destination_repo_id, source_repo_id, payload)
|
120
|
-
end
|
121
|
-
|
122
|
-
# Removes RPMs from a repository
|
123
|
-
#
|
124
|
-
# @param [String] repo_id the repository ID to remove RPMs from
|
125
|
-
# @param [Array] rpm_ids array of RPM IDs to remove
|
126
|
-
# @return [RestClient::Response] a task representing the unit unassociate operation
|
127
|
-
def self.rpm_remove(repo_id, rpm_ids)
|
128
|
-
criteria = {:type_ids => ['rpm'], :filters => {}}
|
129
|
-
criteria[:filters]['association'] = {'unit_id' => {'$in' => rpm_ids}}
|
130
|
-
self.unassociate_units(repo_id, criteria)
|
131
|
-
end
|
132
|
-
|
133
|
-
# Copies errata from one repository to another
|
134
|
-
#
|
135
|
-
# optional
|
136
|
-
# :errata_ids
|
137
|
-
#
|
138
|
-
# @param [String] source_repo_id the source repository ID
|
139
|
-
# @param [String] destination_repo_id the destination repository ID
|
140
|
-
# @param [Hash] optional container for all optional parameters
|
141
|
-
# @return [RestClient::Response] a task representing the unit copy operation
|
142
|
-
def self.errata_copy(source_repo_id, destination_repo_id, optional={})
|
143
|
-
criteria = {:type_ids => ['erratum'], :filters => {}}
|
144
|
-
criteria[:filters]['association'] = {'unit_id' => {'$in' => optional[:errata_ids]}} if optional[:errata_ids]
|
145
|
-
payload = {:criteria => criteria}
|
146
|
-
unit_copy(destination_repo_id, source_repo_id, payload)
|
147
|
-
end
|
148
|
-
|
149
|
-
# Removes errata from a repository
|
150
|
-
#
|
151
|
-
# @param [String] repo_id the repository ID to remove errata from
|
152
|
-
# @param [Array] errata_ids array of errata IDs to remove
|
153
|
-
# @return [RestClient::Response] a task representing the unit unassociate operation
|
154
|
-
def self.errata_remove(repo_id, errata_ids)
|
155
|
-
criteria = {:type_ids => ['erratum'], :filters => {}}
|
156
|
-
criteria[:filters]['association'] = {'unit_id' => {'$in' => errata_ids}}
|
157
|
-
self.unassociate_units(repo_id, criteria)
|
158
|
-
end
|
159
|
-
|
160
|
-
# Copies distributions from one repository to another
|
161
|
-
#
|
162
|
-
# optoinal
|
163
|
-
# :distribution_ids
|
164
|
-
#
|
165
|
-
# @param [String] source_repo_id the source repository ID
|
166
|
-
# @param [String] destination_repo_id the destination repository ID
|
167
|
-
# @param [Hash] optional container for all optional parameters
|
168
|
-
# @return [RestClient::Response] a task representing the unit copy operation
|
169
|
-
def self.distribution_copy(source_repo_id, destination_repo_id, optional={})
|
170
|
-
criteria = {:type_ids => ['distribution'], :filters => {}}
|
171
|
-
criteria[:filters][:unit] = { :id=>{ '$in' => optional[:distribution_ids] } } if optional[:distribution_ids]
|
172
|
-
payload = {:criteria => criteria}
|
173
|
-
unit_copy(destination_repo_id, source_repo_id, payload)
|
174
|
-
end
|
175
|
-
|
176
|
-
# Removes a distribution from a repository
|
177
|
-
#
|
178
|
-
# @param [String] repo_id the repository ID to remove the distribution from
|
179
|
-
# @param [String] distribution_id the distribution ID to remove
|
180
|
-
# @return [RestClient::Response] a task representing the unit unassociate operation
|
181
|
-
def self.distribution_remove(repo_id, distribution_id)
|
182
|
-
criteria = {:type_ids => ['distribution'], :filters => {}}
|
183
|
-
criteria[:filters][:unit] = { :id=>{ '$in' => [distribution_id] } }
|
184
|
-
self.unassociate_units(repo_id, criteria)
|
185
|
-
end
|
186
|
-
|
187
|
-
# Copies package groups from one repository to another
|
188
|
-
#
|
189
|
-
# optoinal
|
190
|
-
# :package_group_ids
|
191
|
-
#
|
192
|
-
# @param [String] source_repo_id the source repository ID
|
193
|
-
# @param [String] destination_repo_id the destination repository ID
|
194
|
-
# @param [Hash] optional container for all optional parameters
|
195
|
-
# @return [RestClient::Response] a task representing the unit copy operation
|
196
|
-
def self.package_group_copy(source_repo_id, destination_repo_id, optional={})
|
197
|
-
criteria = {:type_ids => [Runcible::Extensions::PackageGroup.content_type], :filters => {}}
|
198
|
-
criteria[:filters][:unit] = { :id=>{ '$in' => optional[:package_group_ids] } } if optional[:package_group_ids]
|
199
|
-
payload = {:criteria => criteria}
|
200
|
-
unit_copy(destination_repo_id, source_repo_id, payload)
|
201
|
-
end
|
202
101
|
|
203
102
|
# Retrieves the RPM IDs for a single repository
|
204
103
|
#
|
205
104
|
# @param [String] id the ID of the repository
|
206
105
|
# @return [RestClient::Response] the set of repository RPM IDs
|
207
106
|
def self.rpm_ids(id)
|
208
|
-
criteria = {:type_ids=>[
|
107
|
+
criteria = {:type_ids=>[Runcible::Extensions::Rpm.content_type]}
|
209
108
|
self.unit_search(id, criteria).collect{|i| i['unit_id']}
|
210
109
|
end
|
211
110
|
|
@@ -214,7 +113,7 @@ module Runcible
|
|
214
113
|
# @param [String] id the ID of the repository
|
215
114
|
# @return [RestClient::Response] the set of repository RPMs
|
216
115
|
def self.rpms(id)
|
217
|
-
criteria = {:type_ids=>[
|
116
|
+
criteria = {:type_ids=>[Runcible::Extensions::Rpm.content_type]}
|
218
117
|
self.unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
|
219
118
|
end
|
220
119
|
|
@@ -233,7 +132,7 @@ module Runcible
|
|
233
132
|
and_condition << {:release=>release} if release
|
234
133
|
and_condition << {:epoch=>epoch} if epoch
|
235
134
|
|
236
|
-
criteria = {:type_ids=>[
|
135
|
+
criteria = {:type_ids=>[Runcible::Extensions::Rpm.content_type],
|
237
136
|
:filters => {
|
238
137
|
:unit => {
|
239
138
|
"$and" => and_condition
|
@@ -250,7 +149,7 @@ module Runcible
|
|
250
149
|
# @param [String] id the ID of the repository
|
251
150
|
# @return [RestClient::Response] the set of repository errata IDs
|
252
151
|
def self.errata_ids(id)
|
253
|
-
criteria = {:type_ids=>[
|
152
|
+
criteria = {:type_ids=>[Runcible::Extensions::Errata.content_type]}
|
254
153
|
|
255
154
|
self.unit_search(id, criteria).collect{|i| i['unit_id']}
|
256
155
|
end
|
@@ -260,7 +159,7 @@ module Runcible
|
|
260
159
|
# @param [String] id the ID of the repository
|
261
160
|
# @return [RestClient::Response] the set of repository errata
|
262
161
|
def self.errata(id)
|
263
|
-
criteria = {:type_ids=>[
|
162
|
+
criteria = {:type_ids=>[Runcible::Extensions::Errata.content_type]}
|
264
163
|
self.unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
|
265
164
|
end
|
266
165
|
|
@@ -269,7 +168,7 @@ module Runcible
|
|
269
168
|
# @param [String] id the ID of the repository
|
270
169
|
# @return [RestClient::Response] the set of repository distributions
|
271
170
|
def self.distributions(id)
|
272
|
-
criteria = {:type_ids=>[
|
171
|
+
criteria = {:type_ids=>[Runcible::Extensions::Distribution.content_type]}
|
273
172
|
|
274
173
|
self.unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
|
275
174
|
end
|
@@ -74,6 +74,54 @@ module Runcible
|
|
74
74
|
self.search(content_type, { :filters => {:_id=> {'$in'=> ids}} }, optional)
|
75
75
|
end
|
76
76
|
|
77
|
+
# unassociates content units from a repository
|
78
|
+
#
|
79
|
+
# @param [String] repo_id the repository ID to remove units from
|
80
|
+
# @param [Hash] filters the filters to find the units this content type to remove
|
81
|
+
# @return [RestClient::Response] a task representing the unit unassociate operation
|
82
|
+
def self.unassociate_from_repo(repo_id, filters)
|
83
|
+
criteria = {:type_ids => [content_type]}
|
84
|
+
criteria[:filters] = filters
|
85
|
+
Runcible::Extensions::Repository.unassociate_units(repo_id, criteria)
|
86
|
+
end
|
87
|
+
|
88
|
+
# unassociates content units from a repository
|
89
|
+
#
|
90
|
+
# @param [String] repo_id the repository ID to remove units from
|
91
|
+
# @param [Array] ids list of content unit ids of this
|
92
|
+
# content type, aka metadata id or content id
|
93
|
+
# ex: "RHEA-2010:0001" for errata..,
|
94
|
+
# Note rpms do not have ids, so cant use this.
|
95
|
+
# @return [RestClient::Response] a task representing the unit unassociate operation
|
96
|
+
def self.unassociate_ids_from_repo(repo_id, ids)
|
97
|
+
unassociate_from_repo(repo_id, :unit => {'id' => {'$in' => ids}})
|
98
|
+
end
|
99
|
+
|
100
|
+
# unassociates content units from a repository
|
101
|
+
#
|
102
|
+
# @param [String] repo_id the repository ID to remove units from
|
103
|
+
# @param [Array] ids list of the unique hash ids of the content unit
|
104
|
+
# with respect to this repo. unit_id, _id are other names for this.
|
105
|
+
# for example: "efdd2d63-b275-4728-a298-f68cf4c174e7"
|
106
|
+
#
|
107
|
+
# @return [RestClient::Response] a task representing the unit unassociate operation
|
108
|
+
def self.unassociate_unit_ids_from_repo(repo_id, ids)
|
109
|
+
unassociate_from_repo(repo_id, :association => {'unit_id' => {'$in' => ids}})
|
110
|
+
end
|
111
|
+
|
112
|
+
#copy contents from source repo to the destination repo
|
113
|
+
#
|
114
|
+
# @param [String] source_repo_id the source repository ID
|
115
|
+
# @param [String] destination_repo_id the destination repository ID
|
116
|
+
# @param [Hash] optional container for all optional parameters
|
117
|
+
# @return [RestClient::Response] a task representing the unit copy operation
|
118
|
+
def self.copy(source_repo_id, destination_repo_id, optional={})
|
119
|
+
criteria = {:type_ids => [content_type], :filters => {}}
|
120
|
+
criteria[:filters]['association'] = {'unit_id' => {'$in' => optional[:ids]}} if optional[:ids]
|
121
|
+
payload = {:criteria => criteria}
|
122
|
+
Runcible::Extensions::Repository.unit_copy(destination_repo_id, source_repo_id, payload)
|
123
|
+
end
|
124
|
+
|
77
125
|
end
|
78
126
|
end
|
79
127
|
end
|
data/lib/runcible/version.rb
CHANGED
metadata
CHANGED
@@ -1,26 +1,103 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runcible
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
|
-
- Eric D Helms
|
13
|
+
- Eric D Helms, Justin Sherrill
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-
|
19
|
-
dependencies:
|
20
|
-
|
18
|
+
date: 2013-02-04 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: json
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - "="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 1
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 7
|
32
|
+
- 5
|
33
|
+
version: 1.7.5
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rest-client
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 13
|
45
|
+
segments:
|
46
|
+
- 1
|
47
|
+
- 6
|
48
|
+
- 1
|
49
|
+
version: 1.6.1
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: oauth
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
type: :runtime
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: activesupport
|
68
|
+
prerelease: false
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 19
|
75
|
+
segments:
|
76
|
+
- 3
|
77
|
+
- 0
|
78
|
+
- 10
|
79
|
+
version: 3.0.10
|
80
|
+
type: :runtime
|
81
|
+
version_requirements: *id004
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: i18n
|
84
|
+
prerelease: false
|
85
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 11
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
- 5
|
94
|
+
- 0
|
95
|
+
version: 0.5.0
|
96
|
+
type: :runtime
|
97
|
+
version_requirements: *id005
|
21
98
|
description: Exposing Pulp's juiciest components to the Ruby world.
|
22
99
|
email:
|
23
|
-
- ehelms@redhat.com
|
100
|
+
- ehelms@redhat.com, jsherril@redhat.com
|
24
101
|
executables: []
|
25
102
|
|
26
103
|
extensions: []
|