pulp_simple 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +4 -0
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/ChangeLog.rdoc +5 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +23 -0
- data/Rakefile +41 -0
- data/lib/pulp_simple.rb +47 -0
- data/lib/pulp_simple/base.rb +52 -0
- data/lib/pulp_simple/consumer_groups.rb +17 -0
- data/lib/pulp_simple/consumers.rb +28 -0
- data/lib/pulp_simple/jobs.rb +12 -0
- data/lib/pulp_simple/version.rb +4 -0
- data/pulp_simple.gemspec +26 -0
- data/spec/pulp_simple_spec.rb +63 -0
- data/spec/spec_helper.rb +5 -0
- metadata +161 -0
data/.document
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour --format documentation
|
data/ChangeLog.rdoc
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 sabatangle
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
= pulp_simple
|
2
|
+
|
3
|
+
== Description
|
4
|
+
|
5
|
+
Simple wrapper around Fedora's Pulp server REST API.
|
6
|
+
|
7
|
+
== Features
|
8
|
+
|
9
|
+
== Examples
|
10
|
+
|
11
|
+
require 'pulp_simple'
|
12
|
+
|
13
|
+
== Requirements
|
14
|
+
|
15
|
+
== Install
|
16
|
+
|
17
|
+
$ gem install pulp_simple
|
18
|
+
|
19
|
+
== Copyright
|
20
|
+
|
21
|
+
Copyright (c) 2012 Steve Abatangle. All Rights Reserved.
|
22
|
+
|
23
|
+
See LICENSE.txt for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
begin
|
7
|
+
gem 'rubygems-tasks', '~> 0.2'
|
8
|
+
require 'rubygems/tasks'
|
9
|
+
|
10
|
+
Gem::Tasks.new
|
11
|
+
rescue LoadError => e
|
12
|
+
warn e.message
|
13
|
+
warn "Run `gem install rubygems-tasks` to install 'rubygems/tasks'."
|
14
|
+
end
|
15
|
+
|
16
|
+
begin
|
17
|
+
gem 'rdoc', '~> 3.0'
|
18
|
+
require 'rdoc/task'
|
19
|
+
|
20
|
+
RDoc::Task.new do |rdoc|
|
21
|
+
rdoc.title = "pulp_simple"
|
22
|
+
end
|
23
|
+
rescue LoadError => e
|
24
|
+
warn e.message
|
25
|
+
warn "Run `gem install rdoc` to install 'rdoc/task'."
|
26
|
+
end
|
27
|
+
task :doc => :rdoc
|
28
|
+
|
29
|
+
begin
|
30
|
+
gem 'rspec', '~> 2.4'
|
31
|
+
require 'rspec/core/rake_task'
|
32
|
+
|
33
|
+
RSpec::Core::RakeTask.new
|
34
|
+
rescue LoadError => e
|
35
|
+
task :spec do
|
36
|
+
abort "Please run `gem install rspec` to install RSpec."
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
task :test => :spec
|
41
|
+
task :default => :spec
|
data/lib/pulp_simple.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'json'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
require 'pulp_simple/version'
|
6
|
+
require 'pulp_simple/base'
|
7
|
+
require 'pulp_simple/consumers'
|
8
|
+
require 'pulp_simple/consumer_groups'
|
9
|
+
require 'pulp_simple/jobs'
|
10
|
+
|
11
|
+
module PulpSimple
|
12
|
+
def self.pulp_server=(server)
|
13
|
+
@pulp_server = server
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.pulp_server
|
17
|
+
@pulp_server ||= config['pulp_server']
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.pulp_username=(username)
|
21
|
+
@pulp_username = username
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.pulp_username
|
25
|
+
@pulp_username ||= config['pulp_username']
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.pulp_password=(password)
|
29
|
+
@pulp_password = password
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.pulp_password
|
33
|
+
@pulp_password ||= config['pulp_password']
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.base_url
|
37
|
+
"https://#{pulp_username}:#{pulp_password}@#{pulp_server}/pulp/api"
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def self.config
|
43
|
+
YAML.load(File.read 'etc/pulp-simple-config.yml')
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module PulpSimple
|
2
|
+
class Base
|
3
|
+
attr_accessor :pulp_resource_name
|
4
|
+
|
5
|
+
self.class::DEFINED_METHODS = {}
|
6
|
+
|
7
|
+
def initialize(pulp_resource_name=nil)
|
8
|
+
@pulp_resource_name = pulp_resource_name
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(meth, *args, &block)
|
12
|
+
method_name = meth.to_s
|
13
|
+
args = args.first
|
14
|
+
if method_def = self.class::DEFINED_METHODS[method_name]
|
15
|
+
rest_url = full_url(method_name, method_def)
|
16
|
+
call_rest_method(method_name, rest_url, method_def[:http_method], args)
|
17
|
+
else
|
18
|
+
super
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def call_rest_method(method_name, rest_url, http_method, args)
|
25
|
+
args = args.to_json if args
|
26
|
+
begin
|
27
|
+
JSON.parse RestClient.send(http_method, rest_url, args)
|
28
|
+
rescue JSON::ParserError
|
29
|
+
''
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def short_class_name
|
34
|
+
self.class.name.to_s.sub(/^.*::/, '')
|
35
|
+
end
|
36
|
+
|
37
|
+
def base_url
|
38
|
+
"#{PulpSimple.base_url}/#{short_class_name.downcase}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def full_url(method_name, method_def)
|
42
|
+
url = base_url
|
43
|
+
url += "/#{@pulp_resource_name}" if @pulp_resource_name
|
44
|
+
url_method_name = method_def[:url_method_name] || method_name
|
45
|
+
url += "/#{url_method_name}" unless (url_method_name.nil? || url_method_name.empty?)
|
46
|
+
url += '/'
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module PulpSimple
|
2
|
+
class ConsumerGroups < PulpSimple::Base
|
3
|
+
|
4
|
+
DEFINED_METHODS = {
|
5
|
+
'list' => { :http_method => :get, :url_method_name => '', :class_method_ok? => true },
|
6
|
+
'info' => { :http_method => :get, :url_method_name => '' },
|
7
|
+
'installpackages' => { :http_method => :post },
|
8
|
+
'uninstallpackages' => { :http_method => :post },
|
9
|
+
'updatepackages' => { :http_method => :post },
|
10
|
+
'add_key_value_pair' => { :http_method => :post },
|
11
|
+
'delete_key_value_pair' => { :http_method => :post }
|
12
|
+
}
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module PulpSimple
|
2
|
+
class Consumers < PulpSimple::Base
|
3
|
+
|
4
|
+
DEFINED_METHODS = {
|
5
|
+
'list' => { :http_method => :get, :url_method_name => '' },
|
6
|
+
'info' => { :http_method => :get, :url_method_name => '' },
|
7
|
+
'package_profile' => { :http_method => :get },
|
8
|
+
'update_package_profile' => { :http_method => :put, :url_method_name => 'package_profile' },
|
9
|
+
'package_updates' => { :http_method => :get },
|
10
|
+
'repoids' => { :http_method => :get },
|
11
|
+
'keyvalues' => { :http_method => :get },
|
12
|
+
'errata' => { :http_method => :get },
|
13
|
+
'bind' => { :http_method => :post },
|
14
|
+
'unbind' => { :http_method => :post },
|
15
|
+
'add_key_value_pair' => { :http_method => :post },
|
16
|
+
'delete_key_value_pair' => { :http_method => :post },
|
17
|
+
'update_key_value_pair' => { :http_method => :post },
|
18
|
+
'history' => { :http_method => :post },
|
19
|
+
'installpackages' => { :http_method => :post },
|
20
|
+
'uninstallpackages' => { :http_method => :post },
|
21
|
+
'updatepackages' => { :http_method => :post },
|
22
|
+
'installerrata' => { :http_method => :post }
|
23
|
+
}
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
data/pulp_simple.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path('../lib/pulp_simple/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "pulp_simple"
|
7
|
+
gem.version = PulpSimple::VERSION
|
8
|
+
gem.summary = %q{Simple wrapper around Fedora Pulp REST API}
|
9
|
+
gem.description = %q{Simple wrapper around Fedora Pulp REST API}
|
10
|
+
gem.license = "MIT"
|
11
|
+
gem.authors = ["Steve Abatangle"]
|
12
|
+
gem.email = ['sabat@area51.org']
|
13
|
+
gem.homepage = nil
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_development_dependency "rubygems-tasks", "~> 0.2"
|
21
|
+
gem.add_development_dependency "rdoc", "~> 3.0"
|
22
|
+
gem.add_development_dependency "rspec", "~> 2.4"
|
23
|
+
gem.add_development_dependency "json"
|
24
|
+
gem.add_development_dependency "yaml"
|
25
|
+
gem.add_development_dependency "rest-client"
|
26
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pulp_simple'
|
3
|
+
|
4
|
+
describe PulpSimple do
|
5
|
+
before(:all) do
|
6
|
+
@config = { 'pulp_server' => 'test_pulp_server.gid.gap.com', 'pulp_username' => 'test_pulp_user', 'pulp_password' => 'test_pulp_password' }
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:each) do
|
10
|
+
PulpSimple.pulp_server = PulpSimple.pulp_username = PulpSimple.pulp_password = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it "has a VERSION constant" do
|
14
|
+
subject.const_get('VERSION').should_not be_empty
|
15
|
+
end
|
16
|
+
|
17
|
+
context "Pulp Server" do
|
18
|
+
it "lets you assign an explicit Pulp master server" do
|
19
|
+
PulpSimple.stub(:config).and_return(@config)
|
20
|
+
PulpSimple.pulp_server = 'foobar.gid.gap.com'
|
21
|
+
PulpSimple.pulp_server.should == 'foobar.gid.gap.com'
|
22
|
+
end
|
23
|
+
|
24
|
+
it "uses a default for the Pulp master server if no explicit value is assigned" do
|
25
|
+
PulpSimple.should_receive(:config).and_return(@config)
|
26
|
+
PulpSimple.pulp_server.should == @config['pulp_server']
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "Pulp User" do
|
31
|
+
it "lets you assign an explicit Pulp user" do
|
32
|
+
PulpSimple.stub(:config).and_return(@config)
|
33
|
+
PulpSimple.pulp_username = 'foobar_user'
|
34
|
+
PulpSimple.pulp_username.should == 'foobar_user'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "uses a default for the Pulp user if no explicit value is assigned" do
|
38
|
+
PulpSimple.should_receive(:config).and_return(@config)
|
39
|
+
PulpSimple.pulp_username.should == @config['pulp_username']
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "Pulp Password" do
|
44
|
+
it "lets you assign an explicit Pulp password" do
|
45
|
+
PulpSimple.stub(:config).and_return(@config)
|
46
|
+
PulpSimple.pulp_password = 'foobar_password'
|
47
|
+
PulpSimple.pulp_password.should == 'foobar_password'
|
48
|
+
end
|
49
|
+
|
50
|
+
it "uses a default for the Pulp password if no explicit value is assigned" do
|
51
|
+
PulpSimple.should_receive(:config).and_return(@config)
|
52
|
+
PulpSimple.pulp_password.should == @config['pulp_password']
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "Base URL" do
|
57
|
+
it "produces a valid base URL" do
|
58
|
+
PulpSimple.should_receive(:config).exactly(3).times.and_return(@config)
|
59
|
+
PulpSimple.base_url.should == "https://#{@config['pulp_username']}:#{@config['pulp_password']}@#{@config['pulp_server']}/pulp/api"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pulp_simple
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Steve Abatangle
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2012-05-21 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rubygems-tasks
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 2
|
31
|
+
version: "0.2"
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rdoc
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 3
|
44
|
+
- 0
|
45
|
+
version: "3.0"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rspec
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 2
|
58
|
+
- 4
|
59
|
+
version: "2.4"
|
60
|
+
type: :development
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: json
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
type: :development
|
74
|
+
version_requirements: *id004
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: yaml
|
77
|
+
prerelease: false
|
78
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
type: :development
|
87
|
+
version_requirements: *id005
|
88
|
+
- !ruby/object:Gem::Dependency
|
89
|
+
name: rest-client
|
90
|
+
prerelease: false
|
91
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
version: "0"
|
99
|
+
type: :development
|
100
|
+
version_requirements: *id006
|
101
|
+
description: Simple wrapper around Fedora Pulp REST API
|
102
|
+
email:
|
103
|
+
- sabat@area51.org
|
104
|
+
executables: []
|
105
|
+
|
106
|
+
extensions: []
|
107
|
+
|
108
|
+
extra_rdoc_files: []
|
109
|
+
|
110
|
+
files:
|
111
|
+
- .document
|
112
|
+
- .gitignore
|
113
|
+
- .rspec
|
114
|
+
- ChangeLog.rdoc
|
115
|
+
- LICENSE.txt
|
116
|
+
- README.rdoc
|
117
|
+
- Rakefile
|
118
|
+
- lib/pulp_simple.rb
|
119
|
+
- lib/pulp_simple/base.rb
|
120
|
+
- lib/pulp_simple/consumer_groups.rb
|
121
|
+
- lib/pulp_simple/consumers.rb
|
122
|
+
- lib/pulp_simple/jobs.rb
|
123
|
+
- lib/pulp_simple/version.rb
|
124
|
+
- pulp_simple.gemspec
|
125
|
+
- spec/pulp_simple_spec.rb
|
126
|
+
- spec/spec_helper.rb
|
127
|
+
has_rdoc: true
|
128
|
+
homepage:
|
129
|
+
licenses:
|
130
|
+
- MIT
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
segments:
|
142
|
+
- 0
|
143
|
+
version: "0"
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
segments:
|
150
|
+
- 0
|
151
|
+
version: "0"
|
152
|
+
requirements: []
|
153
|
+
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 1.3.7.1
|
156
|
+
signing_key:
|
157
|
+
specification_version: 3
|
158
|
+
summary: Simple wrapper around Fedora Pulp REST API
|
159
|
+
test_files:
|
160
|
+
- spec/pulp_simple_spec.rb
|
161
|
+
- spec/spec_helper.rb
|