pulp 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +42 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +147 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/examples/repositories.rb +205 -0
- data/examples/test_pulp.yml +4 -0
- data/lib/pulp.rb +26 -0
- data/lib/pulp/cds.rb +25 -0
- data/lib/pulp/common/debug.rb +37 -0
- data/lib/pulp/common/lifecycle.rb +166 -0
- data/lib/pulp/common/lifecycle/create.rb +16 -0
- data/lib/pulp/common/lifecycle/delete.rb +23 -0
- data/lib/pulp/common/lifecycle/get.rb +22 -0
- data/lib/pulp/common/lifecycle/update.rb +23 -0
- data/lib/pulp/connection/base.rb +84 -0
- data/lib/pulp/connection/handler.rb +59 -0
- data/lib/pulp/consumer.rb +23 -0
- data/lib/pulp/consumergroup.rb +22 -0
- data/lib/pulp/content.rb +14 -0
- data/lib/pulp/distribution.rb +11 -0
- data/lib/pulp/errata.rb +17 -0
- data/lib/pulp/event.rb +8 -0
- data/lib/pulp/filter.rb +19 -0
- data/lib/pulp/package.rb +20 -0
- data/lib/pulp/package_group.rb +8 -0
- data/lib/pulp/package_group_category.rb +7 -0
- data/lib/pulp/repository.rb +114 -0
- data/lib/pulp/service.rb +51 -0
- data/lib/pulp/task.rb +37 -0
- data/lib/pulp/task_history.rb +10 -0
- data/lib/pulp/task_snapshot.rb +9 -0
- data/lib/pulp/user.rb +12 -0
- data/spec/pulp/common/debug_spec.rb +42 -0
- data/spec/pulp/common/lifecycle/create_spec.rb +21 -0
- data/spec/pulp/common/lifecycle/delete_spec.rb +40 -0
- data/spec/pulp/common/lifecycle/get_spec.rb +42 -0
- data/spec/pulp/common/lifecycle/update_spec.rb +48 -0
- data/spec/pulp/common/lifecycle_spec.rb +393 -0
- data/spec/pulp/connection/base_spec.rb +312 -0
- data/spec/pulp/connection/handler_spec.rb +123 -0
- data/spec/pulp/content_spec.rb +21 -0
- data/spec/pulp/package_spec.rb +14 -0
- data/spec/pulp/repository_spec.rb +14 -0
- data/spec/pulp/service_spec.rb +85 -0
- data/spec/pulp/task_spec.rb +48 -0
- data/spec/pulp_spec.rb +4 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +32 -0
- metadata +252 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
module Pulp
|
2
|
+
class Consumer < Pulp::Connection::Base
|
3
|
+
|
4
|
+
has_crud
|
5
|
+
|
6
|
+
pulp_fields :description, :package_profile, :repoids
|
7
|
+
|
8
|
+
pulp_action :packages, :method => :get
|
9
|
+
pulp_action :certificate, :method => :get
|
10
|
+
pulp_action :bind
|
11
|
+
pulp_action :unbind
|
12
|
+
pulp_action :package_profile
|
13
|
+
pulp_action :history, :params => :optional
|
14
|
+
pulp_action :add_key_value_pair
|
15
|
+
pulp_action :update_key_value_pair
|
16
|
+
pulp_action :delete_key_value_pair
|
17
|
+
pulp_action :keyvalues, :method => :get
|
18
|
+
|
19
|
+
# from errata
|
20
|
+
pulp_action :listerrata, :array => :errata
|
21
|
+
pulp_action :installerrata, :method => :get
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Pulp
|
2
|
+
class Consumergroup < Pulp::Connection::Base
|
3
|
+
|
4
|
+
has_collection
|
5
|
+
has_delete
|
6
|
+
has_create
|
7
|
+
has_get
|
8
|
+
|
9
|
+
pulp_fields :description, :consumerids
|
10
|
+
|
11
|
+
pulp_action :add
|
12
|
+
pulp_action :remove
|
13
|
+
pulp_action :bind
|
14
|
+
pulp_action :unbind
|
15
|
+
pulp_action :add_key_value_pair
|
16
|
+
pulp_action :update_key_value_pair
|
17
|
+
pulp_action :delete_key_value_pair
|
18
|
+
|
19
|
+
#from errata
|
20
|
+
pulp_action :installerrata, :method => :get
|
21
|
+
end
|
22
|
+
end
|
data/lib/pulp/content.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
module Pulp
|
2
|
+
class Distribution < Pulp::Connection::Base
|
3
|
+
|
4
|
+
has_collection
|
5
|
+
has_get
|
6
|
+
|
7
|
+
# a pulp distribution can't be updated so far
|
8
|
+
pulp_locked_fields :arch, :_ns, :description, :family, :files, :url, :relativepath, :timestamp, :url, :variant, :version
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
data/lib/pulp/errata.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Pulp
|
2
|
+
class Errata < Pulp::Connection::Base
|
3
|
+
|
4
|
+
has_collection
|
5
|
+
has_get
|
6
|
+
has_create
|
7
|
+
has_delete
|
8
|
+
has_get
|
9
|
+
|
10
|
+
|
11
|
+
pulp_field :_ns, :locked => true
|
12
|
+
pulp_fields :description, :from_str, :immutable, :issued, :pkglist,
|
13
|
+
:pushcount, :reboot_suggested, :references, :release, :repo_defined, :status,
|
14
|
+
:title, :type, :updated, :version
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/pulp/event.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
module Pulp
|
2
|
+
class Event < Pulp::Connection::Base
|
3
|
+
|
4
|
+
has_collection :all_filters => [ :api, :methid, :principal, :field, :limit, :errors_only ]
|
5
|
+
|
6
|
+
pulp_fields :timestamp, :principal_type, :principal, :action, :method, :params, :result, :exception, :traceback
|
7
|
+
end
|
8
|
+
end
|
data/lib/pulp/filter.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Pulp
|
2
|
+
class Filter < Pulp::Connection::Base
|
3
|
+
|
4
|
+
has_collection
|
5
|
+
has_create
|
6
|
+
has_get
|
7
|
+
|
8
|
+
pulp_fields :description, :type, :package_list
|
9
|
+
|
10
|
+
def delete(force=false)
|
11
|
+
self.class.delete(id,force)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.delete(item_id,force=false)
|
15
|
+
base_delete("",item_id, :force => force)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/pulp/package.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Pulp
|
2
|
+
class Package < Pulp::Connection::Base
|
3
|
+
|
4
|
+
has_collection
|
5
|
+
has_create
|
6
|
+
has_get
|
7
|
+
has_delete
|
8
|
+
|
9
|
+
|
10
|
+
pulp_field :_ns, :locked => true
|
11
|
+
pulp_fields :arch, :buildhost, :checksum, :description,
|
12
|
+
:download_url, :epoch, :filename, :group,
|
13
|
+
:license, :name, :provides, :release,
|
14
|
+
:repo_defined, :requires, :size, :vendor, :version
|
15
|
+
|
16
|
+
def self.by_nvrea(name,version,release,epoch,arch)
|
17
|
+
self.new(base_get("#{name}/#{version}/#{release}/#{epoch}/#{arch}"))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module Pulp
|
2
|
+
class PackageGroup < Pulp::Connection::Base
|
3
|
+
|
4
|
+
pulp_locked_fields :mandatory_package_names, :description, :repo_defined, :default, :display_order,
|
5
|
+
:immutable, :user_visible, :translated_name, :translated_description, :conditional_package_names,
|
6
|
+
:optional_package_names, :langonly, :name
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
module Pulp
|
2
|
+
# Create Repository:
|
3
|
+
# Minimum Options to create a repository:
|
4
|
+
# r = Pulp::Repository.create(:feed => "http://mirror.switch.ch/ftp/mirror/epel/6/x86_64/", :id => 'epel-6-x86_64', :name => 'epel-6-x86_64', :arch => 'x86_64')
|
5
|
+
class Repository < Pulp::Connection::Base
|
6
|
+
has_crud :collection => { :all_filters => [ :id, :name, :arch, :groupid, :relative_path, :notes ] }
|
7
|
+
|
8
|
+
pulp_fields :arch, :name, :release
|
9
|
+
|
10
|
+
#these can't be updated
|
11
|
+
pulp_locked_fields :checksum_type, :clone_ids, :content_types, :feed_ca, :feed_cert, :feed_key,
|
12
|
+
:filters, :files_count, :groupid, :last_sync, :publish,
|
13
|
+
:consumer_ca, :consumer_cert, :distributionid, :notes, :next_scheduled_sync,
|
14
|
+
:package_count, :preserve_metadata, :relative_path, :source, :sync_schedule, :use_symlinks, :uri_ref
|
15
|
+
|
16
|
+
#special fields
|
17
|
+
pulp_deferred_fields :files, :keys
|
18
|
+
|
19
|
+
pulp_deferred_field :comps, :returns => :plain
|
20
|
+
pulp_deferred_field :errata, :array => Pulp::Errata, :filters => true
|
21
|
+
pulp_deferred_field :distribution, :array => Pulp::Distribution
|
22
|
+
pulp_deferred_field :packagegroupcategories, :array => Pulp::PackageGroupCategory, :filter => true
|
23
|
+
pulp_deferred_field :packagegroups, :array => Pulp::PackageGroup, :filter => true
|
24
|
+
pulp_deferred_field :packages, :array => Pulp::Package, :filter => true
|
25
|
+
|
26
|
+
pulp_action :sync, :returns => Pulp::Task, :params => :optional, :task_list => true
|
27
|
+
pulp_action :add_errata, :parse => false
|
28
|
+
pulp_action :add_file, :parse => false
|
29
|
+
pulp_action :add_filters, :parse => false
|
30
|
+
pulp_action :add_group, :parse => false
|
31
|
+
pulp_action :add_metadata, :parse => false
|
32
|
+
pulp_action :add_package, :parse => false
|
33
|
+
pulp_action :add_packagegroup_to_category, :parse => false
|
34
|
+
pulp_action :add_packages_to_group, :parse => false
|
35
|
+
pulp_action :add_keys, :parse => false
|
36
|
+
pulp_action :clone, :returns => Pulp::Task, :task_list => true
|
37
|
+
pulp_action :create_packagegroup, :returns => Pulp::PackageGroup
|
38
|
+
pulp_action :create_packagegroupcategory, :returns => Pulp::PackageGroupCategory
|
39
|
+
pulp_action :delete_errata, :parse => false
|
40
|
+
pulp_action :delete_package, :parse => false
|
41
|
+
pulp_action :delete_package_from_group, :parse => false
|
42
|
+
pulp_action :delete_packagegroup, :parse => false
|
43
|
+
pulp_action :delete_packagegroup_from_category, :parse => false
|
44
|
+
pulp_action :delete_packagegroupcategory, :parse => false
|
45
|
+
pulp_action :download_metadata, :parse => false
|
46
|
+
pulp_action :export, :returns => Pulp::Task, :task_list => true
|
47
|
+
pulp_action :generate_metadata, :returns => Pulp::Task, :task_list => true
|
48
|
+
pulp_action :get_package_by_filename
|
49
|
+
pulp_action :get_package_by_nvrea
|
50
|
+
pulp_action :import_comps, :parse => false
|
51
|
+
pulp_action :list_metadata
|
52
|
+
pulp_action :remove_distribution, :parse => false
|
53
|
+
pulp_action :remove_file, :parse => false
|
54
|
+
pulp_action :remove_filters, :parse => false
|
55
|
+
pulp_action :remove_group, :parse => false
|
56
|
+
pulp_action :remove_metadata, :parse => false
|
57
|
+
pulp_action :rmkeys, :parse => false
|
58
|
+
pulp_action :update_publish, :parse => false
|
59
|
+
pulp_action :upload, :parse => false
|
60
|
+
|
61
|
+
pulp_action :list_distribution, :method => :get, :append_slash => false
|
62
|
+
|
63
|
+
def self.schedules
|
64
|
+
self.base_get('schedules/')
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def update_sync_schedule(schedule)
|
69
|
+
update_schedule('sync',schedule)
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_schedule(type)
|
73
|
+
self.class.base_get("schedules/#{type}/",id)
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_sync_schedule
|
77
|
+
get_schedule('sync')
|
78
|
+
end
|
79
|
+
|
80
|
+
def delete_schedule(type)
|
81
|
+
self.class.base_delete("schedules/#{type}/",id)
|
82
|
+
end
|
83
|
+
|
84
|
+
def delete_sync_schedule
|
85
|
+
delete_schedule('sync')
|
86
|
+
end
|
87
|
+
|
88
|
+
def update_schedule(type,schedule)
|
89
|
+
self.class.base_put("schedules/#{type}/",id,{:schedule => schedule})
|
90
|
+
end
|
91
|
+
|
92
|
+
def add_note(key,note)
|
93
|
+
self.class.base_unparsed_post('notes/',self.id,{:key => key, :value => note})
|
94
|
+
refresh
|
95
|
+
self
|
96
|
+
end
|
97
|
+
|
98
|
+
def delete_note(key)
|
99
|
+
self.class.base_unparsed_delete("notes/#{key}/",self.id)
|
100
|
+
refresh
|
101
|
+
self
|
102
|
+
end
|
103
|
+
|
104
|
+
def update_note(key,new_value)
|
105
|
+
self.class.base_unparsed_put("notes/#{key}/",self.id,new_value)
|
106
|
+
refresh
|
107
|
+
self
|
108
|
+
end
|
109
|
+
|
110
|
+
pulp_update_action :feed, :params => :feed
|
111
|
+
pulp_update_action :feed_cert_data, :params => [:ca, :crt, :key]
|
112
|
+
pulp_update_action :consumer_cert_data, :params => [:ca, :crt, :key]
|
113
|
+
end
|
114
|
+
end
|
data/lib/pulp/service.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
module Pulp
|
2
|
+
class Service < Pulp::Connection::Base
|
3
|
+
|
4
|
+
def self.dependencies(pkgnames,repoids)
|
5
|
+
base_post('','dependencies/',{:pkgnames => pkgnames, :repoids => repoids})
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.search_package(params)
|
9
|
+
base_post('','search/packages/',params)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.start_upload(name,size,checksum,id=nil)
|
13
|
+
params = {
|
14
|
+
:name => name,
|
15
|
+
:size => size,
|
16
|
+
:checksum => checksum
|
17
|
+
}
|
18
|
+
params[:id] = id unless id.nil?
|
19
|
+
base_post('','upload',params)
|
20
|
+
end
|
21
|
+
|
22
|
+
# TODO: won't work yet probably
|
23
|
+
def self.append_file_content(id,data)
|
24
|
+
base_post('',"upload/#{id}/append",data)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.import_file(uploadid, metadata)
|
28
|
+
base_put('','upload/import',{:uploadid => uploadid, :metadata => metadata})
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.package_checksum(pkglist)
|
32
|
+
base_put('','packages/checksum/',pkglist)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.file_checksum(filelist)
|
36
|
+
base_put('','files/checksum/',filelist)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.associate_packages(package_info)
|
40
|
+
base_post('','associate/packages/',package_info)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.repo_discovery(url,type,cert_data)
|
44
|
+
Pulp::Task.new(base_post('','discovery/repo/',{:url => url, :type => type, :cert_data => cert_data }))
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.repo_discovery_staus(taskid)
|
48
|
+
Pulp::Task.new(base_get('',"discovery/repo/#{taskid}"))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/pulp/task.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Pulp
|
2
|
+
class Task < Pulp::Connection::Base
|
3
|
+
|
4
|
+
has_delete
|
5
|
+
has_get
|
6
|
+
has_collection :all_filters => [:state]
|
7
|
+
|
8
|
+
pulp_fields :args, :job_id, :class_name, :method_name, :state, :start_time, :finish_time, :result,
|
9
|
+
:exception ,:traceback, :progress, :scheduler, :scheduled_time, :snapshot_id
|
10
|
+
|
11
|
+
pulp_action :snapshots, :method => :get, :array => Pulp::TaskSnapshot
|
12
|
+
|
13
|
+
def cancel
|
14
|
+
self.class.cancel(id)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.cancel(taskid)
|
18
|
+
self.new(base_post(taskid,'cancel/'))
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete_snapshot
|
22
|
+
self.class.delete_snapshot(id)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.delete_snapshot(taskid)
|
26
|
+
Pulp::TaskSnapshot.new(base_delete(taskid,'snapshot/'))
|
27
|
+
end
|
28
|
+
|
29
|
+
def snapshot
|
30
|
+
self.class.snapshot(id)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.snapshot(taskid)
|
34
|
+
Pulp::TaskSnapshot.new(base_get(taskid,'snapshot/'))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Pulp
|
2
|
+
class TaskSnapshot < Pulp::Connection::Base
|
3
|
+
|
4
|
+
pulp_fields :class_name, :method_name, :state, :failure_threshold, :cancel_attempts, :callable,
|
5
|
+
:args, :kwargs, :progress, :timeout, :schedule_threshold, :_progress_callback, :start_time, :finish_time,
|
6
|
+
:result, :exception, :traceback
|
7
|
+
|
8
|
+
end
|
9
|
+
end
|
data/lib/pulp/user.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
3
|
+
|
4
|
+
class TestDebug
|
5
|
+
include Pulp::Common::Debug
|
6
|
+
end
|
7
|
+
|
8
|
+
describe Pulp::Common::Debug do
|
9
|
+
it "should provide a way to set and query a debug flag" do
|
10
|
+
TestDebug.should respond_to(:debug_enabled)
|
11
|
+
TestDebug.should respond_to(:debug_enabled=)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should provide a way to set and query an output engine" do
|
15
|
+
TestDebug.should respond_to(:output)
|
16
|
+
TestDebug.should respond_to(:output=)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should provide a method to print debug messages on class and instance level" do
|
20
|
+
TestDebug.should respond_to(:debug)
|
21
|
+
TestDebug.new.should respond_to(:debug)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should not have debugging enabled by default" do
|
25
|
+
TestDebug.debug_enabled.should == false
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not print out a debug message if the debug flag is not set" do
|
29
|
+
output = Object.new
|
30
|
+
output.expects(:puts).with('foo').never
|
31
|
+
TestDebug.output = output
|
32
|
+
TestDebug.debug('foo')
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should print out a debug message if the debug flag is set" do
|
36
|
+
TestDebug.debug_enabled = true
|
37
|
+
output = Object.new
|
38
|
+
output.expects(:puts).with('foo').once
|
39
|
+
TestDebug.output = output
|
40
|
+
TestDebug.debug('foo')
|
41
|
+
end
|
42
|
+
end
|