Class: Content::Pulp::Repository
- Inherits:
-
Object
- Object
- Content::Pulp::Repository
- Defined in:
- app/services/content/pulp/repository.rb
Direct Known Subclasses
Constant Summary collapse
- PULP_SELECT_FIELDS =
['name', 'epoch', 'version', 'release', 'arch', 'checksumtype', 'checksum']
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pulp_id ⇒ Object
readonly
Returns the value of attribute pulp_id.
-
#relative_path ⇒ Object
readonly
Returns the value of attribute relative_path.
Class Method Summary collapse
Instance Method Summary collapse
- #auto_publish ⇒ Object
- #cancel_running_sync! ⇒ Object
- #checksum_type ⇒ Object
- #counters ⇒ Object
- #create ⇒ Object
-
#create_event_notifier ⇒ Object
once we keep a list pulp servers, this should be done in create/destroy.
- #create_with_distributor ⇒ Object
- #delete ⇒ Object
- #display_name ⇒ Object
- #feed ⇒ Object
-
#initialize(options = {}) ⇒ Repository
constructor
A new instance of Repository.
- #last_publish ⇒ Object
- #last_sync ⇒ Object
- #protected ⇒ Object
- #publish ⇒ Object
- #reload! ⇒ Object
- #sync ⇒ Object
- #sync_history ⇒ Object
- #sync_schedule ⇒ Object
- #sync_schedule=(schedule) ⇒ Object
- #sync_status ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Repository
Returns a new instance of Repository.
23 24 25 26 27 28 29 30 31 32 |
# File 'app/services/content/pulp/repository.rb', line 23 def initialize = {} .each do |k, v| instance_variable_set("@#{k}", v) if respond_to?("#{k}".to_sym) end raise('must define pulp id') unless pulp_id # initiate pulp connection Content::Pulp::Configuration.new end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
4 5 6 |
# File 'app/services/content/pulp/repository.rb', line 4 def content_type @content_type end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
4 5 6 |
# File 'app/services/content/pulp/repository.rb', line 4 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'app/services/content/pulp/repository.rb', line 4 def name @name end |
#pulp_id ⇒ Object (readonly)
Returns the value of attribute pulp_id.
4 5 6 |
# File 'app/services/content/pulp/repository.rb', line 4 def pulp_id @pulp_id end |
#relative_path ⇒ Object (readonly)
Returns the value of attribute relative_path.
4 5 6 |
# File 'app/services/content/pulp/repository.rb', line 4 def relative_path @relative_path end |
Class Method Details
.create(options = {}) ⇒ Object
9 10 11 |
# File 'app/services/content/pulp/repository.rb', line 9 def create( = {}) new().create end |
.delete(pulp_id) ⇒ Object
13 14 15 |
# File 'app/services/content/pulp/repository.rb', line 13 def delete(pulp_id) new(:pulp_id => pulp_id).delete end |
.sync(pulp_id) ⇒ Object
17 18 19 |
# File 'app/services/content/pulp/repository.rb', line 17 def sync(pulp_id) new(:pulp_id => pulp_id).sync end |
Instance Method Details
#auto_publish ⇒ Object
70 71 72 |
# File 'app/services/content/pulp/repository.rb', line 70 def auto_publish @auto_publish.nil? ? distributor['auto_publish'] : @auto_publish end |
#cancel_running_sync! ⇒ Object
108 109 110 111 112 113 |
# File 'app/services/content/pulp/repository.rb', line 108 def cancel_running_sync! return if sync_status.blank? || sync_status.not_synced? Runcible::Resources::Task.cancel(sync_status.task_id) rescue RestClient::ResourceNotFound # task already done, nothing to do here end |
#checksum_type ⇒ Object
46 47 48 |
# File 'app/services/content/pulp/repository.rb', line 46 def checksum_type details['checksum_type'] end |
#counters ⇒ Object
54 55 56 |
# File 'app/services/content/pulp/repository.rb', line 54 def counters details['content_unit_counts'] end |
#create ⇒ Object
38 39 40 |
# File 'app/services/content/pulp/repository.rb', line 38 def create create_repository end |
#create_event_notifier ⇒ Object
once we keep a list pulp servers, this should be done in create/destroy
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'app/services/content/pulp/repository.rb', line 116 def create_event_notifier url = Rails.application.routes.url_helpers. events_api_repositories_url(:only_path => false, :host => Setting[:foreman_url]) type = '*' resource = Runcible::Resources::EventNotifier notifs = resource.list #only create a notifier if one doesn't exist with the correct url exists = notifs.select { |n| n['event_types'] == [type] && n['notifier_config']['url'] == url } resource.create(resource::NotifierTypes::REST_API, { :url => url }, [type]) if exists.empty? true end |
#create_with_distributor ⇒ Object
34 35 36 |
# File 'app/services/content/pulp/repository.rb', line 34 def create_with_distributor create_repository [pulp_distributor] end |
#delete ⇒ Object
94 95 96 97 98 |
# File 'app/services/content/pulp/repository.rb', line 94 def delete Runcible::Resources::Repository.delete(pulp_id) rescue RestClient::ResourceNotFound => e true #not found is not a failure for delete end |
#display_name ⇒ Object
42 43 44 |
# File 'app/services/content/pulp/repository.rb', line 42 def display_name details['display_name'] end |
#feed ⇒ Object
58 59 60 |
# File 'app/services/content/pulp/repository.rb', line 58 def feed @feed || importer['config']['feed_url'] end |
#last_publish ⇒ Object
66 67 68 |
# File 'app/services/content/pulp/repository.rb', line 66 def last_publish distributor['last_publish'] end |
#last_sync ⇒ Object
62 63 64 |
# File 'app/services/content/pulp/repository.rb', line 62 def last_sync importer['last_sync'] end |
#protected ⇒ Object
74 75 76 |
# File 'app/services/content/pulp/repository.rb', line 74 def protected @protected.nil? ? distributor['protected'] : @protected end |
#publish ⇒ Object
104 105 106 |
# File 'app/services/content/pulp/repository.rb', line 104 def publish Runcible::Extensions::Repository.publish_all(pulp_id) end |
#reload! ⇒ Object
78 79 80 |
# File 'app/services/content/pulp/repository.rb', line 78 def reload! @details = nil end |
#sync ⇒ Object
100 101 102 |
# File 'app/services/content/pulp/repository.rb', line 100 def sync Runcible::Resources::Repository.sync(pulp_id) end |
#sync_history ⇒ Object
87 88 89 90 91 92 |
# File 'app/services/content/pulp/repository.rb', line 87 def sync_history history = Runcible::Extensions::Repository.sync_history(pulp_id) (history || []).map do |sync| Content::Pulp::RepositorySyncHistory.new(sync) end end |
#sync_schedule ⇒ Object
138 139 140 |
# File 'app/services/content/pulp/repository.rb', line 138 def sync_schedule Runcible::Resources::RepositorySchedule.list(pulp_id, Runcible::Extensions::YumImporter::ID) end |
#sync_schedule=(schedule) ⇒ Object
129 130 131 132 133 134 135 136 |
# File 'app/services/content/pulp/repository.rb', line 129 def sync_schedule=(schedule) type = Runcible::Extensions::YumImporter::ID if schedule.present? Runcible::Resources::RepositorySchedule.create(pulp_id, type, schedule) else Runcible::Extensions::Repository.remove_schedules(pulp_id, type) end end |
#sync_status ⇒ Object
82 83 84 85 |
# File 'app/services/content/pulp/repository.rb', line 82 def sync_status status = Runcible::Extensions::Repository.sync_status(pulp_id) Content::Pulp::RepositorySyncStatus.new(status.first) unless status.empty? end |