runcible 0.0.7 → 0.1.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/lib/runcible.rb +2 -0
- data/lib/runcible/base.rb +33 -11
- data/lib/runcible/extensions/consumer.rb +67 -0
- data/lib/runcible/extensions/distribution.rb +24 -0
- data/lib/runcible/extensions/distributor.rb +39 -0
- data/lib/runcible/extensions/errata.rb +24 -0
- data/lib/runcible/extensions/importer.rb +38 -0
- data/lib/runcible/extensions/package_category.rb +24 -0
- data/lib/runcible/extensions/package_group.rb +24 -0
- data/lib/runcible/extensions/repository.rb +175 -16
- data/lib/runcible/extensions/rpm.rb +19 -0
- data/lib/runcible/extensions/yum_distributor.rb +56 -0
- data/lib/runcible/extensions/yum_importer.rb +44 -0
- data/lib/runcible/resources/consumer.rb +89 -0
- data/lib/runcible/resources/event_notifier.rb +36 -0
- data/lib/runcible/resources/repository.rb +29 -7
- data/lib/runcible/resources/repository_schedule.rb +56 -0
- data/lib/runcible/resources/role.rb +1 -3
- data/lib/runcible/resources/task.rb +12 -6
- data/lib/runcible/resources/unit.rb +17 -0
- data/lib/runcible/resources/user.rb +5 -1
- data/lib/runcible/version.rb +1 -1
- metadata +19 -5
data/lib/runcible.rb
CHANGED
@@ -25,5 +25,7 @@ require "runcible/version"
|
|
25
25
|
require "runcible/base"
|
26
26
|
|
27
27
|
resources = Dir[File.dirname(__FILE__) + '/runcible/resources/*.rb']
|
28
|
+
resources += Dir[File.dirname(__FILE__) + '/runcible/extensions/importer.rb']
|
29
|
+
resources += Dir[File.dirname(__FILE__) + '/runcible/extensions/distributor.rb']
|
28
30
|
resources += Dir[File.dirname(__FILE__) + '/runcible/extensions/*.rb']
|
29
31
|
resources.each{ |f| require f }
|
data/lib/runcible/base.rb
CHANGED
@@ -53,19 +53,23 @@ module Runcible
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def self.call(method, path, options={})
|
56
|
-
|
56
|
+
clone_config = self.config.clone
|
57
|
+
path = clone_config[:api_path] + path
|
57
58
|
|
58
|
-
RestClient.log =
|
59
|
+
RestClient.log = clone_config[:logger] if clone_config[:logger]
|
59
60
|
|
60
|
-
headers =
|
61
|
-
headers[:params] = options[:params] if options[:params]
|
61
|
+
headers = clone_config[:headers].clone
|
62
62
|
|
63
|
-
if
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
get_params = options[:params] if options[:params]
|
64
|
+
path = combine_get_params(path, get_params) if get_params
|
65
|
+
|
66
|
+
|
67
|
+
if clone_config[:oauth]
|
68
|
+
headers = add_oauth_header(method, path, headers) if clone_config[:oauth]
|
69
|
+
headers["pulp-user"] = clone_config[:user]
|
70
|
+
client = RestClient::Resource.new(clone_config[:url])
|
67
71
|
else
|
68
|
-
client = RestClient::Resource.new(
|
72
|
+
client = RestClient::Resource.new(clone_config[:url], :user => clone_config[:user], :password => config[:http_auth][:password])
|
69
73
|
end
|
70
74
|
|
71
75
|
args = [method]
|
@@ -75,6 +79,17 @@ module Runcible
|
|
75
79
|
process_response(client[path].send(*args))
|
76
80
|
end
|
77
81
|
|
82
|
+
def self.combine_get_params(path, params)
|
83
|
+
query_string = params.collect do |k, v|
|
84
|
+
if v.is_a? Array
|
85
|
+
v.collect{|y| "#{k.to_s}=#{y.to_s}" }.join('&')
|
86
|
+
else
|
87
|
+
"#{k.to_s}=#{v.to_s}"
|
88
|
+
end
|
89
|
+
end.flatten().join('&')
|
90
|
+
path + "?#{query_string}"
|
91
|
+
end
|
92
|
+
|
78
93
|
def self.generate_payload(options)
|
79
94
|
if options[:payload]
|
80
95
|
if options[:payload][:optional]
|
@@ -91,13 +106,20 @@ module Runcible
|
|
91
106
|
else
|
92
107
|
payload = {}
|
93
108
|
end
|
94
|
-
|
95
109
|
return payload.to_json
|
96
110
|
end
|
97
111
|
|
98
112
|
def self.process_response(response)
|
99
113
|
begin
|
100
|
-
|
114
|
+
body = JSON.parse(response.body)
|
115
|
+
if body.respond_to? :with_indifferent_access
|
116
|
+
body = body.with_indifferent_access
|
117
|
+
elsif body.is_a? Array
|
118
|
+
body = body.collect do |i|
|
119
|
+
i.respond_to?(:with_indifferent_access) ? i.with_indifferent_access : i
|
120
|
+
end
|
121
|
+
end
|
122
|
+
response = RestClient::Response.create(body, response.net_http_res, response.args)
|
101
123
|
rescue JSON::ParserError
|
102
124
|
end
|
103
125
|
|
@@ -0,0 +1,67 @@
|
|
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 Consumer < Runcible::Resources::Consumer
|
28
|
+
|
29
|
+
def self.bind_all(id, repo_id)
|
30
|
+
# bind the consumer to all repositories with the given repo_id
|
31
|
+
Runcible::Extensions::Repository.retrieve(repo_id)['distributors'].each do |d|
|
32
|
+
self.bind(id, repo_id, d['id'])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.unbind_all(id, repo_id)
|
37
|
+
# unbind the consumer from all repositories with the given repo_id
|
38
|
+
Runcible::Extensions::Repository.retrieve(repo_id)['distributors'].each do |d|
|
39
|
+
self.unbind(id, repo_id, d['id'])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.install(id, type_id, units)
|
44
|
+
self.install_content(id, generate_content(type_id, units))
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.update(id, type_id, units)
|
48
|
+
self.update_content(id, generate_content(type_id, units))
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.uninstall(id, type_id, units)
|
52
|
+
self.uninstall_content(id, generate_content(type_id, units))
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.generate_content(type_id, units)
|
56
|
+
content = []
|
57
|
+
units.each do |unit|
|
58
|
+
content_unit = {}
|
59
|
+
content_unit[:type_id] = type_id
|
60
|
+
content_unit[:unit_key] = { :name => unit }
|
61
|
+
content.push(content_unit)
|
62
|
+
end
|
63
|
+
content
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Runcible
|
2
|
+
module Extensions
|
3
|
+
class Distribution < Runcible::Base
|
4
|
+
TYPE = 'distribution'
|
5
|
+
|
6
|
+
def self.all()
|
7
|
+
Runcible::Resources::Unit.search(TYPE, {})
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.find(id)
|
11
|
+
find_all([id]).first
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.find_all(ids)
|
15
|
+
Runcible::Resources::Unit.search(TYPE, :filters=> {:id=> {'$in'=> ids}})
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.find_all_by_unit_ids(ids)
|
19
|
+
Runcible::Resources::Unit.search(TYPE, :filters=> {:_id=> {'$in'=> ids}})
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (c) 2012 Justin Sherrill
|
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
|
+
require 'active_support/json'
|
25
|
+
require 'securerandom'
|
26
|
+
|
27
|
+
module Runcible
|
28
|
+
module Extensions
|
29
|
+
class Distributor
|
30
|
+
attr_accessor 'auto_publish', 'id'
|
31
|
+
|
32
|
+
def initialize(params={})
|
33
|
+
@auto_publish = false
|
34
|
+
self.id = SecureRandom.hex(10)
|
35
|
+
params.each{|k,v| self.send("#{k.to_s}=",v)}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Runcible
|
2
|
+
module Extensions
|
3
|
+
class Errata < Runcible::Base
|
4
|
+
TYPE = 'erratum'
|
5
|
+
|
6
|
+
def self.all()
|
7
|
+
Runcible::Resources::Unit.search(TYPE, {})
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.find(id)
|
11
|
+
find_all([id]).first
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.find_all(ids)
|
15
|
+
Runcible::Resources::Unit.search(TYPE, :filters=> {:id=> {'$in'=> ids}})
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.find_all_by_unit_ids(ids)
|
19
|
+
Runcible::Resources::Unit.search(TYPE, :filters=> {:_id=> {'$in'=> ids}})
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Copyright (c) 2012 Justin Sherrill
|
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
|
+
require 'active_support/core_ext/hash'
|
25
|
+
require 'active_support/json'
|
26
|
+
|
27
|
+
|
28
|
+
module Runcible
|
29
|
+
module Extensions
|
30
|
+
#Importers should supply id & config methods
|
31
|
+
class Importer
|
32
|
+
def initialize(params={})
|
33
|
+
params.each{|k,v| self.send("#{k.to_s}=",v)}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Runcible
|
2
|
+
module Extensions
|
3
|
+
class PackageCategory < Runcible::Base
|
4
|
+
TYPE = 'package_category'
|
5
|
+
|
6
|
+
def self.all
|
7
|
+
Runcible::Resources::Unit.search(TYPE, {})
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.find(id)
|
11
|
+
find_all([id]).first
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.find_all(ids)
|
15
|
+
Runcible::Resources::Unit.search(TYPE, :filters => {'id'=> {'$in'=> ids}})
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.find_all_by_unit_ids(ids)
|
19
|
+
Runcible::Resources::Unit.search(TYPE, :filters => {:_id=> {'$in'=> ids}})
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Runcible
|
2
|
+
module Extensions
|
3
|
+
class PackageGroup < Runcible::Base
|
4
|
+
TYPE = 'package_group'
|
5
|
+
|
6
|
+
def self.all
|
7
|
+
Runcible::Resources::Unit.search(TYPE, {})
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.find(id)
|
11
|
+
find_all([id]).first
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.find_all(ids)
|
15
|
+
Runcible::Resources::Unit.search(TYPE, :filters => {'id'=> {'$in'=> ids}})
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.find_all_by_unit_ids(ids)
|
19
|
+
Runcible::Resources::Unit.search(TYPE, :filters => {:_id=> {'$in'=> ids}})
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -21,26 +21,42 @@
|
|
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
|
-
require 'runcible/resources/repository'
|
25
|
-
|
26
24
|
|
27
25
|
module Runcible
|
28
|
-
module
|
29
|
-
class
|
26
|
+
module Extensions
|
27
|
+
class Repository < Runcible::Resources::Repository
|
30
28
|
|
31
|
-
def self.create_with_importer(id,
|
32
|
-
|
33
|
-
create(id, required)
|
29
|
+
def self.create_with_importer(id, importer)
|
30
|
+
create_with_importer_and_distributors(id, importer)
|
34
31
|
end
|
35
32
|
|
36
33
|
def self.create_with_distributors(id, distributors)
|
37
|
-
|
38
|
-
|
34
|
+
create_with_importer_and_distributors(id, nil, distributors)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.create_with_importer_and_distributors(id, importer, distributors=[], optional={})
|
38
|
+
if importer.is_a?(Importer)
|
39
|
+
optional[:importer_type_id] = importer.id
|
40
|
+
optional[:importer_config] = importer.config
|
41
|
+
else
|
42
|
+
optional[:importer_type_id] = importer.delete('id') || importer.delete(:id)
|
43
|
+
optional[:importer_config] = importer
|
44
|
+
end if importer
|
45
|
+
|
46
|
+
optional[:distributors] = distributors.collect do |d|
|
47
|
+
if d.is_a?(Distributor)
|
48
|
+
[d.type_id, d.config, d.auto_publish, d.id]
|
49
|
+
else
|
50
|
+
[d['type_id'], d['config'], d['auto_publish'], d['id']]
|
51
|
+
end
|
52
|
+
end if !distributors.empty?
|
53
|
+
optional[:id] = id
|
54
|
+
#debugger
|
55
|
+
create(id, optional)
|
39
56
|
end
|
40
57
|
|
41
|
-
def self.
|
42
|
-
|
43
|
-
create(id, required)
|
58
|
+
def self.sync_status(repo_id)
|
59
|
+
Runcible::Resources::Task.list(["pulp:repository:#{repo_id}", "pulp:action:sync"])
|
44
60
|
end
|
45
61
|
|
46
62
|
def self.search_by_repository_ids(repository_ids)
|
@@ -50,18 +66,161 @@ module Runcible
|
|
50
66
|
search(criteria)
|
51
67
|
end
|
52
68
|
|
53
|
-
|
69
|
+
# optional
|
70
|
+
# :package_ids
|
71
|
+
# :name_blacklist
|
72
|
+
def self.rpm_copy(source_repo_id, destination_repo_id, optional={})
|
73
|
+
|
54
74
|
criteria = {:type_ids => ['rpm'], :filters => {}}
|
55
|
-
criteria[:filters]['association'] = {'unit_id' => {'$in' => package_ids}} if optional[:package_ids]
|
56
|
-
criteria[:filters]['unit'] = { 'name' => {'$not' => {'$in' => name_blacklist}}} if optional[:name_blacklist]
|
75
|
+
criteria[:filters]['association'] = {'unit_id' => {'$in' => optional[:package_ids]}} if optional[:package_ids]
|
76
|
+
criteria[:filters]['unit'] = { 'name' => {'$not' => {'$in' => optional[:name_blacklist]}}} if optional[:name_blacklist]
|
57
77
|
|
78
|
+
payload = {:criteria=>criteria}
|
79
|
+
payload[:override_config] = optional[:override_config] if optional[:override_config]
|
80
|
+
unit_copy(destination_repo_id, source_repo_id, payload)
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.rpm_remove(repo_id, package_ids)
|
84
|
+
criteria = {:type_ids => ['rpm'], :filters => {}}
|
85
|
+
criteria[:filters]['association'] = {'unit_id' => {'$in' => package_ids}}
|
58
86
|
payload = {}
|
59
87
|
payload[:criteria] = criteria
|
60
|
-
payload
|
88
|
+
self.unassociate_units(repo_id, payload)
|
89
|
+
end
|
90
|
+
|
91
|
+
#optional
|
92
|
+
# errata_ids
|
93
|
+
def self.errata_copy(source_repo_id, destination_repo_id, optional={})
|
94
|
+
criteria = {:type_ids => ['erratum'], :filters => {}}
|
95
|
+
criteria[:filters][:unit] = { :id=>{ '$in' => optional[:errata_ids] } } if optional[:errata_ids]
|
96
|
+
payload = {:criteria => criteria}
|
97
|
+
unit_copy(destination_repo_id, source_repo_id, payload)
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.errata_remove(repo_id, errata_ids)
|
101
|
+
criteria = {:type_ids => ['erratum'], :filters => {}}
|
102
|
+
criteria[:filters][:unit] = { :id=>{ '$in' => errata_ids } }
|
103
|
+
payload = {:criteria => criteria}
|
104
|
+
self.unassociate_units(repo_id, payload)
|
105
|
+
end
|
61
106
|
|
107
|
+
#optoinal
|
108
|
+
# distribution_ids
|
109
|
+
def self.distribution_copy(source_repo_id, destination_repo_id, optional={})
|
110
|
+
criteria = {:type_ids => ['distribution'], :filters => {}}
|
111
|
+
criteria[:filters][:unit] = { :id=>{ '$in' => optional[:distribution_ids] } } if optional[:distribution_ids]
|
112
|
+
payload = {:criteria => criteria}
|
62
113
|
unit_copy(destination_repo_id, source_repo_id, payload)
|
63
114
|
end
|
64
115
|
|
116
|
+
def self.distribution_remove(repo_id, distribution_id)
|
117
|
+
criteria = {:type_ids => ['distribution'], :filters => {}}
|
118
|
+
criteria[:filters][:unit] = { :id=>{ '$in' => [distribution_id] } }
|
119
|
+
payload = {:criteria => criteria}
|
120
|
+
self.unassociate_units(repo_id, payload)
|
121
|
+
end
|
122
|
+
|
123
|
+
def self.rpm_ids(id)
|
124
|
+
criteria = {:type_ids=>['rpm'],
|
125
|
+
:sort => {
|
126
|
+
:unit => [ ['name', 'ascending'], ['version', 'descending'] ]
|
127
|
+
}}
|
128
|
+
self.unit_search(id, criteria).collect{|i| i['unit_id']}
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.rpms(id)
|
132
|
+
criteria = {:type_ids=>['rpm'],
|
133
|
+
:sort => {
|
134
|
+
:unit => [ ['name', 'ascending'], ['version', 'descending'] ]
|
135
|
+
}}
|
136
|
+
self.unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
|
137
|
+
end
|
138
|
+
|
139
|
+
def self.packages_by_nvre(id, name, version=nil, release=nil, epoch=nil)
|
140
|
+
and_condition = []
|
141
|
+
and_condition << {:name=>name} if name
|
142
|
+
and_condition << {:version=>version} if version
|
143
|
+
and_condition << {:release=>release} if release
|
144
|
+
and_condition << {:epoch=>epoch} if epoch
|
145
|
+
|
146
|
+
criteria = {:type_ids=>['rpm'],
|
147
|
+
:filters => {
|
148
|
+
:unit => {
|
149
|
+
"$and" => and_condition
|
150
|
+
}
|
151
|
+
},
|
152
|
+
:sort => {
|
153
|
+
:unit => [ ['name', 'ascending'], ['version', 'descending'] ]
|
154
|
+
}}
|
155
|
+
self.unit_search(id, criteria).collect{|p| p['metadata'].with_indifferent_access}
|
156
|
+
end
|
157
|
+
|
158
|
+
def self.errata_ids(id, filter = {})
|
159
|
+
criteria = {
|
160
|
+
:type_ids=>['erratum'],
|
161
|
+
:sort => {
|
162
|
+
:unit => [ ['title', 'ascending'] ]
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
166
|
+
self.unit_search(id, criteria).collect{|i| i['unit_id']}
|
167
|
+
end
|
168
|
+
|
169
|
+
def self.distributions(id)
|
170
|
+
criteria = {
|
171
|
+
:type_ids=>['distribution'],
|
172
|
+
:sort => {
|
173
|
+
:unit => [ ['id', 'ascending'] ]
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
self.unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
|
178
|
+
end
|
179
|
+
|
180
|
+
def self.package_groups(id)
|
181
|
+
criteria = {
|
182
|
+
:type_ids=>[Runcible::Extensions::PackageGroup::TYPE],
|
183
|
+
:sort => {
|
184
|
+
:unit => [ ['id', 'ascending'] ]
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
self.unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
|
189
|
+
end
|
190
|
+
|
191
|
+
def self.package_categories(id)
|
192
|
+
criteria = {
|
193
|
+
:type_ids=>[Runcible::Extensions::PackageCategory::TYPE],
|
194
|
+
:sort => {
|
195
|
+
:unit => [ ['id', 'ascending'] ]
|
196
|
+
}
|
197
|
+
}
|
198
|
+
self.unit_search(id, criteria).collect{|i| i['metadata'].with_indifferent_access}
|
199
|
+
end
|
200
|
+
|
201
|
+
def self.create_or_update_schedule(repo_id, type, schedule)
|
202
|
+
schedules = Runcible::Resources::RepositorySchedule.list(repo_id, type)
|
203
|
+
if schedules.empty?
|
204
|
+
Runcible::Resources::RepositorySchedule.create(repo_id, type, schedule)
|
205
|
+
else
|
206
|
+
Runcible::Resources::RepositorySchedule.update(repo_id, type, schedules[0]['_id'], {:schedule=>schedule})
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def self.remove_schedules(repo_id, type)
|
211
|
+
schedules = Runcible::Resources::RepositorySchedule.list(repo_id, type)
|
212
|
+
schedules.each do |schedule|
|
213
|
+
Runcible::Resources::RepositorySchedule.delete(repo_id, type, schedule['_id'])
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
def self.publish_all(repo_id)
|
218
|
+
to_ret = []
|
219
|
+
self.retrieve(repo_id)['distributors'].each do |d|
|
220
|
+
to_ret << self.publish(repo_id, d['id'])
|
221
|
+
end
|
222
|
+
to_ret
|
223
|
+
end
|
65
224
|
end
|
66
225
|
end
|
67
226
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Runcible
|
2
|
+
module Extensions
|
3
|
+
class Rpm < Runcible::Base
|
4
|
+
TYPE = 'rpm'
|
5
|
+
|
6
|
+
def self.all
|
7
|
+
Runcible::Resources::Unit.search(TYPE, {})
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.find(id)
|
11
|
+
find_all([id]).first
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.find_all(ids)
|
15
|
+
Runcible::Resources::Unit.search(TYPE, :filters => {'_id'=> {'$in'=> ids}})
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Copyright (c) 2012 Justin Sherrill
|
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
|
+
require 'active_support/json'
|
25
|
+
require 'securerandom'
|
26
|
+
|
27
|
+
module Runcible
|
28
|
+
module Extensions
|
29
|
+
class YumDistributor < Distributor
|
30
|
+
#required
|
31
|
+
attr_accessor "relative_url", "http", "https"
|
32
|
+
#optional
|
33
|
+
attr_accessor "protected", "auth_cert", "auth_ca",
|
34
|
+
"https_ca", "gpgkey", "generate_metadata",
|
35
|
+
"checksum_type", "skip", "https_publish_dir", "http_publish_dir"
|
36
|
+
|
37
|
+
def initialize(relative_url, http, https, params={})
|
38
|
+
@relative_url=relative_url
|
39
|
+
@http = http
|
40
|
+
@https = https
|
41
|
+
super(params)
|
42
|
+
end
|
43
|
+
|
44
|
+
def type_id
|
45
|
+
'yum_distributor'
|
46
|
+
end
|
47
|
+
|
48
|
+
def config
|
49
|
+
to_ret = self.as_json
|
50
|
+
to_ret.delete('auto_publish')
|
51
|
+
to_ret.delete('id')
|
52
|
+
to_ret
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Copyright (c) 2012 Justin Sherrill
|
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
|
+
module Runcible
|
25
|
+
module Extensions
|
26
|
+
class YumImporter < Importer
|
27
|
+
ID = 'yum_importer'
|
28
|
+
|
29
|
+
#https://github.com/pulp/pulp/blob/master/rpm-support/plugins/importers/yum_importer/importer.py
|
30
|
+
attr_accessor 'feed_url', 'ssl_verify', 'ssl_ca_cert', 'ssl_client_cert', 'ssl_client_key',
|
31
|
+
'proxy_url', 'proxy_port', 'proxy_pass', 'proxy_user',
|
32
|
+
'max_speed', 'verify_size', 'verify_checksum', 'num_threads',
|
33
|
+
'newest', 'remove_old', 'num_old_packages', 'purge_orphaned', 'skip', 'checksum_type',
|
34
|
+
'num_retries', 'retry_delay'
|
35
|
+
def id
|
36
|
+
YumImporter::ID
|
37
|
+
end
|
38
|
+
|
39
|
+
def config
|
40
|
+
self.as_json
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,89 @@
|
|
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 Resources
|
27
|
+
class Consumer < Runcible::Base
|
28
|
+
|
29
|
+
def self.path(id=nil)
|
30
|
+
(id == nil) ? "consumers/" : "consumers/#{id}/"
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.create(id, optional={})
|
34
|
+
required = required_params(binding.send(:local_variables), binding)
|
35
|
+
call(:post, path, :payload => { :required => required, :optional => optional })
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.retrieve(id)
|
39
|
+
call(:get, path(id))
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.update(id, optional={})
|
43
|
+
required = required_params(binding.send(:local_variables), binding)
|
44
|
+
call(:put, path(id), :payload => { :required => required, :optional => optional })
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.upload_profile(id, content_type, profile)
|
48
|
+
required = required_params(binding.send(:local_variables), binding, ["id"])
|
49
|
+
call(:post, path("#{id}/profiles/"), :payload => { :required => required })
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.profile(id, content_type)
|
53
|
+
call(:get, path("#{id}/profiles/#{content_type}/"))
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.delete(id)
|
57
|
+
call(:delete, path(id))
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.bind(id, repo_id, distributor_id)
|
61
|
+
required = required_params(binding.send(:local_variables), binding, ["id"])
|
62
|
+
call(:post, path("#{id}/bindings"), :payload => { :required => required })
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.unbind(id, repo_id, distributor_id)
|
66
|
+
call(:delete, path("#{id}/bindings/#{repo_id}/#{distributor_id}"))
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.repos(id)
|
70
|
+
call(:get, path("#{id}/bindings/"))
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.install_content(id, units, options="")
|
74
|
+
required = required_params(binding.send(:local_variables), binding, ["id"])
|
75
|
+
call(:post, path("#{id}/actions/content/install/"), :payload => { :required => required })
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.update_content(id, units, options="")
|
79
|
+
required = required_params(binding.send(:local_variables), binding, ["id"])
|
80
|
+
call(:post, path("#{id}/actions/content/update/"), :payload => { :required => required })
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.uninstall_content(id, units, options="")
|
84
|
+
required = required_params(binding.send(:local_variables), binding, ["id"])
|
85
|
+
call(:post, path("#{id}/actions/content/uninstall/"), :payload => { :required => required })
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
module Runcible
|
3
|
+
module Resources
|
4
|
+
class EventNotifier < Runcible::Base
|
5
|
+
|
6
|
+
class EventTypes
|
7
|
+
REPO_SYNC_COMPLETE = 'repo-sync-finished'
|
8
|
+
REPO_SYNC_START = 'repo-sync-started'
|
9
|
+
REPO_PUBLISH_COMPLETE = 'repo-publish-finished'
|
10
|
+
REPO_PUBLISH_START = 'repo-publish-started'
|
11
|
+
end
|
12
|
+
|
13
|
+
class NotifierTypes
|
14
|
+
REST_API = 'rest-api'
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.create(notifier_type_id, notifier_config, event_types)
|
18
|
+
required = required_params(binding.send(:local_variables), binding)
|
19
|
+
call(:post, path, :payload => {:required => required})
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.delete(id)
|
23
|
+
call(:delete, path(id))
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.list
|
27
|
+
call(:get, path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.path(id=nil)
|
31
|
+
(id == nil) ? "events/" : "events/#{id}/"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -21,11 +21,10 @@
|
|
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
|
-
require '
|
25
|
-
|
24
|
+
require 'active_support/core_ext/hash'
|
26
25
|
|
27
26
|
module Runcible
|
28
|
-
module
|
27
|
+
module Resources
|
29
28
|
class Repository < Runcible::Base
|
30
29
|
|
31
30
|
def self.path(id=nil)
|
@@ -37,8 +36,8 @@ module Runcible
|
|
37
36
|
call(:post, path, :payload => { :required => required, :optional => optional })
|
38
37
|
end
|
39
38
|
|
40
|
-
def self.retrieve(id,
|
41
|
-
call(:get, path(id)
|
39
|
+
def self.retrieve(id, details=true)
|
40
|
+
call(:get, path(id) + "?details=#{details}")
|
42
41
|
end
|
43
42
|
|
44
43
|
def self.update(id, optional={})
|
@@ -72,9 +71,32 @@ module Runcible
|
|
72
71
|
call(:post, "#{path(id)}actions/sync/", :payload => { :optional => optional })
|
73
72
|
end
|
74
73
|
|
75
|
-
def self.
|
74
|
+
def self.sync_history(id)
|
75
|
+
call(:get, "#{path(id)}/history/sync/")
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.unit_copy(destination_repo_id, source_repo_id, optional={:criteria=>{}})
|
76
79
|
required = required_params(binding.send(:local_variables), binding, ["destination_repo_id"])
|
77
|
-
call(:post, "#{path(destination_repo_id)}actions/associate/",
|
80
|
+
call(:post, "#{path(destination_repo_id)}actions/associate/",
|
81
|
+
:payload => { :required => required, :optional=> optional })
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.unassociate_units(source_repo_id, optional={})
|
85
|
+
required = required_params(binding.send(:local_variables), binding, ["source_repo_id"])
|
86
|
+
call(:post, "#{path(source_repo_id)}actions/unassociate/",
|
87
|
+
:payload => { :required => required, :optional=> optional })
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.unit_search(id, criteria={})
|
91
|
+
call(:post, "#{path(id)}search/units/", :payload=>{:required=>{:criteria=>criteria}})
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.publish(repo_id, distributor_id)
|
95
|
+
call(:post, "#{path(repo_id)}actions/publish/", :payload=>{:required=>{:id=>distributor_id}})
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.delete_distributor(repo_id, distributor_id)
|
99
|
+
call(:delete, "#{path(repo_id)}/distributors/#{distributor_id}/")
|
78
100
|
end
|
79
101
|
|
80
102
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Copyright (c) 2012 Eric D Helms
|
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
|
+
require 'active_support/core_ext/hash'
|
25
|
+
|
26
|
+
module Runcible
|
27
|
+
module Resources
|
28
|
+
class RepositorySchedule < Runcible::Base
|
29
|
+
|
30
|
+
def self.path(repo_id, importer, schedule_id=nil)
|
31
|
+
repo_path = Runcible::Resources::Repository.path(repo_id)
|
32
|
+
path = "#{repo_path}importers/#{importer}/sync_schedules/"
|
33
|
+
(schedule_id == nil) ? path : "#{path}#{schedule_id}/"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.list(repo_id, importer_type)
|
37
|
+
call(:get, path(repo_id, importer_type))
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.create(repo_id, importer_type, schedule, optional={})
|
41
|
+
call(:post, path(repo_id, importer_type),
|
42
|
+
:payload => { :required => {:schedule=>schedule}, :optional => optional })
|
43
|
+
end
|
44
|
+
|
45
|
+
# specific call to just update the sync schedule for a repo
|
46
|
+
def self.update(repo_id, importer_type, schedule_id, optional={})
|
47
|
+
call(:put, path(repo_id, importer_type, schedule_id),
|
48
|
+
:payload => {:optional => optional })
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.delete(repo_id, importer_type, schedule_id)
|
52
|
+
call(:delete, path(repo_id, importer_type, schedule_id))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
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
|
-
require 'runcible/base'
|
25
|
-
|
26
24
|
|
27
25
|
module Runcible
|
28
|
-
module
|
26
|
+
module Resources
|
29
27
|
class Role < Runcible::Base
|
30
28
|
|
31
29
|
def self.path(role=nil)
|
@@ -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
|
-
require 'runcible/base'
|
25
|
-
|
26
24
|
|
27
25
|
module Runcible
|
28
|
-
module
|
26
|
+
module Resources
|
29
27
|
class Task < Runcible::Base
|
30
28
|
|
31
29
|
def self.path(id=nil)
|
@@ -37,11 +35,19 @@ module Runcible
|
|
37
35
|
end
|
38
36
|
|
39
37
|
def self.cancel(id)
|
40
|
-
|
38
|
+
#cancelling a task may require cancelling some higher level
|
39
|
+
# task, so query the tasks _href field to make sure
|
40
|
+
call(:delete, poll(id)['_href'])
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.list(tags=[])
|
44
|
+
call(:get, path, :params=>{:tag=>tags})
|
41
45
|
end
|
42
46
|
|
43
|
-
def self.
|
44
|
-
|
47
|
+
def self.poll_all(ids)
|
48
|
+
# temporary solution until https://bugzilla.redhat.com/show_bug.cgi?id=860089
|
49
|
+
# is resolved
|
50
|
+
return ids.collect{|id| self.poll(id)}
|
45
51
|
end
|
46
52
|
|
47
53
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Runcible
|
2
|
+
module Resources
|
3
|
+
class Unit < Runcible::Base
|
4
|
+
|
5
|
+
def self.path(type)
|
6
|
+
"content/units/#{type}/search/"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.search(type, criteria)
|
10
|
+
call(:post, path(type), :payload=>{:required=>{:criteria=>criteria}})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -23,13 +23,17 @@
|
|
23
23
|
|
24
24
|
|
25
25
|
module Runcible
|
26
|
-
module
|
26
|
+
module Resources
|
27
27
|
class User < Runcible::Base
|
28
28
|
|
29
29
|
def self.path(login=nil)
|
30
30
|
(login == nil) ? "users/" : "users/#{login}/"
|
31
31
|
end
|
32
32
|
|
33
|
+
def self.retrieve_all
|
34
|
+
call(:get, path)
|
35
|
+
end
|
36
|
+
|
33
37
|
def self.create(login, optional={})
|
34
38
|
required = required_params(binding.send(:local_variables), binding)
|
35
39
|
call(:post, path, :payload => { :required => required, :optional => optional })
|
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: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.7
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eric D Helms
|
@@ -15,10 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-09
|
18
|
+
date: 2012-10-09 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
|
-
description:
|
21
|
+
description: Exposing Pulp's juiciest components to the Ruby world.
|
22
22
|
email:
|
23
23
|
- ehelms@redhat.com
|
24
24
|
executables: []
|
@@ -30,12 +30,26 @@ extra_rdoc_files: []
|
|
30
30
|
files:
|
31
31
|
- lib/runcible.rb
|
32
32
|
- lib/runcible/base.rb
|
33
|
+
- lib/runcible/extensions/errata.rb
|
34
|
+
- lib/runcible/extensions/importer.rb
|
35
|
+
- lib/runcible/extensions/yum_importer.rb
|
36
|
+
- lib/runcible/extensions/distributor.rb
|
37
|
+
- lib/runcible/extensions/rpm.rb
|
38
|
+
- lib/runcible/extensions/package_group.rb
|
39
|
+
- lib/runcible/extensions/distribution.rb
|
40
|
+
- lib/runcible/extensions/consumer.rb
|
41
|
+
- lib/runcible/extensions/yum_distributor.rb
|
33
42
|
- lib/runcible/extensions/repository.rb
|
43
|
+
- lib/runcible/extensions/package_category.rb
|
34
44
|
- lib/runcible/version.rb
|
45
|
+
- lib/runcible/resources/repository_schedule.rb
|
46
|
+
- lib/runcible/resources/event_notifier.rb
|
35
47
|
- lib/runcible/resources/task.rb
|
48
|
+
- lib/runcible/resources/consumer.rb
|
36
49
|
- lib/runcible/resources/user.rb
|
37
50
|
- lib/runcible/resources/role.rb
|
38
51
|
- lib/runcible/resources/repository.rb
|
52
|
+
- lib/runcible/resources/unit.rb
|
39
53
|
homepage: https://github.com/Katello/runcible
|
40
54
|
licenses: []
|
41
55
|
|