Class: Katello::PulpSyncStatus
- Inherits:
-
PulpTaskStatus
- Object
- ActiveRecord::Base
- Model
- TaskStatus
- PulpTaskStatus
- Katello::PulpSyncStatus
- Defined in:
- app/models/katello/pulp_sync_status.rb
Defined Under Namespace
Classes: Status
Constant Summary collapse
- HISTORY_ERROR =
'failed'
- HISTORY_SUCCESS =
'success'
- FINISHED =
"finished"
- ERROR =
"error"
- RUNNING =
"running"
- WAITING =
"waiting"
- CANCELED =
"canceled"
Constants inherited from PulpTaskStatus
Katello::PulpTaskStatus::WAIT_TIMES, Katello::PulpTaskStatus::WAIT_TIME_STEP
Constants included from Util::TaskStatus
Class Method Summary collapse
-
.convert_history(history_list) ⇒ Object
Pulp history items are moved from the task item, but are different and as a result we need to convert the structure.
- .pulp_task(pulp_status) ⇒ Object
Instance Method Summary collapse
- #after_refresh ⇒ Object
- #correct_state ⇒ Object
- #progress ⇒ Object
- #update_state(pulp_status) ⇒ Object
Methods inherited from PulpTaskStatus
#affected_units, any_task_running, dump_state, #error, poll_wait_time, #refresh, refresh, using_pulp_task, wait_for_tasks
Methods inherited from TaskStatus
#as_json, #canceled?, #description, #error?, #finished?, #generate_description, #human_readable_message, #humanize_parameters, #humanize_type, #initialize, make, #merge_pulp_task!, #message, #overall_status, #pending?, #pending_message, #refresh, refresh, #refresh_pulp, #result_description, #rmi_error_description, #system_filter_clause
Methods inherited from Model
Constructor Details
This class inherits a constructor from Katello::TaskStatus
Class Method Details
.convert_history(history_list) ⇒ Object
Pulp history items are moved from the task item, but are different
and as a result we need to convert the structure
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'app/models/katello/pulp_sync_status.rb', line 152 def self.convert_history(history_list) #history item attributes #["_id", "_ns", "added_count", "completed", "details", "error_message", "exception", "id", # "importer_id", "importer_type_id", "removed_count", "repo_id", "result", "started", "summary", # "traceback", "updated_count"] #task status attributes #["task_group_id", "exception", "traceback", "_href", "task_id", "call_request_tags", "reasons", # "start_time", "tags", "state", "finish_time", "dependency_failures", "schedule_id", "progress", # "call_request_group_id", "call_request_id", "principal_login", "response", "result"] history_list.collect do |history| result = history['result'] result = ERROR if result == HISTORY_ERROR result = FINISHED if result == HISTORY_SUCCESS { :state => result, :progress => {:details => history["details"]}, :finish_time => history['completed'], :start_time => history['started'] }.with_indifferent_access end end |
.pulp_task(pulp_status) ⇒ Object
130 131 132 133 134 |
# File 'app/models/katello/pulp_sync_status.rb', line 130 def self.pulp_task(pulp_status) task_status = PulpSyncStatus.find_by(:uuid => pulp_status[:id]) task_status = self.new { |t| yield t if block_given? } if task_status.nil? task_status.update_state(pulp_status) end |
Instance Method Details
#after_refresh ⇒ Object
126 127 128 |
# File 'app/models/katello/pulp_sync_status.rb', line 126 def after_refresh correct_state end |
#correct_state ⇒ Object
142 143 144 145 146 147 |
# File 'app/models/katello/pulp_sync_status.rb', line 142 def correct_state if [FINISHED].include?(self.state) && self.progress.error_details[:messages].present? self.state = ERROR self.save! unless self.new_record? end end |
#progress ⇒ Object
122 123 124 |
# File 'app/models/katello/pulp_sync_status.rb', line 122 def progress PulpSyncProgress.new(attributes['progress']) end |
#update_state(pulp_status) ⇒ Object
136 137 138 139 140 |
# File 'app/models/katello/pulp_sync_status.rb', line 136 def update_state(pulp_status) PulpSyncStatus.dump_state(pulp_status, self) correct_state self end |