runcible 0.0.1
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/.gitignore +18 -0
- data/Gemfile +19 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +37 -0
- data/lib/runcible.rb +25 -0
- data/lib/runcible/base.rb +113 -0
- data/lib/runcible/extensions/repository.rb +67 -0
- data/lib/runcible/oauth_setup.rb +29 -0
- data/lib/runcible/resources/repository.rb +82 -0
- data/lib/runcible/resources/role.rb +46 -0
- data/lib/runcible/resources/task.rb +49 -0
- data/lib/runcible/resources/user.rb +50 -0
- data/lib/runcible/version.rb +3 -0
- data/rel-eng/packages/.readme +3 -0
- data/rel-eng/tito.props +5 -0
- data/runcible.gemspec +17 -0
- data/runcible.spec +48 -0
- data/test/.gitkeep +0 -0
- data/test/integration/extensions/repository_test.rb +117 -0
- data/test/integration/fixtures/repositories/zoo5/.treeinfo +12 -0
- data/test/integration/fixtures/repositories/zoo5/CHANGESET +11 -0
- data/test/integration/fixtures/repositories/zoo5/PULP_MANIFEST +1 -0
- data/test/integration/fixtures/repositories/zoo5/cheetah-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/create.sh +20 -0
- data/test/integration/fixtures/repositories/zoo5/elephant-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/empty.iso +0 -0
- data/test/integration/fixtures/repositories/zoo5/giraffe-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/images/test1.img +0 -0
- data/test/integration/fixtures/repositories/zoo5/images/test2.img +0 -0
- data/test/integration/fixtures/repositories/zoo5/lion-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/monkey-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/penguin-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/06661e2a9839cf0beebcf409410ca4f93c09081f4e772fd0d03e1faf62705a11-comps.xml +39 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/0c4d57a68f9a3b13dabc6f8b01ca8958aa796167cececee04717edfc26d02f2d-other.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/298ce23f48b3613e030d19f3d9c2ff2df31c2f08479bdf94cebb87c208e48c0e-filelists.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/32c0e38317aade0c057b173ff62344e912e1bd650409c6ac31aecee78e3413af-comps.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/34d954906c7ce7aa2254e24d7be0a9049e0a2f436add023ca056123a2d48e30e-updateinfo.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/63aedd074d9f0daf7c6be8c61f91d76a962bb6ceda86b9abd2140f154c320fa2-other.sqlite.bz2 +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/69d65cdebffc6199d3adb3e38b06ca9abaae6c1c7366805099987b28f182178d-filelists.sqlite.bz2 +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/799241a518a4a6b11a68f8e6fbdb719875f87832f60accc0851ced0d6a0497c6-updateinfo.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/a4ea9fcdce31dc8673c7a9ba66c086bd6a16e1eff717e3896dd1cac444a1423c-primary.xml.gz +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/fb9b9508e148368d0edf7e03dc905b343937fd958e6531cce6380933d18c3455-primary.sqlite.bz2 +0 -0
- data/test/integration/fixtures/repositories/zoo5/repodata/repomd.xml +75 -0
- data/test/integration/fixtures/repositories/zoo5/squirrel-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/repositories/zoo5/updateinfo.xml +26 -0
- data/test/integration/fixtures/repositories/zoo5/walrus-0.3-0.8.noarch.rpm +0 -0
- data/test/integration/fixtures/vcr_cassettes/extensions/pulp_repository_extensions.yml +137 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_consumer.yml +1529 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_consumer_group.yml +430 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_consumer_helper.yml +120 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_distribution.yml +77 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_errata.yml +77 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_filter.yml +233 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_filter_helper.yml +81 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_package.yml +155 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_package_group.yml +40 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_package_group_category.yml +40 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_ping.yml +40 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_repository.yml +1196 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_repository_helper.yml +8659 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_repository_sync.yml +215 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_role.yml +133 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_roles.yml +120 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_task.yml +943 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_user.yml +288 -0
- data/test/integration/fixtures/vcr_cassettes/pulp_user_helper.yml +195 -0
- data/test/integration/resources/helpers/consumer_helper.rb +49 -0
- data/test/integration/resources/helpers/filter_helper.rb +44 -0
- data/test/integration/resources/helpers/repository_helper.rb +127 -0
- data/test/integration/resources/pulp_consumer_group_test.rb +182 -0
- data/test/integration/resources/pulp_consumer_test.rb +200 -0
- data/test/integration/resources/pulp_distribution_test.rb +55 -0
- data/test/integration/resources/pulp_errata_test.rb +60 -0
- data/test/integration/resources/pulp_filter_test.rb +92 -0
- data/test/integration/resources/pulp_package_group_category_test.rb +55 -0
- data/test/integration/resources/pulp_package_group_test.rb +56 -0
- data/test/integration/resources/pulp_package_test.rb +79 -0
- data/test/integration/resources/pulp_ping_test.rb +31 -0
- data/test/integration/resources/pulp_repository_test.rb +307 -0
- data/test/integration/resources/pulp_role_test.rb +62 -0
- data/test/integration/resources/pulp_task_test.rb +79 -0
- data/test/integration/resources/pulp_user_test.rb +105 -0
- data/test/integration/test_runner.rb +113 -0
- data/test/integration/vcr_setup.rb +22 -0
- data/test/unit/test_base.rb +62 -0
- metadata +218 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Specify your gem's dependencies in runcible.gemspec
|
|
4
|
+
gemspec
|
|
5
|
+
|
|
6
|
+
gem 'json'
|
|
7
|
+
gem 'rest-client', '>= 1.6.1'
|
|
8
|
+
gem 'oauth'
|
|
9
|
+
|
|
10
|
+
group :development, :test do
|
|
11
|
+
gem 'ruby-debug'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
group :test do
|
|
15
|
+
gem 'vcr'
|
|
16
|
+
gem 'webmock'
|
|
17
|
+
gem 'minitest'
|
|
18
|
+
gem 'parseconfig'
|
|
19
|
+
end
|
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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.
|
data/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Runcible
|
|
2
|
+
|
|
3
|
+
TODO: Write a gem description
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'runcible'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install runcible
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
TODO: Write usage instructions here
|
|
22
|
+
|
|
23
|
+
## Contributing
|
|
24
|
+
|
|
25
|
+
1. Fork it
|
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env rake
|
|
2
|
+
require "bundler/gem_tasks"
|
|
3
|
+
require "rake/testtask"
|
|
4
|
+
|
|
5
|
+
namespace :test do
|
|
6
|
+
Rake::TestTask.new :unit do |t|
|
|
7
|
+
t.pattern = 'test/unit/test_*.rb'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
task :integration do
|
|
11
|
+
options = {}
|
|
12
|
+
|
|
13
|
+
options[:mode] = ENV['mode']
|
|
14
|
+
options[:test_name] = ENV['test']
|
|
15
|
+
options[:auth_type] = ENV['auth_type']
|
|
16
|
+
|
|
17
|
+
if !['recorded', 'live'].include?(options[:mode])
|
|
18
|
+
puts "Invalid test mode"
|
|
19
|
+
else
|
|
20
|
+
require "test/integration/test_runner"
|
|
21
|
+
|
|
22
|
+
test_runner = PulpMiniTestRunner.new
|
|
23
|
+
|
|
24
|
+
if options[:test_name]
|
|
25
|
+
puts "Running tests for: #{options[:test_name]}"
|
|
26
|
+
puts "Using #{options[:mode]} Pulp."
|
|
27
|
+
|
|
28
|
+
test_runner.run_tests(options)
|
|
29
|
+
else
|
|
30
|
+
puts "Running full test suite."
|
|
31
|
+
puts "Using #{options[:mode]} data."
|
|
32
|
+
|
|
33
|
+
test_runner.run_tests(options)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/runcible.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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 "runcible/version"
|
|
25
|
+
require File.join(File.dirname(__FILE__), 'runcible/resources/*.rb')
|
|
@@ -0,0 +1,113 @@
|
|
|
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 'rest_client'
|
|
25
|
+
require 'oauth'
|
|
26
|
+
require 'json'
|
|
27
|
+
require './lib/runcible/oauth_setup'
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
module Runcible
|
|
31
|
+
class Base
|
|
32
|
+
|
|
33
|
+
# Accepted Configuration Values
|
|
34
|
+
#
|
|
35
|
+
# :user Pulp username
|
|
36
|
+
# :password Password for this user
|
|
37
|
+
# :oauth Oauth credentials
|
|
38
|
+
# :headers Additional headers e.g. content-type => "application/json"
|
|
39
|
+
def self.config=(conf={})
|
|
40
|
+
@@config = {
|
|
41
|
+
:headers => { :content_type => 'application/json',
|
|
42
|
+
:accept => 'application/json'}
|
|
43
|
+
}.merge(conf)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.config
|
|
47
|
+
@@config
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.call(method, path, options={})
|
|
51
|
+
client = RestClient::Resource.new(config[:url], config)
|
|
52
|
+
|
|
53
|
+
payload = [:post, :put].include?(method) ? generate_payload(options) : {}
|
|
54
|
+
headers = options[:headers] ? options[:headers] : {}
|
|
55
|
+
params = options[:params]
|
|
56
|
+
headers[:params] = params if params
|
|
57
|
+
|
|
58
|
+
args = [method]
|
|
59
|
+
args << payload.to_json if [:post, :put].include?(method)
|
|
60
|
+
args << headers if headers
|
|
61
|
+
|
|
62
|
+
path = '/pulp/api/v2/' + path
|
|
63
|
+
|
|
64
|
+
process_response(client[path].send(*args))
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.generate_payload(options)
|
|
68
|
+
if options[:payload]
|
|
69
|
+
if options[:payload][:optional]
|
|
70
|
+
if options[:payload][:required]
|
|
71
|
+
payload = options[:payload][:required].merge(options[:payload][:optional])
|
|
72
|
+
else
|
|
73
|
+
payload = options[:payload][:optional]
|
|
74
|
+
end
|
|
75
|
+
elsif options[:payload][:delta]
|
|
76
|
+
payload = options[:payload]
|
|
77
|
+
else
|
|
78
|
+
payload = options[:payload][:required]
|
|
79
|
+
end
|
|
80
|
+
else
|
|
81
|
+
payload = {}
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
return payload
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def self.process_response(response)
|
|
88
|
+
begin
|
|
89
|
+
response = RestClient::Response.create(JSON.parse(response.body), response.net_http_res, response.args)
|
|
90
|
+
rescue JSON::ParserError
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
return response
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def self.required_params(local_names, binding, keys_to_remove=[])
|
|
97
|
+
local_names = local_names.reduce({}) do |acc, v|
|
|
98
|
+
value = binding.eval(v.to_s) unless v == :_
|
|
99
|
+
acc[v] = value unless value.nil?
|
|
100
|
+
acc
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
local_names.delete("payload")
|
|
104
|
+
local_names.delete("optional")
|
|
105
|
+
keys_to_remove.each do |key|
|
|
106
|
+
local_names.delete(key)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
return local_names
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
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 './lib/runcible/resources/repository'
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
module Runcible
|
|
28
|
+
module Pulp
|
|
29
|
+
class RepositoryExtension < Runcible::Pulp::Repository
|
|
30
|
+
|
|
31
|
+
def self.create_with_importer(id, importer_type_id, importer_config)
|
|
32
|
+
required = required_params(binding.send(:local_variables), binding, ["id"])
|
|
33
|
+
create(id, required)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.create_with_distributors(id, distributors)
|
|
37
|
+
required = required_params(binding.send(:local_variables), binding, ["id"])
|
|
38
|
+
create(id, required)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.create_with_importer_and_distributors(id, importer_type_id, importer_config, distributors)
|
|
42
|
+
required = required_params(binding.send(:local_variables), binding, ["id"])
|
|
43
|
+
create(id, required)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.search_by_repository_ids(repository_ids)
|
|
47
|
+
criteria = {:filters =>
|
|
48
|
+
{ "id" => {"$in" => repository_ids}}
|
|
49
|
+
}
|
|
50
|
+
search(criteria)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.rpm_copy(destination_repo_id, source_repo_id, optional={})
|
|
54
|
+
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]
|
|
57
|
+
|
|
58
|
+
payload = {}
|
|
59
|
+
payload[:criteria] = criteria
|
|
60
|
+
payload[:override_config] = optional[:override_config] if optional[:override_config]
|
|
61
|
+
|
|
62
|
+
unit_copy(destination_repo_id, source_repo_id, payload)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
unless RestClient.const_defined? :OAUTH_EXTENSION
|
|
2
|
+
RestClient::OAUTH_EXTENSION = lambda do |request, args|
|
|
3
|
+
if args[:oauth]
|
|
4
|
+
uri = URI.parse args[:url]
|
|
5
|
+
default_options = { :site => "#{uri.scheme}://#{uri.host}:#{uri.port.to_s}",
|
|
6
|
+
:request_token_path => "",
|
|
7
|
+
:authorize_path => "",
|
|
8
|
+
:access_token_path => "" }
|
|
9
|
+
options = default_options.merge args[:oauth][:options] || { }
|
|
10
|
+
consumer = OAuth::Consumer.new(args[:oauth][:oauth_key], args[:oauth][:oauth_secret], options)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
method_to_http_request = { :get => Net::HTTP::Get,
|
|
14
|
+
:post => Net::HTTP::Post,
|
|
15
|
+
:put => Net::HTTP::Put,
|
|
16
|
+
:delete => Net::HTTP::Delete }
|
|
17
|
+
|
|
18
|
+
http_request = method_to_http_request[args[:method]].
|
|
19
|
+
new(args[:url]) # create Net::HTTPRequest to get oauth header,
|
|
20
|
+
# because RestClient::Request is not supported by Oauth
|
|
21
|
+
consumer.sign!(http_request)
|
|
22
|
+
request['Authorization'] = http_request['Authorization'] # add oauth header to rest_client request
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
unless RestClient.before_execution_procs.include? RestClient::OAUTH_EXTENSION
|
|
28
|
+
RestClient.add_before_execution_proc &RestClient::OAUTH_EXTENSION
|
|
29
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
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 './lib/runcible/base'
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
module Runcible
|
|
28
|
+
module Pulp
|
|
29
|
+
class Repository < Runcible::Base
|
|
30
|
+
|
|
31
|
+
def self.path(id=nil)
|
|
32
|
+
(id == nil) ? "repositories/" : "repositories/#{id}/"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.create(id, optional={})
|
|
36
|
+
required = required_params(binding.send(:local_variables), binding)
|
|
37
|
+
call(:post, path, :payload => { :required => required, :optional => optional })
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.retrieve(id, params={})
|
|
41
|
+
call(:get, path(id), :params => params)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def self.update(id, optional={})
|
|
45
|
+
call(:put, path(id), :payload => { :delta => optional })
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.delete(id)
|
|
49
|
+
call(:delete, path(id))
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def self.retrieve_all(optional={})
|
|
53
|
+
call(:get, path, :payload => { :optional => optional })
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.search(criteria, optional={})
|
|
57
|
+
required = required_params(binding.send(:local_variables), binding)
|
|
58
|
+
call(:post, path("search"), :payload => { :required => required, :optional => optional })
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self.associate_importer(id, importer_type_id, importer_config)
|
|
62
|
+
required = required_params(binding.send(:local_variables), binding)
|
|
63
|
+
call(:post, path("#{id}/importers"), :payload => { :required => required })
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def self.associate_distributor(id, distributor_type_id, distributor_config, optional={})
|
|
67
|
+
required = required_params(binding.send(:local_variables), binding, ["id"])
|
|
68
|
+
call(:post, path("#{id}/distributors"), :payload => { :required => required, :optional => optional })
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def self.sync(id, optional={})
|
|
72
|
+
call(:post, "#{path(id)}actions/sync/", :payload => { :optional => optional })
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def self.unit_copy(destination_repo_id, source_repo_id, optional={})
|
|
76
|
+
required = required_params(binding.send(:local_variables), binding, ["destination_repo_id"])
|
|
77
|
+
call(:post, "#{path(destination_repo_id)}actions/associate/", :payload => { :required => required, :optional=> optional })
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|