runcible 0.1.2 → 0.1.3
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/lib/runcible/base.rb +7 -1
- data/lib/runcible/extensions/consumer.rb +2 -2
- data/lib/runcible/extensions/consumer_group.rb +71 -0
- data/lib/runcible/extensions/errata.rb +4 -2
- data/lib/runcible/extensions/repository.rb +5 -1
- data/lib/runcible/extensions/rpm.rb +1 -1
- data/lib/runcible/resources/consumer.rb +3 -3
- data/lib/runcible/resources/consumer_group.rb +42 -0
- data/lib/runcible/resources/repository.rb +3 -3
- data/lib/runcible/resources/unit.rb +2 -2
- data/lib/runcible/version.rb +1 -1
- metadata +6 -5
data/lib/runcible/base.rb
CHANGED
@@ -54,7 +54,8 @@ module Runcible
|
|
54
54
|
|
55
55
|
def self.call(method, path, options={})
|
56
56
|
clone_config = self.config.clone
|
57
|
-
path
|
57
|
+
#on occation path will already have prefix (sync cancel)
|
58
|
+
path = clone_config[:api_path] + path if !path.start_with?(clone_config[:api_path])
|
58
59
|
|
59
60
|
RestClient.log = clone_config[:logger] if clone_config[:logger]
|
60
61
|
|
@@ -106,6 +107,7 @@ module Runcible
|
|
106
107
|
else
|
107
108
|
payload = {}
|
108
109
|
end
|
110
|
+
|
109
111
|
return payload.to_json
|
110
112
|
end
|
111
113
|
|
@@ -133,10 +135,14 @@ module Runcible
|
|
133
135
|
acc
|
134
136
|
end
|
135
137
|
|
138
|
+
#The double delete is to support 1.8.7 and 1.9.3
|
139
|
+
local_names.delete(:payload)
|
140
|
+
local_names.delete(:optional)
|
136
141
|
local_names.delete("payload")
|
137
142
|
local_names.delete("optional")
|
138
143
|
keys_to_remove.each do |key|
|
139
144
|
local_names.delete(key)
|
145
|
+
local_names.delete(key.to_sym)
|
140
146
|
end
|
141
147
|
|
142
148
|
return local_names
|
@@ -28,14 +28,14 @@ module Runcible
|
|
28
28
|
|
29
29
|
def self.bind_all(id, repo_id)
|
30
30
|
# bind the consumer to all repositories with the given repo_id
|
31
|
-
Runcible::Extensions::Repository.
|
31
|
+
Runcible::Extensions::Repository.retrieve_with_details(repo_id)['distributors'].each do |d|
|
32
32
|
self.bind(id, repo_id, d['id'])
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.unbind_all(id, repo_id)
|
37
37
|
# unbind the consumer from all repositories with the given repo_id
|
38
|
-
Runcible::Extensions::Repository.
|
38
|
+
Runcible::Extensions::Repository.retrieve_with_details(repo_id)['distributors'].each do |d|
|
39
39
|
self.unbind(id, repo_id, d['id'])
|
40
40
|
end
|
41
41
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Copyright (c) 2012
|
2
|
+
#
|
3
|
+
# MIT License
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
|
25
|
+
module Runcible
|
26
|
+
module Extensions
|
27
|
+
class ConsumerGroup < Runcible::Resources::ConsumerGroup
|
28
|
+
def self.add_consumers_by_id(id, consumer_ids)
|
29
|
+
self.associate(id, make_consumer_criteria(consumer_ids))
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.remove_consumers_by_id(id, consumer_ids)
|
33
|
+
self.unassociate(id, make_consumer_criteria(consumer_ids))
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def self.make_consumer_criteria(consumer_ids)
|
38
|
+
{:criteria =>
|
39
|
+
{:filters =>
|
40
|
+
{:id =>{"$in" =>consumer_ids}}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.install_content(id, type_id, units)
|
47
|
+
self.install_units(id, generate_content(type_id, units))
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.update_content(id, type_id, units)
|
51
|
+
self.update_units(id, generate_content(type_id, units))
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.uninstall_content(id, type_id, units)
|
55
|
+
self.uninstall_units(id, generate_content(type_id, units))
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.generate_content(type_id, units)
|
59
|
+
content = []
|
60
|
+
units.each do |unit|
|
61
|
+
content_unit = {}
|
62
|
+
content_unit[:type_id] = type_id
|
63
|
+
content_unit[:unit_key] = { :name => unit }
|
64
|
+
content.push(content_unit)
|
65
|
+
end
|
66
|
+
content
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -36,11 +36,13 @@ module Runcible
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.find_all(ids)
|
39
|
-
Runcible::Resources::Unit.search(TYPE, :filters=>
|
39
|
+
Runcible::Resources::Unit.search(TYPE, {:filters=>{:id=> {'$in'=> ids}}},
|
40
|
+
{:include_repos => true})
|
40
41
|
end
|
41
42
|
|
42
43
|
def self.find_all_by_unit_ids(ids)
|
43
|
-
Runcible::Resources::Unit.search(TYPE, :filters=> {:_id=> {'$in'=> ids}}
|
44
|
+
Runcible::Resources::Unit.search(TYPE, {:filters=> {:_id=> {'$in'=> ids}}},
|
45
|
+
{:include_repos=>true})
|
44
46
|
end
|
45
47
|
|
46
48
|
end
|
@@ -223,11 +223,15 @@ module Runcible
|
|
223
223
|
|
224
224
|
def self.publish_all(repo_id)
|
225
225
|
to_ret = []
|
226
|
-
self.
|
226
|
+
self.retrieve_with_details(repo_id)['distributors'].each do |d|
|
227
227
|
to_ret << self.publish(repo_id, d['id'])
|
228
228
|
end
|
229
229
|
to_ret
|
230
230
|
end
|
231
|
+
|
232
|
+
def self.retrieve_with_details(repo_id)
|
233
|
+
self.retrieve(repo_id, {:details => true})
|
234
|
+
end
|
231
235
|
end
|
232
236
|
end
|
233
237
|
end
|
@@ -79,17 +79,17 @@ module Runcible
|
|
79
79
|
call(:get, path("#{id}/bindings/"))
|
80
80
|
end
|
81
81
|
|
82
|
-
def self.install_units(id, units, options=
|
82
|
+
def self.install_units(id, units, options={})
|
83
83
|
required = required_params(binding.send(:local_variables), binding, ["id"])
|
84
84
|
call(:post, path("#{id}/actions/content/install/"), :payload => { :required => required })
|
85
85
|
end
|
86
86
|
|
87
|
-
def self.update_units(id, units, options=
|
87
|
+
def self.update_units(id, units, options={})
|
88
88
|
required = required_params(binding.send(:local_variables), binding, ["id"])
|
89
89
|
call(:post, path("#{id}/actions/content/update/"), :payload => { :required => required })
|
90
90
|
end
|
91
91
|
|
92
|
-
def self.uninstall_units(id, units, options=
|
92
|
+
def self.uninstall_units(id, units, options={})
|
93
93
|
required = required_params(binding.send(:local_variables), binding, ["id"])
|
94
94
|
call(:post, path("#{id}/actions/content/uninstall/"), :payload => { :required => required })
|
95
95
|
end
|
@@ -44,6 +44,48 @@ module Runcible
|
|
44
44
|
def self.retrieve(id)
|
45
45
|
call(:get, path(id))
|
46
46
|
end
|
47
|
+
|
48
|
+
|
49
|
+
def self.associate(id, criteria)
|
50
|
+
call(:post, path(id) + "actions/associate/", :payload => {:required => criteria})
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.unassociate(id, criteria)
|
54
|
+
call(:post, path(id) + "actions/unassociate/", :payload => {:required => criteria})
|
55
|
+
end
|
56
|
+
|
57
|
+
#def self.retrieve_binding(id, repo_id, distributor_id)
|
58
|
+
# call(:get, path("#{id}/bindings/#{repo_id}/#{distributor_id}"))
|
59
|
+
#end
|
60
|
+
#
|
61
|
+
#def self.retrieve_bindings(id)
|
62
|
+
# call(:get, path("#{id}/bindings/"))
|
63
|
+
#end
|
64
|
+
#
|
65
|
+
#def self.bind(id, repo_id, distributor_id)
|
66
|
+
# required = required_params(binding.send(:local_variables), binding, ["id"])
|
67
|
+
# call(:post, path("#{id}/bindings"), :payload => { :required => required })
|
68
|
+
#end
|
69
|
+
#
|
70
|
+
#def self.unbind(id, repo_id, distributor_id)
|
71
|
+
# call(:delete, path("#{id}/bindings/#{repo_id}/#{distributor_id}"))
|
72
|
+
#end
|
73
|
+
|
74
|
+
def self.install_units(id, units, options={})
|
75
|
+
required = required_params(binding.send(:local_variables), binding, ["id"])
|
76
|
+
call(:post, path("#{id}/actions/content/install/"), :payload => { :required => required })
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.update_units(id, units, options={})
|
80
|
+
required = required_params(binding.send(:local_variables), binding, ["id"])
|
81
|
+
call(:post, path("#{id}/actions/content/update/"), :payload => { :required => required })
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.uninstall_units(id, units, options={})
|
85
|
+
required = required_params(binding.send(:local_variables), binding, ["id"])
|
86
|
+
call(:post, path("#{id}/actions/content/uninstall/"), :payload => { :required => required })
|
87
|
+
end
|
88
|
+
|
47
89
|
end
|
48
90
|
end
|
49
91
|
end
|
@@ -36,8 +36,8 @@ module Runcible
|
|
36
36
|
call(:post, path, :payload => { :required => required, :optional => optional })
|
37
37
|
end
|
38
38
|
|
39
|
-
def self.retrieve(id,
|
40
|
-
call(:get, path(id)
|
39
|
+
def self.retrieve(id, params={})
|
40
|
+
call(:get, path(id), :params => params)
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.update(id, optional={})
|
@@ -72,7 +72,7 @@ module Runcible
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def self.sync_history(id)
|
75
|
-
|
75
|
+
call(:get, "#{path(id)}/history/sync/")
|
76
76
|
end
|
77
77
|
|
78
78
|
def self.unit_copy(destination_repo_id, source_repo_id, optional={:criteria=>{}})
|
@@ -6,8 +6,8 @@ module Runcible
|
|
6
6
|
"content/units/#{type}/search/"
|
7
7
|
end
|
8
8
|
|
9
|
-
def self.search(type, criteria)
|
10
|
-
call(:post, path(type), :payload=>{:required=>{:criteria=>criteria}})
|
9
|
+
def self.search(type, criteria, optional={})
|
10
|
+
call(:post, path(type), :payload=>{:required=>{:criteria=>criteria}, :optional=>optional})
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
data/lib/runcible/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runcible
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eric D Helms
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-11-02 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: Exposing Pulp's juiciest components to the Ruby world.
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- lib/runcible/extensions/distribution.rb
|
40
40
|
- lib/runcible/extensions/consumer.rb
|
41
41
|
- lib/runcible/extensions/yum_distributor.rb
|
42
|
+
- lib/runcible/extensions/consumer_group.rb
|
42
43
|
- lib/runcible/extensions/repository.rb
|
43
44
|
- lib/runcible/extensions/package_category.rb
|
44
45
|
- lib/runcible/version.rb
|
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
81
|
requirements: []
|
81
82
|
|
82
83
|
rubyforge_project:
|
83
|
-
rubygems_version: 1.8.
|
84
|
+
rubygems_version: 1.8.24
|
84
85
|
signing_key:
|
85
86
|
specification_version: 3
|
86
87
|
summary: ""
|